Esempio n. 1
0
 def server():
     io = SansIORW(encoding="utf-8")
     version, one, auth_method = yield from io.read_struct("BBB")
     assert version == 5
     assert one == 1
     assert auth_method == 2
     yield from io.write_struct("BB", 5, 2)
     auth_version = yield from io.read_struct("B")
     assert auth_version == 1
     username = yield from io.read_pascal_string()
     password = yield from io.read_pascal_string()
     assert username == "yoba"
     assert password == "foo"
     yield from io.write_struct("BB", 0, 0)
     yield from io.passthrough()
Esempio n. 2
0
 def server():
     io = SansIORW(encoding="utf-8")
     version, one, auth_method = yield from io.read_struct("BBB")
     assert version == 5
     assert one == 1
     assert auth_method == 0
     yield from io.write_struct("BB", 5, 1)
     yield from io.passthrough()
Esempio n. 3
0
 def client():
     io = SansIORW(encoding="utf-8")
     yield from io.write_struct("BBH4s", 4, 1, 123, b"\x7f\x00\x00\x01")
     yield from io.write_c_string("yoba")
     prefix, code, port, ipv4 = yield from io.read_struct("BBH4s")
     assert prefix == 0
     assert code == 0x5a
     assert port == 0
     assert ipv4 == b"\x00" * 4
     yield from io.passthrough()
Esempio n. 4
0
 def client():
     io = SansIORW(encoding="utf-8")
     yield from io.write_struct("BBH4s", 4, 1, 123, b"\x7f\x00\x00\x01")
     yield from io.write_c_string("yoba")
     prefix, code, port, ipv4 = yield from io.read_struct("BBH4s")
     assert prefix == 0
     assert code == 0x5b
     assert port == 0
     assert ipv4 == b"\x00" * 4
     raise RuntimeError("connection failed")
Esempio n. 5
0
 def server():
     io = SansIORW(encoding="utf-8")
     version, command, port, ipv4 = yield from io.read_struct("BBH4s")
     assert version == 4
     assert command == 1
     assert port == 123
     assert ipv4 == b"\x7f\x00\x00\x01"
     user_id = yield from io.read_c_string()
     assert user_id == "yoba"
     yield from io.connect(ipv4, port)
     yield from io.write_struct("BBH4s", 0, 0x5a, 666, b"\x00" * 4)
     yield from io.passthrough()
Esempio n. 6
0
 def server():
     io = SansIORW(encoding="utf-8")
     version, command, port, ipv4 = yield from io.read_struct("BBH4s")
     assert version == 4
     assert command == 1
     assert port == 123
     assert ipv4 == b"\x00\x00\x00\xff"
     user_id = yield from io.read_c_string()
     assert user_id == ""
     host = yield from io.read_c_string()
     assert host == "python.org"
     yield from io.connect(host, port)
     yield from io.write_struct("BBH4s", 0, 0x5a, 0, b"\x00" * 4)
     yield from io.passthrough()
Esempio n. 7
0
 def client():
     io = SansIORW(encoding="utf-8")
     yield from io.write_struct("B", 5)
     yield from io.write_struct("B", 0)
     yield from io.passthrough()
Esempio n. 8
0
 def client():
     io = SansIORW(encoding="utf-8")
     yield from io.write_struct("BBH4s", 4, 2, 123, b"\x7f\x00\x00\x01")
     yield from io.write_c_string("yoba")
     yield from io.passthrough()