]> code.delx.au - pymsnt/blobdiff - src/legacy/msn/msnw.py
The <host/> config option now sets the bind address for outgoing connections
[pymsnt] / src / legacy / msn / msnw.py
index 3810f5316d5a5c622cd6e429ef0387daf8fad952..1e361542a492e76fcacabac1905090514a5656d7 100644 (file)
@@ -25,6 +25,7 @@ class MSNConnection:
        MAXMESSAGESIZE     = 1400
        SWITCHBOARDTIMEOUT = 30.0*60.0
        GETALLAVATARS      = False
+       BINDADDRESS        = "0.0.0.0"
 
        def __init__(self, username, password, ident):
                """ Connects to the MSN servers.
@@ -62,7 +63,7 @@ class MSNConnection:
                d = Deferred()
                dispatchFactory.d = d
                d.addCallbacks(self._gotNotificationReferral, self.connectionFailed)
-               self.connectors.append(reactor.connectTCP("messenger.hotmail.com", 1863, dispatchFactory))
+               self.connectors.append(reactor.connectTCP("messenger.hotmail.com", 1863, dispatchFactory, bindAddress=(MSNConnection.BINDADDRESS, 0)))
                LogEvent(INFO, self.ident)
        
        def _gotNotificationReferral(self, (host, port)):
@@ -74,7 +75,7 @@ class MSNConnection:
                self.notificationFactory.password = self.password
                self.notificationFactory.msncon = self
                self.notificationFactory.protocol = NotificationClient
-               self.connectors.append(reactor.connectTCP(host, port, self.notificationFactory))
+               self.connectors.append(reactor.connectTCP(host, port, self.notificationFactory, bindAddress=(MSNConnection.BINDADDRESS, 0)))
                LogEvent(INFO, self.ident)
        
        def _sendSavedEvents(self):
@@ -502,7 +503,7 @@ class SwitchboardSessionBase(msn.SwitchboardClient):
                        self.reply = 0
                        factory = ClientFactory()
                        factory.buildProtocol = lambda addr: self
-                       reactor.connectTCP(host, port, factory)
+                       self.msncon.connectors.append(reactor.connectTCP(host, port, factory, bindAddress=(MSNConnection.BINDADDRESS, 0)))
                def sbRequestFailed(ignored=None):
                        LogEvent(INFO, self.ident)
                        del self.msncon.switchboardSessions[self.remoteUser]
@@ -517,7 +518,7 @@ class SwitchboardSessionBase(msn.SwitchboardClient):
                self.reply = 1
                factory = ClientFactory()
                factory.buildProtocol = lambda addr: self
-               reactor.connectTCP(host, port, factory)
+               self.msncon.connectors.append(reactor.connectTCP(host, port, factory, bindAddress=(MSNConnection.BINDADDRESS, 0)))
        
        def flushBuffer(self):
                for message, noerror in self.messageBuffer[:]: