|
12 | 12 | P_UDP = 17 |
13 | 13 | P_DCCP = 33 |
14 | 14 | P_IP6 = 41 |
| 15 | +P_IP6ZONE = 42 # rfc4007 IPv6 zone |
| 16 | +P_DNS = 53 # reserved |
| 17 | +P_DNS4 = 54 |
| 18 | +P_DNS6 = 55 |
| 19 | +P_DNSADDR = 56 |
15 | 20 | P_SCTP = 132 |
16 | | -P_UTP = 301 |
17 | | -P_UDT = 302 |
18 | | -P_IPFS = 421 |
| 21 | +P_UDT = 301 |
| 22 | +P_UTP = 302 |
| 23 | +P_UNIX = 400 |
| 24 | +P_P2P = 421 # preferred over /ipfs |
| 25 | +P_IPFS = 421 # backwards compatibility; equivalent to /p2p |
| 26 | +P_ONION = 444 |
| 27 | +P_QUIC = 460 |
19 | 28 | P_HTTP = 480 |
20 | 29 | P_HTTPS = 443 |
21 | | -P_ONION = 444 |
| 30 | +P_WS = 477 |
| 31 | +P_WSS = 478 |
| 32 | +P_P2P_WEBSOCKET_STAR = 479 |
| 33 | +P_P2P_WEBRTC_STAR = 275 |
| 34 | +P_P2P_WEBRTC_DIRECT = 276 |
| 35 | +P_P2P_CIRCUIT = 290 |
22 | 36 |
|
23 | 37 | _CODES = [ |
24 | 38 | P_IP4, |
25 | 39 | P_TCP, |
26 | 40 | P_UDP, |
27 | 41 | P_DCCP, |
28 | 42 | P_IP6, |
| 43 | + P_IP6ZONE, |
| 44 | + P_DNS, |
| 45 | + P_DNS4, |
| 46 | + P_DNS6, |
| 47 | + P_DNSADDR, |
29 | 48 | P_SCTP, |
30 | | - P_UTP, |
31 | 49 | P_UDT, |
| 50 | + P_UTP, |
| 51 | + P_UNIX, |
| 52 | + P_P2P, |
32 | 53 | P_IPFS, |
| 54 | + P_ONION, |
| 55 | + P_QUIC, |
33 | 56 | P_HTTP, |
34 | 57 | P_HTTPS, |
35 | | - P_ONION, |
| 58 | + P_WS, |
| 59 | + P_WSS, |
| 60 | + P_P2P_WEBSOCKET_STAR, |
| 61 | + P_P2P_WEBRTC_STAR, |
| 62 | + P_P2P_WEBRTC_DIRECT, |
| 63 | + P_P2P_CIRCUIT, |
36 | 64 | ] |
37 | 65 |
|
38 | 66 |
|
@@ -70,18 +98,18 @@ def __init__(self, code, size, name, vcode): |
70 | 98 |
|
71 | 99 | def __eq__(self, other): |
72 | 100 | return all((self.code == other.code, |
73 | | - self.size == other.size, |
74 | | - self.name == other.name, |
75 | | - self.vcode == other.vcode)) |
| 101 | + self.size == other.size, |
| 102 | + self.name == other.name, |
| 103 | + self.vcode == other.vcode)) |
76 | 104 |
|
77 | 105 | def __ne__(self, other): |
78 | 106 | return not (self == other) |
79 | 107 |
|
80 | 108 | def __repr__(self): |
81 | 109 | return "Protocol(code={code}, name='{name}', size={size})".format( |
82 | | - code=self.code, |
83 | | - size=self.size, |
84 | | - name=self.name) |
| 110 | + code=self.code, |
| 111 | + size=self.size, |
| 112 | + name=self.name) |
85 | 113 |
|
86 | 114 |
|
87 | 115 | def code_to_varint(num): |
@@ -118,21 +146,32 @@ def read_varint_code(buf): |
118 | 146 |
|
119 | 147 | # Protocols is the list of multiaddr protocols supported by this module. |
120 | 148 | PROTOCOLS = [ |
121 | | - Protocol(P_IP4, 32, "ip4", code_to_varint(P_IP4)), |
122 | | - Protocol(P_TCP, 16, "tcp", code_to_varint(P_TCP)), |
123 | | - Protocol(P_UDP, 16, "udp", code_to_varint(P_UDP)), |
124 | | - Protocol(P_DCCP, 16, "dccp", code_to_varint(P_DCCP)), |
125 | | - Protocol(P_IP6, 128, "ip6", code_to_varint(P_IP6)), |
126 | | - # these require varint: |
127 | | - Protocol(P_SCTP, 16, "sctp", code_to_varint(P_SCTP)), |
128 | | - # Bug in spec? Onion addresses actually need to be 96 bits to account for |
129 | | - # the port number. |
130 | | - Protocol(P_ONION, 96, "onion", code_to_varint(P_ONION)), |
131 | | - Protocol(P_UTP, 0, "utp", code_to_varint(P_UTP)), |
132 | | - Protocol(P_UDT, 0, "udt", code_to_varint(P_UDT)), |
133 | | - Protocol(P_HTTP, 0, "http", code_to_varint(P_HTTP)), |
134 | | - Protocol(P_HTTPS, 0, "https", code_to_varint(P_HTTPS)), |
135 | | - Protocol(P_IPFS, LENGTH_PREFIXED_VAR_SIZE, "ipfs", code_to_varint(P_IPFS)), |
| 149 | + Protocol(P_IP4, 32, 'ip4', code_to_varint(P_IP4)), |
| 150 | + Protocol(P_TCP, 16, 'tcp', code_to_varint(P_TCP)), |
| 151 | + Protocol(P_UDP, 16, 'udp', code_to_varint(P_UDP)), |
| 152 | + Protocol(P_DCCP, 16, 'dccp', code_to_varint(P_DCCP)), |
| 153 | + Protocol(P_IP6, 128, 'ip6', code_to_varint(P_IP6)), |
| 154 | + Protocol(P_IP6ZONE, LENGTH_PREFIXED_VAR_SIZE, 'ip6zone', code_to_varint(P_IP6ZONE)), |
| 155 | + Protocol(P_DNS, LENGTH_PREFIXED_VAR_SIZE, 'dns', code_to_varint(P_DNS)), |
| 156 | + Protocol(P_DNS4, LENGTH_PREFIXED_VAR_SIZE, 'dns4', code_to_varint(P_DNS4)), |
| 157 | + Protocol(P_DNS6, LENGTH_PREFIXED_VAR_SIZE, 'dns6', code_to_varint(P_DNS6)), |
| 158 | + Protocol(P_DNSADDR, LENGTH_PREFIXED_VAR_SIZE, 'dnsaddr', code_to_varint(P_DNSADDR)), |
| 159 | + Protocol(P_SCTP, 16, 'sctp', code_to_varint(P_SCTP)), |
| 160 | + Protocol(P_UDT, 0, 'udt', code_to_varint(P_UDT)), |
| 161 | + Protocol(P_UTP, 0, 'utp', code_to_varint(P_UTP)), |
| 162 | + Protocol(P_UNIX, LENGTH_PREFIXED_VAR_SIZE, 'unix', code_to_varint(P_UNIX)), |
| 163 | + Protocol(P_P2P, LENGTH_PREFIXED_VAR_SIZE, 'p2p', code_to_varint(P_P2P)), |
| 164 | + Protocol(P_IPFS, LENGTH_PREFIXED_VAR_SIZE, 'ipfs', code_to_varint(P_IPFS)), |
| 165 | + Protocol(P_ONION, 96, 'onion', code_to_varint(P_ONION)), |
| 166 | + Protocol(P_QUIC, 0, 'quic', code_to_varint(P_QUIC)), |
| 167 | + Protocol(P_HTTP, 0, 'http', code_to_varint(P_HTTP)), |
| 168 | + Protocol(P_HTTPS, 0, 'https', code_to_varint(P_HTTPS)), |
| 169 | + Protocol(P_WS, 0, 'ws', code_to_varint(P_WS)), |
| 170 | + Protocol(P_WSS, 0, 'wss', code_to_varint(P_WSS)), |
| 171 | + Protocol(P_P2P_WEBSOCKET_STAR, 0, 'p2p-websocket-star', code_to_varint(P_P2P_WEBSOCKET_STAR)), |
| 172 | + Protocol(P_P2P_WEBRTC_STAR, 0, 'p2p-webrtc-star', code_to_varint(P_P2P_WEBRTC_STAR)), |
| 173 | + Protocol(P_P2P_WEBRTC_DIRECT, 0, 'p2p-webrtc-direct', code_to_varint(P_P2P_WEBRTC_DIRECT)), |
| 174 | + Protocol(P_P2P_CIRCUIT, 0, 'p2p-circuit', code_to_varint(P_P2P_CIRCUIT)), |
136 | 175 | ] |
137 | 176 |
|
138 | 177 | _names_to_protocols = dict((proto.name, proto) for proto in PROTOCOLS) |
|
0 commit comments