Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add IPv6 support #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pymaster.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ def __init__(self, ip, port):
self.serverRL = IPRateLimit('server', 60, 30)
self.clientRL = IPRateLimit('client', 60, 120)
self.ipfilterRL = IPRateLimit('filterlog', 60, 10)
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))

log("Welcome to PyMaster!")
Expand Down
4 changes: 2 additions & 2 deletions server_entry.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from time import time
from struct import pack
import ipaddress

class ServerEntry:
challenge2 = 0
Expand Down Expand Up @@ -67,8 +68,7 @@ def __init__(self, addr, challenge):
self.addr = addr
# Shortcuts for generating query
self.queryAddr = b''
for i in addr[0].split('.'):
self.queryAddr += pack('!B', int(i))
self.queryAddr += ipaddress.ip_address(addr[0]).packed
self.queryAddr += pack('!H', int(addr[1]))

# Random number that server must return
Expand Down