[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[minion-cvs] Resolve a pending interface bug from email: binding the...



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

Modified Files:
	MMTPServer.py 
Log Message:
Resolve a pending interface bug from email: binding the wrong IP gave an unhelpful error

Index: MMTPServer.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/server/MMTPServer.py,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -d -r1.80 -r1.81
--- MMTPServer.py	16 Feb 2004 22:50:38 -0000	1.80
+++ MMTPServer.py	1 Mar 2004 07:18:02 -0000	1.81
@@ -32,7 +32,7 @@
 import mixminion.TLSConnection
 import mixminion._minionlib as _ml
 from mixminion.Common import MixError, MixFatalError, MixProtocolError, \
-     LOG, stringContains, floorDiv
+     LOG, stringContains, floorDiv, UIError
 from mixminion.Crypto import sha1, getCommonPRNG
 from mixminion.Packet import PACKET_LEN, DIGEST_LEN, IPV4Info, MMTPHostInfo
 from mixminion.MMTPClient import PeerCertificateCache, MMTPClientConnection
@@ -304,9 +304,15 @@
         self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
         try:
             self.sock.bind((self.ip, self.port))
-        except socket.error, e:
-            raise MixFatalError("Error while trying to bind to %s:%s: %s"%(
-                self.ip, self.port, e))
+        except socket.error, (err,msg):
+            extra = ""
+            code = errno.errorcode.get(err)
+            if code in ["EADDRNOTAVAIL", "WSAEADDRNOTAVAIL"]:
+                extra = " (Is that really your IP address?)"
+            elif code == "EACCES":
+                extra = " (Remember, only root can bind low ports)"
+            raise UIError("Error while trying to bind to %s:%s: %s%s"%(
+                self.ip, self.port, msg, extra))
         self.sock.listen(backlog)
         self.connectionFactory = connectionFactory
         self.isOpen = 1