Skip to content

Commit

Permalink
Update server.py
Browse files Browse the repository at this point in the history
  • Loading branch information
gnh1201 authored Feb 27, 2024
1 parent 8ed755c commit 18f928d
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,13 +493,16 @@ def bypass_callback(response, *args, **kwargs):
proxy_data['data']['client_address'] = resolved_address_list[0]

# build a tunnel
try:
id, raw_data = jsonrpc2_encode('relay_connect', proxy_data['data'])
relay = requests.post(server_url, headers=proxy_data['headers'], data=raw_data, stream=True, timeout=1)
for chunk in relay.iter_content(chunk_size=buffer_size):
print (chunk)
except requests.exceptions.ReadTimeout as e:
pass
def relay_connect(id, raw_data, proxy_data):
try:
# The tunnel connect forever until the client destroy it
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):
print (chunk)
except requests.exceptions.ReadTimeout as e:
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
print ("[*] waiting for the relay... %s" % (id))
Expand Down

0 comments on commit 18f928d

Please sign in to comment.