Proxy Regex tests complete
This commit is contained in:
@@ -2,7 +2,7 @@ from multiprocessing import Process
|
||||
import socket
|
||||
|
||||
class TcpServer:
|
||||
def __init__(self,port,ipv6):
|
||||
def __init__(self,port,ipv6,proxy_port=None):
|
||||
def _startServer(port):
|
||||
sock = socket.socket(socket.AF_INET6 if ipv6 else socket.AF_INET, socket.SOCK_STREAM)
|
||||
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
@@ -13,6 +13,7 @@ class TcpServer:
|
||||
buf = connection.recv(4096)
|
||||
connection.send(buf)
|
||||
connection.close()
|
||||
self.proxy_port = proxy_port
|
||||
self.ipv6 = ipv6
|
||||
self.port = port
|
||||
self.server = Process(target=_startServer,args=[port])
|
||||
@@ -25,7 +26,7 @@ class TcpServer:
|
||||
|
||||
def sendCheckData(self,data):
|
||||
s = socket.socket(socket.AF_INET6 if self.ipv6 else socket.AF_INET, socket.SOCK_STREAM)
|
||||
s.connect(('::1' if self.ipv6 else '127.0.0.1', self.port))
|
||||
s.connect(('::1' if self.ipv6 else '127.0.0.1', self.proxy_port if self.proxy_port else self.port))
|
||||
s.sendall(data)
|
||||
received_data = s.recv(4096)
|
||||
s.close()
|
||||
|
||||
Reference in New Issue
Block a user