mirror of
https://github.com/tun2proxy/tun2proxy.git
synced 2025-04-23 07:19:08 +00:00
Add manual tests for half open connections
This commit is contained in:
parent
2cf7c9cdea
commit
70cea8e11f
5 changed files with 55 additions and 1 deletions
|
@ -114,7 +114,6 @@ or through `ip -6 route del default`, which causes the `libc` resolver (and othe
|
|||
requests for IPv6 addresses.
|
||||
|
||||
## TODO
|
||||
- Improve handling of half-open connections
|
||||
- Increase error robustness (reduce `unwrap` and `expect` usage)
|
||||
- UDP support for SOCKS
|
||||
- Native support for proxying DNS over TCP or TLS
|
||||
|
|
12
tests/manual-tests/half-open-close-client/client.py
Normal file
12
tests/manual-tests/half-open-close-client/client.py
Normal file
|
@ -0,0 +1,12 @@
|
|||
import socket
|
||||
import time
|
||||
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
||||
s.connect(('116.203.215.166', 1337))
|
||||
s.sendall('I am closing the write end, but I can still receive data'.encode())
|
||||
s.shutdown(socket.SHUT_WR)
|
||||
while True:
|
||||
data = s.recv(1024)
|
||||
if not data:
|
||||
break
|
||||
print(data.decode())
|
16
tests/manual-tests/half-open-close-client/server.py
Normal file
16
tests/manual-tests/half-open-close-client/server.py
Normal file
|
@ -0,0 +1,16 @@
|
|||
import socket
|
||||
import time
|
||||
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
||||
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
s.bind(('0.0.0.0', 1337))
|
||||
s.listen()
|
||||
conn, addr = s.accept()
|
||||
with conn:
|
||||
while True:
|
||||
data = conn.recv(1024)
|
||||
if not data:
|
||||
break
|
||||
print(data.decode())
|
||||
time.sleep(3)
|
||||
conn.sendall('This will still be received by the client that has closed its write end'.encode())
|
12
tests/manual-tests/half-open-close-server/client.py
Normal file
12
tests/manual-tests/half-open-close-server/client.py
Normal file
|
@ -0,0 +1,12 @@
|
|||
import socket
|
||||
import time
|
||||
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
||||
s.connect(('116.203.215.166', 1337))
|
||||
while True:
|
||||
data = s.recv(1024)
|
||||
if not data:
|
||||
break
|
||||
print(data.decode())
|
||||
time.sleep(3)
|
||||
s.sendall('Message after server write end close'.encode())
|
15
tests/manual-tests/half-open-close-server/server.py
Normal file
15
tests/manual-tests/half-open-close-server/server.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
import socket
|
||||
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
||||
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
s.bind(('0.0.0.0', 1337))
|
||||
s.listen()
|
||||
conn, addr = s.accept()
|
||||
with conn:
|
||||
conn.sendall('I am closing the write end, but I can still receive data'.encode())
|
||||
conn.shutdown(socket.SHUT_WR)
|
||||
while True:
|
||||
data = conn.recv(1024)
|
||||
if not data:
|
||||
break
|
||||
print(data.decode())
|
Loading…
Add table
Reference in a new issue