Skip to content

Commit 4507543

Browse files
committed
Added webrtc-direct and webrtc
- Added the protocols in the registry in protcols.py - Added the maddr test cases in test_multiaddr.py
1 parent fb35e85 commit 4507543

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

multiaddr/protocols.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@
7979
P_SNI = 0x01C1
8080
P_NOISE = 0x01C6
8181
P_WEBTRANSPORT = 0x01D1
82+
P_WEBRTC_DIRECT = 0x118
83+
P_WEBRTC = 0X119
8284
P_MEMORY = 0x309
8385

8486

@@ -172,6 +174,8 @@ def __repr__(self) -> str:
172174
Protocol(P_P2P_CIRCUIT, "p2p-circuit", None),
173175
Protocol(P_WEBTRANSPORT, "webtransport", None),
174176
Protocol(P_UNIX, "unix", "fspath"),
177+
Protocol(P_WEBRTC_DIRECT, "webrtc-direct", None),
178+
Protocol(P_WEBRTC, "webrtc", None),
175179
Protocol(P_MEMORY, "memory", "memory"),
176180
]
177181

tests/test_multiaddr.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,13 @@ def test_invalid(addr_str):
109109
"/dns/example.com",
110110
"/dns4/موقع.وزارة-الاتصالات.مصر",
111111
"/ip4/127.0.0.1/tcp/443/tls/sni/example.com/http/http-path/foo",
112+
"/memory/4",
113+
"/http-path/tmp%2Fbar",
114+
"/http-path/tmp%2Fbar%2Fbaz",
115+
"/http-path/foo",
116+
"/ip4/127.0.0.1/tcp/9090/http/p2p-webrtc-direct",
117+
"/ip4/127.0.0.1/tcp/127/webrtc-direct",
118+
"/ip4/127.0.0.1/tcp/127/webrtc",
112119
],
113120
) # nopep8
114121
def test_valid(addr_str):

tests/test_thin_waist_addresses.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,6 @@ def test_specific_address_override_port():
2121
addrs = get_thin_waist_addresses(input_addr, 100)
2222
assert addrs == [Multiaddr("/ip4/123.123.123.123/tcp/100")]
2323

24-
25-
def test_ignore_non_thin_waist():
26-
# Should raise StringParseError for unknown protocol (e.g. /webrtc)
27-
with pytest.raises(StringParseError):
28-
Multiaddr("/ip4/123.123.123.123/udp/1234/webrtc")
29-
30-
3124
def test_ipv4_wildcard():
3225
input_addr = Multiaddr("/ip4/0.0.0.0/tcp/1234")
3326
addrs = get_thin_waist_addresses(input_addr)

0 commit comments

Comments
 (0)