Overview of this problem is, I want to connect to the internet through websocket tunneling.
Here is my expected timeline that should have working:

My client device is only allowed to connect to the Cloudflare IPs, therefore I want my device (client) to connect the internet through websocket server as a proxy.
So my client device has tun2sock application, basically it's VPN. That app require socks5 address and port. It's succesfully connected, and I think there is no problem in socks5.
But I'm not sure about socks5 server script and websocket server script. Here is I provide my code both socks5_server.py when handling websocket connection and websocket_server.py. Note that I put some custom header in websocket header to indicate server what client want to connect to, it's named
Tunnel: TCP|addr|port
With that, ws server can parsing the custom ws header and create connection to the desired address and port.
Also I confident that my socks5 server has been following RFC1928, because I think there is no issue in socks5 server, but not for handling websocket connection inside socks5 server.
Here is socks5_server.py
import socket
from rfc1928_constants import *
from time import sleep
NUM_METHOD = 1
METHOD_REQ = VER_5 + NUM_METHOD.to_bytes(1, 'big') + METHOD_NOAUTHENTICATIONREQUIRED
METHOD_RES = VER_5 + METHOD_NOAUTHENTICATIONREQUIRED
SOCKS5_SERVER_IP = '192.168.43.248'
SOCKS5_SERVER_PORT = 9999
socks5clients: list = []
def start_ws_tunnel(DST_ADDR: str, DST_PORT: int, clientsock: socket.socket, clientaddr: tuple[str, int]):
# Websocket client initialization...
ws = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
wsreq: bytes = b"GET / HTTP/1.1\r\n" \
b"Host: wstun.ikhwanperwira.my.id\r\n" \
b"Tunnel: TCP|"+DST_ADDR.encode()+b"|"+str(DST_PORT).encode()+b"\r\n" \
b"Upgrade: websocket\r\n" \
b"Connection: Upgrade\r\n" \
b"Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw==\r\n" \
b"Sec-WebSocket-Version: 13\r\n\r\n"
ws.connect(('104.26.6.171', 80)) # Connect to Cloudflare IP
ws.send(wsreq)
wsres: bytes = ws.recv(1024)
if not b"101 Switching Protocols" in wsres[:64]:
raise Exception(f"Websocket server didn't return 101 Switching Protocols! {wsres}")
print('Switching protocol accepted from websocket server!')
while 1:
req = clientsock.recv(4096)
if not req:
print('connection closed from client')
break
succeed = ws.send(req)
if succeed != len(req):
print('failed on forwarding request from client to server')
break
res = ws.recv(4096)
if not res:
print('connection closed from server')
break
succeed = clientsock.send(res)
if succeed != len(res):
print('failed on forwarding response from server to client')
break
print('Connection closed:', clientaddr)
ws.close()
clientsock.close()
del ws
del clientsock
del clientaddr
def client_collector(interrupt):
global socks5clients
tcpsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
tcpsocket.bind((SOCKS5_SERVER_IP, SOCKS5_SERVER_PORT))
tcpsocket.listen(5)
while not interrupt.is_set():
socks5clients.append(tcpsocket.accept())
def tcp_handler(interrupt):
from threading import Thread
global socks5clients
while not interrupt.is_set():
try:
for client in socks5clients:
clientsock, clientaddr = client
method_req = clientsock.recv(1024)
VER = method_req[0:1]
NMETHOD = method_req[1:2]
METHODS = method_req[2:2+int.from_bytes(NMETHOD, 'big')]
if method_req == METHOD_REQ:
method_res = METHOD_RES
nbytes_sent = clientsock.send(method_res)
if nbytes_sent != len(method_res):
raise Exception('Failed to send method response!')
else:
raise Exception(f'Invalid method request! {METHOD_REQ}')
socks5req: bytes = clientsock.recv(1024)
VER: bytes = socks5req[0:1]
CMD: bytes = socks5req[1:2]
RSV: bytes = socks5req[2:3]
ATYP = socks5req[3:4]
if VER != VER_5:
raise Exception('Invalid version number!')
if CMD not in [CMD_CONNECT, CMD_BIND, CMD_UDP]:
raise Exception('Invalid command!')
if RSV != TCP_RSV:
raise Exception('Invalid reserved byte!')
BND_ADDR, BND_PORT = SOCKS5_SERVER_IP, SOCKS5_SERVER_PORT
# if CMD == CMD_UDP:
# print('UDP request detected on:', clientaddr)
if ATYP == ATYP_IPV4:
DST_ADDR_LEN = ATYP_IPV4_LEN
DST_ADDR = socket.inet_ntoa(socks5req[4:4+DST_ADDR_LEN])
DST_PORT = int.from_bytes(socks5req[4+DST_ADDR_LEN:4+DST_ADDR_LEN+2], 'big')
socks5res = VER_5 + REP_SUCCEEDED + TCP_RSV + ATYP_IPV4 + socket.inet_aton(BND_ADDR) + BND_PORT.to_bytes(2, 'big')
elif ATYP == ATYP_IPV6:
DST_ADDR_LEN = ATYP_IPV6_LEN
DST_ADDR = socket.inet_ntop(socket.AF_INET6, socks5req[4:4+DST_ADDR_LEN])
DST_PORT = int.from_bytes(socks5req[4+DST_ADDR_LEN:4+DST_ADDR_LEN+2], 'big')
socks5res = VER_5 + REP_SUCCEEDED + TCP_RSV + ATYP_IPV4 + socket.inet_aton(BND_ADDR) + BND_PORT.to_bytes(2, 'big')
elif ATYP == ATYP_DNS:
DST_ADDR_LEN = int.from_bytes(socks5req[4:5], 'big')
DST_ADDR = socks5req[5:5+DST_ADDR_LEN].decode('ascii')
DST_PORT = int.from_bytes(socks5req[5+DST_ADDR_LEN:5+DST_ADDR_LEN+2], 'big')
socks5res = VER_5 + REP_SUCCEEDED + TCP_RSV + ATYP_IPV4 + socket.inet_aton(BND_ADDR) + BND_PORT.to_bytes(2, 'big')
clientsock.send(socks5res)
if CMD != CMD_UDP:
# if DST_ADDR == '93.184.216.34':
Thread(target=start_ws_tunnel, args=(DST_ADDR, DST_PORT, clientsock, clientaddr, )).start()
socks5clients.remove(client)
except Exception as e:
print(e)
pass
def udp_handler(interrupt):
udpsocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
udpsocket.bind((SOCKS5_SERVER_IP, SOCKS5_SERVER_PORT))
while not interrupt.is_set():
try:
udpreq, clientaddr = udpsocket.recvfrom(2048)
RSV = udpreq[0:2]
FRAG = udpreq[2:3]
ATYP = udpreq[3:4]
if ATYP == ATYP_IPV4:
DST_ADDR_LEN = ATYP_IPV4_LEN
DST_ADDR = socket.inet_ntoa(udpreq[4:4+DST_ADDR_LEN])
offset = 4
elif ATYP == ATYP_IPV6:
DST_ADDR_LEN = ATYP_IPV6_LEN
DST_ADDR = socket.inet_ntop(socket.AF_INET6, udpreq[4:4+DST_ADDR_LEN])
offset = 4
elif ATYP == ATYP_DNS:
DST_ADDR_LEN = int.from_bytes(udpreq[4:5], 'big')
DST_ADDR = udpreq[5:5+DST_ADDR_LEN].decode('ascii')
offset = 5
else:
raise Exception('Invalid address type!')
DST_PORT = int.from_bytes(udpreq[offset+DST_ADDR_LEN:offset+DST_ADDR_LEN+2], 'big')
data = udpreq[offset+DST_ADDR_LEN+2:]
udpres = udpreq[:offset+DST_ADDR_LEN+2] + (b'UDP:'+ data)
if DST_ADDR == '104.26.6.171':
print(clientaddr, 'UDP', (DST_ADDR, DST_PORT), data, sep=' -> ')
udpsocket.sendto(udpres, clientaddr)
sleep(1)
except:
pass
if __name__ == '__main__':
from threading import Thread, Event
interrupt = Event()
client_collector_thread = Thread(target=client_collector, args=(interrupt, ))
tcp_thread = Thread(target=tcp_handler, args=(interrupt, ))
udp_thread = Thread(target=udp_handler, args=(interrupt, ))
client_collector_thread.start()
tcp_thread.start()
udp_thread.start()
input("Press enter to stop program...")
interrupt.set()
client_collector_thread.join()
tcp_thread.join()
udp_thread.join()
And here is: websocket_server.py
import socket
def tunnel_connect(clientsock, clientaddr, dst_addr, dst_port):
tunsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
tunsock.bind(("10.1.12.255", 0))
try:
print(f"Connecting {(dst_addr, int(dst_port))}")
tunsock.connect((dst_addr, int(dst_port)))
except Exception as e:
print(f'connection closed earlier when connecting {(dst_addr, int(dst_port))}:', e)
clientsock.close()
tunsock.close()
del clientsock
del tunsock
return
while 1:
req = clientsock.recv(4096)
if not req:
print('connection closed from client')
break
succeed = tunsock.send(req)
if succeed != len(req):
print('failed on forwarding request from client to server')
break
res = tunsock.recv(4096)
if not res:
print('connection closed from server')
break
succeed = clientsock.send(res)
if succeed != len(res):
print('failed on forwarding response from server to client')
break
# print("tunsock thread closed!")
tunsock.close()
clientsock.close()
del clientsock
del tunsock
def handle_client(client_socket, client_addr):
from threading import Thread
try:
# Receive data from the client
request = client_socket.recv(4096)
if not request:
print('Failed to connect!')
client_socket.close()
return
if b'x3JJHMbDL1EzLkh9GBhXDw==' in request:
req_str = request.decode('utf-8')
param = 'Tunnel: '
start_index = req_str.find(param)
stop_index = req_str.find("\r\n", start_index+len(param))
tunnel_val = req_str[start_index:stop_index].strip()
proto, dst_addr, dst_port = tunnel_val.split('|')
client_socket.send(b"HTTP/1.1 101 Switching Protocols\r\n" \
b"Upgrade: websocket\r\n" \
b"Connection: Upgrade\r\n" \
b"Sec-WebSocket-Accept: HSmrc0sMlYUkAGmm5OPpG2HaGWk=\r\n\r\n")
else:
print('Invalid ws key.')
client_socket.close()
return
except:
return
Thread(target=tunnel_connect, args=(client_socket, client_addr, dst_addr, dst_port,)).start()
# while 1:
# request = client_socket.recv(4096)
# if not request:
# break
# client_socket.send(b'ECHO:'+request)
# client_socket.send('|'.join([proto, dst_addr, dst_port]).encode())
# # Close the client socket
# print('Connection closed:', client_addr)
# client_socket.close()
def main():
from threading import Thread
# Create a socket object
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# Allow address reuse
server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
# Bind to localhost and port 3333
server_socket.bind(('127.0.0.1', 3333))
# Listen for incoming connections
server_socket.listen(5)
print("Listening on port 3333...")
while True:
# Accept connections from client
client_socket, addr = server_socket.accept()
print("Accepted connection from", addr)
Thread(target=handle_client, args=(client_socket, addr, )).start()
if __name__ == "__main__":
main()
Here is sample of websocket_server.py output:
Listening on port 3333...
Accepted connection from ('127.0.0.1', 34544)
Accepted connection from ('127.0.0.1', 34548)
Connecting ('api.anythinktech.com', 443)
Connecting ('report.apkpure.net', 443)
Accepted connection from ('127.0.0.1', 34550)
Connecting ('net.mtgglobals.com', 443)
Accepted connection from ('127.0.0.1', 34554)
Connecting ('mqtt-mini.facebook.com', 443)
Accepted connection from ('127.0.0.1', 34564)
Connecting ('googleads.g.doubleclick.net', 443)
Accepted connection from ('127.0.0.1', 34574)
Connecting ('www.gstatic.com', 443)
Accepted connection from ('127.0.0.1', 34578)
Connecting ('www.google.com', 443)
Accepted connection from ('127.0.0.1', 34590)
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 34602)
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 34610)
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 34618)
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 34622)
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 34636)
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 34638)
Connecting ('optimizationguide-pa.googleapis.com', 443)
Accepted connection from ('127.0.0.1', 34646)
Connecting ('analytics-tcp.mintegral.net', 9377)
Accepted connection from ('127.0.0.1', 34652)
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 34666)
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 34674)
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 34676)
Connecting ('www.google.com', 443)
Accepted connection from ('127.0.0.1', 59558)
Connecting ('svibeacon.onezapp.com', 443)
Accepted connection from ('127.0.0.1', 59560)
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 59572)
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 59584)
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 59590)
Connecting ('api.myadsget.com', 80)
Accepted connection from ('127.0.0.1', 59606)
Connecting ('svibeacon.onezapp.com', 443)
Accepted connection from ('127.0.0.1', 59610)
Connecting ('googleads.g.doubleclick.net', 443)
Accepted connection from ('127.0.0.1', 59620)
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 59626)
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 59628)
Connecting ('dns.google', 443)
connection closed from client
Accepted connection from ('127.0.0.1', 59638)
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 59650)
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 59656)
Connecting ('dns.google', 443)
connection closed from server
Accepted connection from ('127.0.0.1', 41930)
Connecting ('report.apkpure.net', 443)
Accepted connection from ('127.0.0.1', 41938)
Connecting ('svibeacon.onezapp.com', 443)
Accepted connection from ('127.0.0.1', 41944)
Connecting ('report.apkpure.net', 443)
Accepted connection from ('127.0.0.1', 41948)
Connecting ('www.google.com', 443)
Accepted connection from ('127.0.0.1', 41962)
Connecting ('www.google.com', 443)
Accepted connection from ('127.0.0.1', 41966)
Connecting ('www.google.com', 443)
Accepted connection from ('127.0.0.1', 41982)
Connecting ('www.google.com', 443)
Accepted connection from ('127.0.0.1', 41998)
Connecting ('net.mtgglobals.com', 443)
Accepted connection from ('127.0.0.1', 53190)
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 53194)
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 53204)
Connecting ('dns.google', 443)
connection closed from client
connection closed from client
connection closed from client
connection closed from client
connection closed from client
connection closed from client
connection closed from client
connection closed from client
connection closed from client
connection closed from client
connection closed from client
connection closed from client
connection closed from client
connection closed from client
connection closed from client
connection closed from client
connection closed from client
connection closed from client
connection closed from client
connection closed from client
connection closed from client
connection closed from client
connection closed from client
connection closed from client
connection closed from client
connection closed from client
connection closed from client
connection closed from client
connection closed from client
connection closed from client
connection closed from client
connection closed from client
connection closed from client
connection closed from client
connection closed from client
connection closed from client
connection closed from client
connection closed from client
connection closed from client
Accepted connection from ('127.0.0.1', 38670)
Connecting ('dns.google', 443)
connection closed from client
Accepted connection from ('127.0.0.1', 38672)
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 38684)
Accepted connection from ('127.0.0.1', 38690)
Connecting ('beacons.gcp.gvt2.com', 443)
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 38692)
Connecting ('dns.google', 443)
connection closed from client
connection closed from client
connection closed from client
connection closed from client
Accepted connection from ('127.0.0.1', 38700)
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 38712)
Connecting ('dns.google', 443)
connection closed from client
connection closed from client
Accepted connection from ('127.0.0.1', 38728)
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 38742)
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 38746)
Connecting ('discover-pa.googleapis.com', 443)
connection closed from client
connection closed from client
connection closed from client
connection closed from server
Accepted connection from ('127.0.0.1', 38762)
Connecting ('dns.google', 443)
connection closed from client
connection closed from client
Accepted connection from ('127.0.0.1', 38772)
Accepted connection from ('127.0.0.1', 38774)
Connecting ('googleads.g.doubleclick.net', 443)
Connecting ('clients4.google.com', 443)
connection closed from client
connection closed from client
Accepted connection from ('127.0.0.1', 38790)
Connecting ('googleads.g.doubleclick.net', 443)
connection closed from client
Accepted connection from ('127.0.0.1', 38800)
Connecting ('clientservices.googleapis.com', 443)
Accepted connection from ('127.0.0.1', 38808)
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 38812)
Accepted connection from ('127.0.0.1', 52922)
Connecting ('beacons.gvt2.com', 443)
Accepted connection from ('127.0.0.1', 52926)
Connecting ('svibeacon.onezapp.com', 443)
Accepted connection from ('127.0.0.1', 52508)
Connecting ('exp5.www.linkedin.com', 443)
Accepted connection from ('127.0.0.1', 52514)
Connecting ('74.125.130.94', 443)
Accepted connection from ('127.0.0.1', 52526)
Connecting ('exp5.www.linkedin.com', 443)
connection closed from client
connection closed from client
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 38228)
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 38232)
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 38242)
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 38254)
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 38260)
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 38276)
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 38288)
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 38304)
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 38312)
Connecting ('www.google.com', 443)
Accepted connection from ('127.0.0.1', 38316)
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 38320)
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 38330)
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 38342)
Connecting ('android.apis.google.com', 443)
Accepted connection from ('127.0.0.1', 38350)
Connecting ('optimizationguide-pa.googleapis.com', 443)
connection closed from client
Accepted connection from ('127.0.0.1', 52456)
Connecting ('www.google.com', 443)
Accepted connection from ('127.0.0.1', 52460)
Connecting ('27.112.79.120', 80)
connection closed earlier when connecting ('27.112.79.120', 80): [Errno 111] Connection refused
Accepted connection from ('127.0.0.1', 52468)
Connecting ('27.112.79.120', 80)
connection closed earlier when connecting ('27.112.79.120', 80): [Errno 111] Connection refused
Accepted connection from ('127.0.0.1', 52470)
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 52478)
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 52482)
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 52484)
Connecting ('27.112.79.120', 80)
connection closed earlier when connecting ('27.112.79.120', 80): [Errno 111] Connection refused
Accepted connection from ('127.0.0.1', 52496)
Connecting ('api.anythinktech.com', 443)
Accepted connection from ('127.0.0.1', 52510)
Connecting ('api.myadsget.com', 80)
Accepted connection from ('127.0.0.1', 52518)
Connecting ('svibeacon.onezapp.com', 443)
Accepted connection from ('127.0.0.1', 52528)
Connecting ('net.mtgglobals.com', 443)
Accepted connection from ('127.0.0.1', 52540)
Connecting ('configure-tcp-android.mtgglobals.com', 9377)
Accepted connection from ('127.0.0.1', 52550)
Connecting ('clients4.google.com', 443)
connection closed from client
Accepted connection from ('127.0.0.1', 52566)
Connecting ('27.112.79.120', 80)
connection closed earlier when connecting ('27.112.79.120', 80): [Errno 111] Connection refused
Accepted connection from ('127.0.0.1', 52582)
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 52596)
Connecting ('27.112.79.120', 80)
connection closed earlier when connecting ('27.112.79.120', 80): [Errno 111] Connection refused
Accepted connection from ('127.0.0.1', 52610)
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 52618)
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 52622)
Connecting ('27.112.79.120', 80)
connection closed earlier when connecting ('27.112.79.120', 80): [Errno 111] Connection refused
Accepted connection from ('127.0.0.1', 36018)
Connecting ('27.112.79.120', 80)
connection closed earlier when connecting ('27.112.79.120', 80): [Errno 111] Connection refused
Accepted connection from ('127.0.0.1', 36034)
Connecting ('27.112.79.120', 80)
connection closed earlier when connecting ('27.112.79.120', 80): [Errno 111] Connection refused
Accepted connection from ('127.0.0.1', 36050)
Connecting ('27.112.79.120', 80)
connection closed earlier when connecting ('27.112.79.120', 80): [Errno 111] Connection refused
Accepted connection from ('127.0.0.1', 36054)
Connecting ('27.112.79.120', 80)
connection closed earlier when connecting ('27.112.79.120', 80): [Errno 111] Connection refused
Accepted connection from ('127.0.0.1', 36064)
Connecting ('report.apkpure.net', 443)
Accepted connection from ('127.0.0.1', 36074)
Connecting ('27.112.79.120', 80)
Accepted connection from ('127.0.0.1', 36078)
Connecting ('27.112.79.120', 80)
connection closed earlier when connecting ('27.112.79.120', 80): [Errno 111] Connection refused
connection closed earlier when connecting ('27.112.79.120', 80): [Errno 111] Connection refused
Accepted connection from ('127.0.0.1', 36092)
Connecting ('27.112.79.120', 80)
connection closed earlier when connecting ('27.112.79.120', 80): [Errno 111] Connection refused
connection closed from client
Accepted connection from ('127.0.0.1', 58704)
Connecting ('accounts.google.com', 443)
connection closed from client
connection closed from client
connection closed from client
connection closed from client
connection closed from client
connection closed from client
Accepted connection from ('127.0.0.1', 58710)
Connecting ('www.google.com', 443)
Accepted connection from ('127.0.0.1', 58714)
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 58722)
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 58736)
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 58750)
Connecting ('dns.google', 443)
Accepted connection from ('127.0.0.1', 58760)
Connecting ('dns.google', 443)
connection closed from client
Accepted connection from ('127.0.0.1', 58768)
Connecting ('dns.google', 443)
connection closed from client
connection closed from client
Accepted connection from ('127.0.0.1', 58770)
Connecting ('www.google.com', 443)
connection closed from client
Accepted connection from ('127.0.0.1', 58776)
Connecting ('27.112.79.120', 80)
connection closed earlier when connecting ('27.112.79.120', 80): [Errno 111] Connection refused
Accepted connection from ('127.0.0.1', 58786)
Connecting ('www.google.com', 443)
connection closed from client
Accepted connection from ('127.0.0.1', 58798)
Connecting ('twitter.com', 443)
connection closed from client
Accepted connection from ('127.0.0.1', 58812)
Connecting ('www.google.com', 443)
Accepted connection from ('127.0.0.1', 58826)
Connecting ('27.112.79.120', 80)
connection closed earlier when connecting ('27.112.79.120', 80): [Errno 111] Connection refused
connection closed from client
connection closed from client
connection closed from client
Accepted connection from ('127.0.0.1', 58836)
Connecting ('abs.twimg.com', 443)
Accepted connection from ('127.0.0.1', 58846)
connection closed from client
connection closed from client
connection closed from client
connection closed from client
connection closed from client
connection closed from client
connection closed from client
connection closed from client
connection closed from client
connection closed from client
^CTraceback (most recent call last):
File "/home/isysrg/Koding/wstun/wsserver.py", line 114, in <module>
main()
File "/home/isysrg/Koding/wstun/wsserver.py", line 108, in main
client_socket, addr = server_socket.accept()
File "/usr/lib/python3.10/socket.py", line 293, in accept
fd, addr = self._accept()
KeyboardInterrupt
^CException ignored in: <module 'threading' from '/usr/lib/python3.10/threading.py'>
Traceback (most recent call last):
File "/usr/lib/python3.10/threading.py", line 1567, in _shutdown
lock.acquire()
KeyboardInterrupt:
Actually, it's worked, I tried to connect my client to socks5 server through socks5 client VPN app. But it's only worked on example.com ip which is 93.184.216.34 returning response 404 Not Found that can be considered as successful connection. The other rest accessing another address on internet such as google.com is just stuck on indefinitely loading.