Master server written in Python. Replacement for HLMaster
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
663 B

from time import time
from struct import pack
import ipaddress
class ServerEntry:
def __init__(self, addr, challenge):
# Address
self.addr = addr
# Shortcuts for generating query
self.queryAddr = b''
if ':' in addr[0]:
self.queryAddr += ipaddress.ip_address(addr[0]).packed
else:
for i in addr[0].split('.'):
self.queryAddr += pack('!B', int(i))
self.queryAddr += pack('!H', int(addr[1]))
# Random number that server must return
self.challenge = challenge
self.sentChallengeAt = time()
# Remove server after this time.
# This maybe not instant
self.die = self.sentChallengeAt + 600