]> code.delx.au - pymsnt/commitdiff
The <host/> config option now sets the bind address for outgoing connections
authorJames Bunton <jamesbunton@fastmail.fm>
Sun, 29 Jul 2007 07:40:56 +0000 (17:40 +1000)
committerJames Bunton <jamesbunton@fastmail.fm>
Sun, 29 Jul 2007 07:40:56 +0000 (17:40 +1000)
config-example.xml
src/legacy/glue.py
src/legacy/msn/msnw.py

index 29534744fcdc155b78a5e5056d78780492f4fb95..7a3db86ad91004362e4589970d9db389507dca4a 100644 (file)
@@ -5,7 +5,7 @@
 <!-- The JabberID of the transport -->
 <jid>msn</jid>
 <!-- The public IP or DNS name of the machine the transport is running on -->
-<!-- This is needed for file transfer!! -->
+<!-- This is needed for file transfer!! This is also used as the IP address for outgoing connections -->
 <host>127.0.0.1</host>
 <!-- The component JID of the transport. Unless you're doing clustering, leave this alone -->
 <!-- <compjid>msn1</compjid> -->
index 265536059246c50e515309639d1c9bdfab25f892..4584f40e0bf98bdfa8a9d319e77b9c3a9aaf415f 100644 (file)
@@ -36,6 +36,7 @@ defaultAvatar = avatar.AvatarCache().setAvatar(defaultAvatarData)
 
 def reloadConfig():
        msn.MSNConnection.GETALLAVATARS = config.getAllAvatars
+       msn.MSNConnection.BINDADDRESS = config.host
        msn.setDebug(config._debugLevel >= 4)
 
 def isGroupJID(jid):
index 713c5e9131ae8da93a7cf07646efcaa8f22f8759..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
-                       self.msncon.connectors.append(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
-               self.msncon.connectors.append(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[:]: