diff --git a/spoofident.py b/spoofident.py index 5696a39..2f4581b 100644 --- a/spoofident.py +++ b/spoofident.py @@ -1,6 +1,7 @@ from os import setuid,setgid,path from json import load -import dualstack +import socket +import select def handleIdent(fd): data=fd.recv(1024).strip() ports=data.split(',',2) @@ -25,9 +26,20 @@ if __name__ == '__main__': config=open(pwd+'/spoofident.json','r') settings=load(config) config.close() - server = dualstack.MultipleSocketsListener(settings['listeners']) + servers=[] + for pair in settings['listeners']: + if ':' in pair[0]: # TODO: write actual ip6 detection, properly? + servers.append(socket.socket(socket.AF_INET6,socket.SOCK_STREAM)) + else: + servers.append(socket.socket(socket.AF_INET,socket.SOCK_STREAM)) + print(str(pair[0])+'and'+str(pair[1])) + servers[-1].bind((pair[0], pair[1])) + servers[-1].listen(5) + servers[-1].setblocking(0) setgid(settings['setgid']) setuid(settings['setuid']) while True: - conn,addr=server.accept() - handleIdent(conn) + inready,outready,excready=select.select(servers,[],[]) + for ready in inready: + client,addr=ready.accept() + handleIdent(client) \ No newline at end of file