From e7231f3aead4d10a49dbb46092b4204fee598e2e Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Wed, 9 Aug 2017 23:30:22 +0200 Subject: [PATCH] Fix multiple TCP bind address handling --- src/network/connectionpool.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/network/connectionpool.py b/src/network/connectionpool.py index 3adc1772..1026d305 100644 --- a/src/network/connectionpool.py +++ b/src/network/connectionpool.py @@ -116,11 +116,12 @@ class BMConnectionPool(object): host = BMConfigParser().get("network", "bind") return host - def startListening(self): - host = self.getListeningIP() + def startListening(self, bind=None): + if bind is None: + bind = self.getListeningIP() port = BMConfigParser().safeGetInt("bitmessagesettings", "port") # correct port even if it changed - ls = network.tcp.TCPServer(host=host, port=port) + ls = network.tcp.TCPServer(host=bind, port=port) self.listeningSockets[ls.destination] = ls def startUDPSocket(self, bind=None): @@ -192,7 +193,11 @@ class BMConnectionPool(object): if acceptConnections: if not self.listeningSockets: - self.startListening() + if BMConfigParser().safeGet("network", "bind") == '': + self.startListening() + else: + for bind in re.sub("[^\w.]+", " ", BMConfigParser().safeGet("network", "bind")).split(): + self.startListening(bind) logger.info('Listening for incoming connections.') if not self.udpSockets: if BMConfigParser().safeGet("network", "bind") == '':