2019-01-22 01:30:42 +01:00
|
|
|
import socket
|
2019-01-23 10:28:23 +01:00
|
|
|
import threading
|
2020-05-27 15:45:58 +02:00
|
|
|
import time
|
2021-02-16 12:24:15 +01:00
|
|
|
import traceback
|
2019-01-22 01:30:42 +01:00
|
|
|
|
|
|
|
|
|
|
|
class MasterServer:
|
|
|
|
def __init__(self, server):
|
|
|
|
self.server = server
|
|
|
|
self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
|
|
|
self.masterserverip = "gckms.no-ip.org"
|
|
|
|
self.masterserverport = 27900
|
|
|
|
|
|
|
|
def register_and_run(self):
|
2020-05-27 15:45:58 +02:00
|
|
|
register_thread = threading.Thread(target=self._register)
|
|
|
|
register_thread.start()
|
|
|
|
return register_thread
|
2019-01-22 01:30:42 +01:00
|
|
|
|
2019-01-23 10:28:23 +01:00
|
|
|
def _register(self):
|
2019-01-22 01:30:42 +01:00
|
|
|
while True:
|
2020-05-28 12:06:10 +02:00
|
|
|
print("Sending register")
|
2021-02-16 12:24:15 +01:00
|
|
|
try:
|
|
|
|
self.socket.sendto(("0"+str(self.server.listen_port)).encode("ascii"), (self.masterserverip, self.masterserverport))
|
|
|
|
except:
|
|
|
|
traceback.print_exc()
|
2020-05-27 15:45:58 +02:00
|
|
|
time.sleep(120)
|