Fix multiple TCP bind address handling

This commit is contained in:
Peter Šurda 2017-08-09 23:30:22 +02:00
parent 6c695c8ac7
commit e7231f3aea
Signed by: PeterSurda
GPG Key ID: 0C5F50C0B5F37D87

View File

@ -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") == '':