[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[minion-cvs] Fix address code so it no longer fails when connecting ...



Update of /home/minion/cvsroot/src/minion/lib/mixminion/server
In directory moria.mit.edu:/tmp/cvs-serv25545/lib/mixminion/server

Modified Files:
	MMTPServer.py 
Log Message:
Fix address code so it no longer fails when connecting to a remote host

Index: MMTPServer.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/server/MMTPServer.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- MMTPServer.py	12 Dec 2002 19:56:47 -0000	1.2
+++ MMTPServer.py	15 Dec 2002 04:48:46 -0000	1.3
@@ -229,15 +229,14 @@
     #    __terminator: None, or a string which will terminate the current read.
     #    __outbuf: None, or the remainder of the string we're currently
     #           writing.
-    def __init__(self, sock, tls, serverMode):
+    def __init__(self, sock, tls, serverMode, address=None):
         """Create a new SimpleTLSConnection.
 
            tls -- An underlying TLS connection.
            serverMode -- If true, we start with a server-side negotatiation.
                          otherwise, we start with a client-side negotatiation.
         """
-        self.__sock = sock
-	self.address = "%s:%s" % sock.getpeername()
+        self.__sock = sock            
         self.__con = tls
 	self.fd = self.__con.fileno()
 
@@ -246,6 +245,11 @@
         else:
             self.__state = self.__connectFn
 
+        if address is not None:
+            self.address = address
+        else:
+            self.address = "remote host"
+
     def isShutdown(self):
         """Returns true iff this connection is finished shutting down"""
         return self.__state is None
@@ -470,7 +474,8 @@
 	"""Create an MMTP connection to receive messages sent along a given
 	   socket.  When valid packets are received, pass them to the
 	   function 'consumer'."""
-        SimpleTLSConnection.__init__(self, sock, tls, 1)
+        SimpleTLSConnection.__init__(self, sock, tls, 1,
+                                     "%s:%s"%sock.getpeername())
         self.messageConsumer = consumer
         self.finished = self.__setupFinished
 
@@ -583,7 +588,7 @@
             pass
         tls = context.sock(sock)
 
-        SimpleTLSConnection.__init__(self, sock, tls, 0)
+        SimpleTLSConnection.__init__(self, sock, tls, 0, "%s:%s"%(ip,port))
         self.messageList = messageList
 	self.handleList = handleList
         self.finished = self.__setupFinished