-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path__init__.py
More file actions
85 lines (74 loc) · 1.62 KB
/
__init__.py
File metadata and controls
85 lines (74 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
"""
hyperdht -- Python bindings for hyperdht-cpp via ctypes.
Usage::
from hyperdht import HyperDHT, KeyPair
kp = KeyPair.generate()
print(f"Public key: {kp.public_key.hex()}")
dht = HyperDHT(use_public_bootstrap=True)
dht.bind()
print(f"Listening on port {dht.port}")
# Server
server = dht.create_server()
server.listen(kp, lambda conn: print(f"Connected: {conn}"))
# Client
dht.connect(remote_pk, lambda err, conn: print("OK" if not err else err))
dht.run()
dht.destroy()
Requires: libhyperdht.so and libuv.so
"""
from hyperdht._bindings import (
Address,
Connection,
HyperDHT,
KeyPair,
PendingStream,
PunchStats,
Query,
RelayStats,
Stream,
)
from hyperdht._ffi import (
ERR_CANCELLED,
ERR_CONNECTION_FAILED,
ERR_DESTROYED,
ERR_HOLEPUNCH_FAILED,
ERR_HOLEPUNCH_TIMEOUT,
ERR_NO_ADDRESSES,
ERR_OK,
ERR_PEER_NOT_FOUND,
ERR_RELAY_FAILED,
FIREWALL_CONSISTENT,
FIREWALL_OPEN,
FIREWALL_RANDOM,
FIREWALL_UNKNOWN,
)
from hyperdht._server import Server
__all__ = [
# Classes
"HyperDHT",
"KeyPair",
"Server",
"Connection",
"Stream",
"PendingStream",
"Query",
"PunchStats",
"RelayStats",
"Address",
# Firewall constants
"FIREWALL_UNKNOWN",
"FIREWALL_OPEN",
"FIREWALL_CONSISTENT",
"FIREWALL_RANDOM",
# Error codes
"ERR_OK",
"ERR_DESTROYED",
"ERR_PEER_NOT_FOUND",
"ERR_CONNECTION_FAILED",
"ERR_NO_ADDRESSES",
"ERR_HOLEPUNCH_FAILED",
"ERR_HOLEPUNCH_TIMEOUT",
"ERR_RELAY_FAILED",
"ERR_CANCELLED",
]
__version__ = "0.1.0"