From: <Blu...@us...> - 2009-11-29 20:26:34
|
Revision: 312 http://virtplayground.svn.sourceforge.net/virtplayground/?rev=312&view=rev Author: BlueWolf_ Date: 2009-11-29 20:26:22 +0000 (Sun, 29 Nov 2009) Log Message: ----------- Server checks for an uid that does not exist yet, instead of just assigning a random one without checking Modified Paths: -------------- trunk/server/core/server.py Modified: trunk/server/core/server.py =================================================================== --- trunk/server/core/server.py 2009-11-28 23:30:52 UTC (rev 311) +++ trunk/server/core/server.py 2009-11-29 20:26:22 UTC (rev 312) @@ -15,7 +15,7 @@ ## along with this program; if not, write to the Free Software ## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -import simplejson, socket, threading, time, md5 +import simplejson, socket, threading, time, md5, random from parser import Parser class Server(threading.Thread): @@ -147,8 +147,12 @@ sock.close() continue - # Chozo wanted the 8 so badly... + # Create unique user-id uid = md5.new(addr[0] + str(addr[1])).hexdigest()[:8] + while uid in self.clients: + uid = md5.new(addr[0] + str(addr[1]) + + str(random.random())).hexdigest()[:8] + self.clients[uid] = Client(uid, sock, self.clients, self.__call, self.__parse) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |