mirror of
https://github.com/gnh1201/caterpillar.git
synced 2025-11-29 19:03:32 +00:00
Update server.py
This commit is contained in:
parent
8ed755ccd9
commit
18f928dbe8
|
|
@ -493,13 +493,16 @@ def proxy_server(webserver, port, scheme, method, url, conn, addr, data):
|
||||||
proxy_data['data']['client_address'] = resolved_address_list[0]
|
proxy_data['data']['client_address'] = resolved_address_list[0]
|
||||||
|
|
||||||
# build a tunnel
|
# build a tunnel
|
||||||
|
def relay_connect(id, raw_data, proxy_data):
|
||||||
try:
|
try:
|
||||||
id, raw_data = jsonrpc2_encode('relay_connect', proxy_data['data'])
|
# The tunnel connect forever until the client destroy it
|
||||||
relay = requests.post(server_url, headers=proxy_data['headers'], data=raw_data, stream=True, timeout=1)
|
relay = requests.post(server_url, headers=proxy_data['headers'], data=raw_data, stream=True, timeout=None)
|
||||||
for chunk in relay.iter_content(chunk_size=buffer_size):
|
for chunk in relay.iter_content(chunk_size=buffer_size):
|
||||||
print (chunk)
|
print (chunk)
|
||||||
except requests.exceptions.ReadTimeout as e:
|
except requests.exceptions.ReadTimeout as e:
|
||||||
pass
|
pass
|
||||||
|
id, raw_data = jsonrpc2_encode('relay_connect', proxy_data['data'])
|
||||||
|
start_new_thread(relay_connect, (id, raw_data, proxy_data))
|
||||||
|
|
||||||
# wait for the relay
|
# wait for the relay
|
||||||
print ("[*] waiting for the relay... %s" % (id))
|
print ("[*] waiting for the relay... %s" % (id))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user