2018-07-20 17:21:52 +00:00
|
|
|
#!/usr/bin/env python3
|
2012-10-12 16:37:12 +00:00
|
|
|
#coding:utf8
|
|
|
|
|
2019-01-25 14:51:53 +00:00
|
|
|
import socket
|
2018-06-19 21:24:24 +00:00
|
|
|
import sys
|
2013-12-18 06:33:39 +00:00
|
|
|
|
|
|
|
# libpath
|
|
|
|
|
2018-05-31 14:53:09 +00:00
|
|
|
try:
|
2018-06-18 15:02:03 +00:00
|
|
|
if (sys.version_info.major != 3) or (sys.version_info.minor < 4):
|
|
|
|
raise Exception("You must run Syncplay with Python 3.4 or newer!")
|
2018-05-31 14:53:09 +00:00
|
|
|
except AttributeError:
|
|
|
|
import warnings
|
2018-06-18 15:02:03 +00:00
|
|
|
warnings.warn("You must run Syncplay with Python 3.4 or newer!")
|
2014-06-19 18:31:49 +00:00
|
|
|
|
2019-01-25 14:51:53 +00:00
|
|
|
from twisted.internet import reactor, tcp
|
2012-10-12 16:37:12 +00:00
|
|
|
|
2014-04-21 15:24:30 +00:00
|
|
|
from syncplay.server import SyncFactory, ConfigurationGetter
|
2014-04-19 09:30:28 +00:00
|
|
|
|
2019-01-25 14:51:53 +00:00
|
|
|
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)
|
2019-01-26 15:37:50 +00:00
|
|
|
try:
|
|
|
|
s.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 0)
|
|
|
|
except:
|
|
|
|
pass
|
2019-01-25 14:51:53 +00:00
|
|
|
return s
|
|
|
|
|
2014-04-21 15:24:30 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
argsGetter = ConfigurationGetter()
|
|
|
|
args = argsGetter.getConfiguration()
|
2019-01-25 14:51:53 +00:00
|
|
|
dsp = DualStackPort(int(args.port),
|
2018-07-23 21:08:44 +00:00
|
|
|
SyncFactory(
|
2018-07-25 12:04:58 +00:00
|
|
|
args.port,
|
2018-07-23 21:08:44 +00:00
|
|
|
args.password,
|
|
|
|
args.motd_file,
|
|
|
|
args.isolate_rooms,
|
|
|
|
args.salt,
|
|
|
|
args.disable_ready,
|
|
|
|
args.disable_chat,
|
2018-07-25 12:29:44 +00:00
|
|
|
args.max_chat_message_length,
|
|
|
|
args.max_username_length,
|
2019-01-25 14:51:53 +00:00
|
|
|
args.stats_db_file),
|
|
|
|
interface='::')
|
|
|
|
dsp.startListening()
|
2014-04-21 15:24:30 +00:00
|
|
|
reactor.run()
|