Пример #1
0
 def server():
     io = SansIORW(encoding="utf-8")
     version, one, auth_method = yield from io.read_struct("BBB")
     assert (version, one, auth_method) == (5, 1, 0)
     yield from io.write_struct("BB", 5, 0)
     version, command, zero, address_type = yield from io.read_struct("4B")
     assert (version, command, zero, address_type) == (5, 1, 0, 4)
     ipv6, port = yield from io.read_struct("16sH")
     assert (ipv6, port) == ((b"\x00" * 15) + b"\x01", 666)
     yield from io.write_struct("4B", 5, 0, 0, 1)
     yield from io.write(b"\x00" * 4)
     yield from io.write_struct("H", 0)
     yield from io.passthrough()
Пример #2
0
 def server():
     io = SansIORW(encoding="utf-8")
     version, one, auth_method = yield from io.read_struct("BBB")
     assert (version, one, auth_method) == (5, 1, 0)
     yield from io.write_struct("BB", 5, 0)
     version, command, zero, address_type = yield from io.read_struct("4B")
     assert (version, command, zero, address_type) == (5, 1, 0, 3)
     domain = yield from io.read_pascal_string()
     port = yield from io.read_struct("H")
     assert (domain, port) == ("python.org", 666)
     yield from io.write_struct("4B", 5, 0, 0, 1)
     yield from io.write(b"\x00" * 4)
     yield from io.write_struct("H", 0)
     yield from io.passthrough()
Пример #3
0
 def client():
     io = SansIORW(encoding="utf-8")
     yield from io.write(b"\x06")
     yield from io.passthrough()