From e35f34d3a91009bb7440bd1a776349b77681ad0e Mon Sep 17 00:00:00 2001 From: Alberto Sottile Date: Sun, 3 Feb 2019 16:30:20 +0100 Subject: [PATCH] Restore TCP4 and TCP6 server endpoints --- syncplayServer.py | 46 ++++++++++++++++++---------------------------- 1 file changed, 18 insertions(+), 28 deletions(-) diff --git a/syncplayServer.py b/syncplayServer.py index eaa9f34..0b27c47 100755 --- a/syncplayServer.py +++ b/syncplayServer.py @@ -13,38 +13,28 @@ 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( - args.port, - args.password, - args.motd_file, - args.isolate_rooms, - args.salt, - args.disable_ready, - args.disable_chat, - args.max_chat_message_length, - args.max_username_length, - args.stats_db_file), - interface='::') - dsp.startListening() + factory = SyncFactory( + args.port, + args.password, + args.motd_file, + args.isolate_rooms, + args.salt, + args.disable_ready, + args.disable_chat, + args.max_chat_message_length, + args.max_username_length, + args.stats_db_file + ) + endpoint4 = TCP4ServerEndpoint(reactor, int(args.port)) + endpoint4.listen(factory) + endpoint6 = TCP6ServerEndpoint(reactor, int(args.port)) + endpoint6.listen(factory) reactor.run()