Asyncio-based SOCKS5 server that tunnels connections through configurable chains of SOCKS5, SOCKS4/4a, and HTTP CONNECT proxies. Tor integration via standard SOCKS5 hop.
23 lines
635 B
Python
23 lines
635 B
Python
"""Tests for protocol helpers."""
|
|
|
|
from s5p.proto import Socks5AddrType, encode_address
|
|
|
|
|
|
class TestEncodeAddress:
|
|
"""Test SOCKS5 address encoding."""
|
|
|
|
def test_ipv4(self):
|
|
atyp, data = encode_address("127.0.0.1")
|
|
assert atyp == Socks5AddrType.IPV4
|
|
assert data == b"\x7f\x00\x00\x01"
|
|
|
|
def test_ipv6(self):
|
|
atyp, data = encode_address("::1")
|
|
assert atyp == Socks5AddrType.IPV6
|
|
assert len(data) == 16
|
|
|
|
def test_domain(self):
|
|
atyp, data = encode_address("example.com")
|
|
assert atyp == Socks5AddrType.DOMAIN
|
|
assert data == bytes([11]) + b"example.com"
|