mirror of
https://github.com/Syncplay/syncplay
synced 2025-02-18 20:16:50 +00:00
IPv6: revert to listenTCP and override createInternetSocket to have a dual stack server
This commit is contained in:
parent
218105d4ec
commit
c7396d882d
@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
#coding:utf8
|
#coding:utf8
|
||||||
|
|
||||||
|
import socket
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
# libpath
|
# libpath
|
||||||
@ -12,16 +13,24 @@ except AttributeError:
|
|||||||
import warnings
|
import warnings
|
||||||
warnings.warn("You must run Syncplay with Python 3.4 or newer!")
|
warnings.warn("You must run Syncplay with Python 3.4 or newer!")
|
||||||
|
|
||||||
from twisted.internet.endpoints import TCP6ServerEndpoint
|
from twisted.internet import reactor, tcp
|
||||||
from twisted.internet import reactor
|
|
||||||
|
|
||||||
from syncplay.server import SyncFactory, ConfigurationGetter
|
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)
|
||||||
|
s.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 0)
|
||||||
|
return s
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
argsGetter = ConfigurationGetter()
|
argsGetter = ConfigurationGetter()
|
||||||
args = argsGetter.getConfiguration()
|
args = argsGetter.getConfiguration()
|
||||||
endpoint = TCP6ServerEndpoint(reactor, int(args.port))
|
dsp = DualStackPort(int(args.port),
|
||||||
endpoint.listen(
|
|
||||||
SyncFactory(
|
SyncFactory(
|
||||||
args.port,
|
args.port,
|
||||||
args.password,
|
args.password,
|
||||||
@ -32,5 +41,7 @@ if __name__ == '__main__':
|
|||||||
args.disable_chat,
|
args.disable_chat,
|
||||||
args.max_chat_message_length,
|
args.max_chat_message_length,
|
||||||
args.max_username_length,
|
args.max_username_length,
|
||||||
args.stats_db_file))
|
args.stats_db_file),
|
||||||
|
interface='::')
|
||||||
|
dsp.startListening()
|
||||||
reactor.run()
|
reactor.run()
|
||||||
|
Loading…
Reference in New Issue
Block a user