From 19ff20f0af940d99614de3c5896e9899af367fd0 Mon Sep 17 00:00:00 2001 From: James Bunton Date: Sun, 29 Jul 2007 17:40:56 +1000 Subject: [PATCH] The config option now sets the bind address for outgoing connections --- config-example.xml | 2 +- src/legacy/glue.py | 1 + src/legacy/msn/msnw.py | 9 +++++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/config-example.xml b/config-example.xml index 2953474..7a3db86 100644 --- a/config-example.xml +++ b/config-example.xml @@ -5,7 +5,7 @@ msn - + 127.0.0.1 diff --git a/src/legacy/glue.py b/src/legacy/glue.py index 2655360..4584f40 100644 --- a/src/legacy/glue.py +++ b/src/legacy/glue.py @@ -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): diff --git a/src/legacy/msn/msnw.py b/src/legacy/msn/msnw.py index 713c5e9..1e36154 100644 --- a/src/legacy/msn/msnw.py +++ b/src/legacy/msn/msnw.py @@ -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[:]: -- 2.39.2