Restore TCP4 and TCP6 server endpoints

This commit is contained in:
Alberto Sottile 2019-02-03 16:30:20 +01:00
parent e1af902f7c
commit e35f34d3a9

View File

@ -13,28 +13,15 @@ except AttributeError:
import warnings
warnings.warn("You must run Syncplay with Python 3.4 or newer!")
from twisted.internet import reactor, tcp
from twisted.internet import reactor
from twisted.internet.endpoints import TCP4ServerEndpoint, TCP6ServerEndpoint
from syncplay.server import SyncFactory, ConfigurationGetter
class DualStackPort(tcp.Port):
def __init__(self, port, factory, backlog=50, interface='', reactor=None):
tcp.Port.__init__(self, port, factory, backlog, interface, reactor)
def createInternetSocket(self):
s = tcp.Port.createInternetSocket(self)
try:
s.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 0)
except:
pass
return s
if __name__ == '__main__':
argsGetter = ConfigurationGetter()
args = argsGetter.getConfiguration()
dsp = DualStackPort(int(args.port),
SyncFactory(
factory = SyncFactory(
args.port,
args.password,
args.motd_file,
@ -44,7 +31,10 @@ if __name__ == '__main__':
args.disable_chat,
args.max_chat_message_length,
args.max_username_length,
args.stats_db_file),
interface='::')
dsp.startListening()
args.stats_db_file
)
endpoint4 = TCP4ServerEndpoint(reactor, int(args.port))
endpoint4.listen(factory)
endpoint6 = TCP6ServerEndpoint(reactor, int(args.port))
endpoint6.listen(factory)
reactor.run()