|
|
@ -3,11 +3,16 @@ |
|
|
|
import socket |
|
|
|
import socks |
|
|
|
|
|
|
|
|
|
|
|
SERVER_IP = '127.0.0.1' |
|
|
|
SERVER_PORT = 1081 |
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
|
# Test 1: same source port IPv4 |
|
|
|
sock_out = socks.socksocket(socket.AF_INET, socket.SOCK_DGRAM, |
|
|
|
socket.SOL_UDP) |
|
|
|
sock_out.set_proxy(socks.SOCKS5, '127.0.0.1', 1081) |
|
|
|
sock_out.set_proxy(socks.SOCKS5, SERVER_IP, SERVER_PORT) |
|
|
|
sock_out.bind(('127.0.0.1', 9000)) |
|
|
|
|
|
|
|
sock_in1 = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, |
|
|
@ -35,7 +40,7 @@ if __name__ == '__main__': |
|
|
|
# try again from the same port but IPv6 |
|
|
|
sock_out = socks.socksocket(socket.AF_INET, socket.SOCK_DGRAM, |
|
|
|
socket.SOL_UDP) |
|
|
|
sock_out.set_proxy(socks.SOCKS5, '127.0.0.1', 1081) |
|
|
|
sock_out.set_proxy(socks.SOCKS5, SERVER_IP, SERVER_PORT) |
|
|
|
sock_out.bind(('127.0.0.1', 9000)) |
|
|
|
|
|
|
|
sock_in1 = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM, |
|
|
@ -62,7 +67,7 @@ if __name__ == '__main__': |
|
|
|
# Test 3: different source ports IPv6 |
|
|
|
sock_out = socks.socksocket(socket.AF_INET, socket.SOCK_DGRAM, |
|
|
|
socket.SOL_UDP) |
|
|
|
sock_out.set_proxy(socks.SOCKS5, '127.0.0.1', 1081) |
|
|
|
sock_out.set_proxy(socks.SOCKS5, SERVER_IP, SERVER_PORT) |
|
|
|
sock_out.bind(('127.0.0.1', 9003)) |
|
|
|
|
|
|
|
sock_in1 = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM, |
|
|
|