Skip to content

Ah, maybe not.

July 21, 2014

Thinking about the code i was going to have to add to hide the secret number in the data stream it seems like a lot of work. I’m going to grab a simplified version of the code I used for maintaining the table of names and ips in the multi-user server and I’ll keep the secret numbers in the table. i wasn’t crazy about the queue management but it’s simple enough:

int nextslot=0, numslots=32;
int getipslot(union IPaddr whichip){//see if this ip is registered and register it if not
	int i=0, tslot;
	while(whichip.l!=regip[i].l && i<numslots) i++;
	if (i<numslots){
		return i;
		if (nextslot>=numslots){
		regip[tslot]=thisip; //register the ip
		return tslot;

First it runs through the table looking for the ip. if it doesn’t find it it uses the slot pointed to by nextslot which is initialized to 0, advances whenever a slot is used, and wraps around at the end of the table. So, once it has seen 32 distinct ips, it starts reusing the oldest ones. It’s possible that there could be a collision but i think that would represent somebody leaving a session idle for a long time so if something odd happens they may not even notice.

From → web server

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: