Add `uds` to `._multiaddr`, tweak typing
parent
d704f99223
commit
fcc253f6ce
|
|
@ -38,6 +38,7 @@ prots: bidict[int, str] = {
|
||||||
|
|
||||||
'tcp': 4,
|
'tcp': 4,
|
||||||
'udp': 4,
|
'udp': 4,
|
||||||
|
'uds': 4,
|
||||||
|
|
||||||
# TODO: support the next-gen shite Bo
|
# TODO: support the next-gen shite Bo
|
||||||
# 'quic': 4,
|
# 'quic': 4,
|
||||||
|
|
@ -51,6 +52,7 @@ prot_params: dict[str, tuple[str]] = {
|
||||||
|
|
||||||
'tcp': ('port',),
|
'tcp': ('port',),
|
||||||
'udp': ('port',),
|
'udp': ('port',),
|
||||||
|
'uds': ('path',),
|
||||||
|
|
||||||
# 'quic': ('port',),
|
# 'quic': ('port',),
|
||||||
# 'ssh': ('port',),
|
# 'ssh': ('port',),
|
||||||
|
|
@ -98,7 +100,10 @@ def iter_prot_layers(
|
||||||
|
|
||||||
def parse_maddr(
|
def parse_maddr(
|
||||||
multiaddr: str,
|
multiaddr: str,
|
||||||
) -> dict[str, str | int | dict]:
|
) -> dict[
|
||||||
|
str,
|
||||||
|
str|int|dict,
|
||||||
|
]:
|
||||||
'''
|
'''
|
||||||
Parse a libp2p style "multiaddress" into its distinct protocol
|
Parse a libp2p style "multiaddress" into its distinct protocol
|
||||||
segments where each segment is of the form:
|
segments where each segment is of the form:
|
||||||
|
|
@ -129,7 +134,10 @@ def parse_maddr(
|
||||||
) in iter_prot_layers(multiaddr):
|
) in iter_prot_layers(multiaddr):
|
||||||
|
|
||||||
layer: int = prots[prot_key] # OSI layer used for sorting
|
layer: int = prots[prot_key] # OSI layer used for sorting
|
||||||
ep: dict[str, int | str] = {'layer': layer}
|
ep: dict[str, int|str] = {
|
||||||
|
'layer': layer,
|
||||||
|
'proto': prot_key,
|
||||||
|
}
|
||||||
layers[prot_key] = ep
|
layers[prot_key] = ep
|
||||||
|
|
||||||
# TODO; validation and resolving of names:
|
# TODO; validation and resolving of names:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue