add IPv6 support

This commit is contained in:
ghost 2023-12-26 19:01:26 +02:00
parent ba2acb1f71
commit 39df7f1995
1 changed files with 4 additions and 1 deletions

View File

@ -19,7 +19,10 @@ MAX_SERVERS_FOR_IP = 14
class PyMaster:
def __init__(self, ip, port):
self.serverList = []
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
if ':' in ip:
self.sock = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
else:
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.sock.bind((ip, port))
logging.debug("Welcome to PyMaster!")