Browse Source

some test programs to see if a socks server can handle UDP

neither SSH (immediate close) NOR tor (bad command) handle UDP
main
John-Mark Gurney 5 years ago
parent
commit
51bd6055a7
1 changed files with 49 additions and 0 deletions
  1. +49
    -0
      tests/test_datagram.py

+ 49
- 0
tests/test_datagram.py View File

@@ -0,0 +1,49 @@
import aiosocks
import asyncio
from tests.test_functional import with_timeout

machip = '192.168.0.29'
socksport = 2345
targport = 20834

@with_timeout(2)
async def xtest_live_datagram():
loop = asyncio.get_event_loop()
addr = aiosocks.Socks5Addr('127.0.0.1', socksport)

dst = (machip, targport)
dgram = await aiosocks.open_datagram(addr, None, dst, loop=loop)

dgram.send('this is a test\r\n')

import socket

def xtest_simpletcp():
s = socket.socket()
s.connect(('127.0.0.1', socksport))

s.send(b'\x05\x01\x00')
assert s.recv(2) == b'\x05\x00'

s.send(b'\x05\x01\x00\x01' + socket.inet_pton(socket.AF_INET, machip) + (targport).to_bytes(2, 'big'))

assert s.recv(4) == b'\x05\x00\x00\x01'
print(socket.inet_ntop(socket.AF_INET, s.recv(4)), ':', int.from_bytes(s.recv(2), 'big'))

s.send(b'foobar\r\n')

def xtest_simpleudp():
s = socket.socket()
s.connect(('127.0.0.1', socksport))

s.send(b'\x05\x01\x00')
assert s.recv(2) == b'\x05\x00'

s.send(b'\x05\x03\x00\x01' + socket.inet_pton(socket.AF_INET, machip) + (53).to_bytes(2, 'big'))
print('a')

assert s.recv(4) == b'\x05\x00\x00\x01'
print('a')
print(socket.inet_ntop(socket.AF_INET, s.recv(4)), ':', int.from_bytes(s.recv(2), 'big'))
print('a')
assert False

Loading…
Cancel
Save