Rename to `parse_maddr()` and fill out doc strings
parent
de89e3a9c4
commit
86da79a854
tractor
|
@ -96,21 +96,30 @@ def iter_prot_layers(
|
||||||
yield prot, params
|
yield prot, params
|
||||||
|
|
||||||
|
|
||||||
def parse_addr(
|
def parse_maddr(
|
||||||
multiaddr: str,
|
multiaddr: str,
|
||||||
) -> dict[str, str | int | dict]:
|
) -> dict[str, str | int | dict]:
|
||||||
'''
|
'''
|
||||||
Parse a libp2p style "multiaddress" into it's distinct protocol
|
Parse a libp2p style "multiaddress" into it's distinct protocol
|
||||||
segments where each segment:
|
segments where each segment is of the form:
|
||||||
|
|
||||||
`../<protocol>/<param0>/<param1>/../<paramN>`
|
`../<protocol>/<param0>/<param1>/../<paramN>`
|
||||||
|
|
||||||
is loaded into a layers `dict[str, dict[str, Any]` which holds
|
and is loaded into a (order preserving) `layers: dict[str,
|
||||||
each prot segment of the path as a separate entry sortable by
|
dict[str, Any]` which holds each protocol-layer-segment of the
|
||||||
it's approx OSI "layer number".
|
original `str` path as a separate entry according to its approx
|
||||||
|
OSI "layer number".
|
||||||
|
|
||||||
Any `paramN` in the path must be distinctly defined in order
|
Any `paramN` in the path must be distinctly defined by a str-token in the
|
||||||
according to the (global) `prot_params` table in this module.
|
(module global) `prot_params` table.
|
||||||
|
|
||||||
|
For eg. for wireguard which requires an address, port number and publickey
|
||||||
|
the protocol params are specified as the entry:
|
||||||
|
|
||||||
|
'wg': ('addr', 'port', 'pubkey'),
|
||||||
|
|
||||||
|
and are thus parsed from a maddr in that order:
|
||||||
|
`'/wg/1.1.1.1/51820/<pubkey>'`
|
||||||
|
|
||||||
'''
|
'''
|
||||||
layers: dict[str, str | int | dict] = {}
|
layers: dict[str, str | int | dict] = {}
|
||||||
|
|
Loading…
Reference in New Issue