MCPcopy Create free account
hub / github.com/Syncplay/syncplay / __init__

Method __init__

syncplay/server.py:26–67  ·  view source on GitHub ↗
(self, port='', password='', motdFilePath=None, roomsDbFile=None, permanentRoomsFile=None, isolateRooms=False, salt=None,
                 disableReady=False, disableChat=False, maxChatMessageLength=constants.MAX_CHAT_MESSAGE_LENGTH,
                 maxUsernameLength=constants.MAX_USERNAME_LENGTH, statsDbFile=None, tlsCertPath=None)

Source from the content-addressed store, hash-verified

24
25class SyncFactory(Factory):
26 def __init__(self, port='', password='', motdFilePath=None, roomsDbFile=None, permanentRoomsFile=None, isolateRooms=False, salt=None,
27 disableReady=False, disableChat=False, maxChatMessageLength=constants.MAX_CHAT_MESSAGE_LENGTH,
28 maxUsernameLength=constants.MAX_USERNAME_LENGTH, statsDbFile=None, tlsCertPath=None):
29 self.isolateRooms = isolateRooms
30 syncplay.messages.setLanguage(syncplay.messages.getInitialLanguage())
31 print(getMessage("welcome-server-notification").format(syncplay.version))
32 self.port = port
33 if password:
34 password = password.encode('utf-8')
35 password = hashlib.md5(password).hexdigest()
36 self.password = password
37 if salt is None:
38 salt = RandomStringGenerator.generate_server_salt()
39 print(getMessage("no-salt-notification").format(salt))
40 self._salt = salt
41 self._motdFilePath = motdFilePath
42 self.roomsDbFile = roomsDbFile
43 self.disableReady = disableReady
44 self.disableChat = disableChat
45 self.maxChatMessageLength = maxChatMessageLength if maxChatMessageLength is not None else constants.MAX_CHAT_MESSAGE_LENGTH
46 self.maxUsernameLength = maxUsernameLength if maxUsernameLength is not None else constants.MAX_USERNAME_LENGTH
47 self.permanentRoomsFile = permanentRoomsFile if permanentRoomsFile is not None and os.path.isfile(permanentRoomsFile) else None
48 self.permanentRooms = self.loadListFromMultilineTextFile(self.permanentRoomsFile) if self.permanentRoomsFile is not None else []
49 if not isolateRooms:
50 self._roomManager = RoomManager(self.roomsDbFile, self.permanentRooms)
51 else:
52 self._roomManager = PublicRoomManager()
53 if statsDbFile is not None:
54 self._statsDbHandle = StatsDBManager(statsDbFile)
55 self._statsRecorder = StatsRecorder(self._statsDbHandle, self._roomManager)
56 statsDelay = 5*(int(self.port)%10 + 1)
57 self._statsRecorder.startRecorder(statsDelay)
58 else:
59 self._statsDbHandle = None
60 if tlsCertPath is not None:
61 self.certPath = tlsCertPath
62 self._TLSattempts = 0
63 self._allowTLSconnections(self.certPath)
64 else:
65 self.certPath = None
66 self.options = None
67 self.serverAcceptsTLS = False
68
69 def loadListFromMultilineTextFile(self, path):
70 if not os.path.isfile(path):

Callers

nothing calls this directly

Calls 9

_allowTLSconnectionsMethod · 0.95
getMessageFunction · 0.90
RoomManagerClass · 0.85
PublicRoomManagerClass · 0.85
StatsDBManagerClass · 0.85
StatsRecorderClass · 0.85
generate_server_saltMethod · 0.80
startRecorderMethod · 0.45

Tested by

no test coverage detected