multiaddr package

Submodules

multiaddr.codec module

multiaddr.codec.address_bytes_to_string(proto, buf)[source]
multiaddr.codec.address_string_to_bytes(proto, addr_string)[source]
multiaddr.codec.bytes_split(buf)[source]
multiaddr.codec.bytes_to_string(buf)[source]
multiaddr.codec.size_for_addr(proto, buf)[source]
multiaddr.codec.string_to_bytes(string)[source]

multiaddr.multiaddr module

class multiaddr.multiaddr.Multiaddr(string_addr=None, bytes_addr=None)[source]

Bases: object

Multiaddr is a representation of multiple nested internet addresses.

Multiaddr is a cross-protocol, cross-platform format for representing internet addresses. It emphasizes explicitness and self-description.

Learn more here: https://github.com/jbenet/multiaddr

Multiaddrs have both a binary and string representation.

>>> from multiaddr import Multiaddr
>>> addr = Multiaddr("/ip4/1.2.3.4/tcp/80")

Multiaddr objects are immutable, so encapsulate and decapsulate return new objects rather than modify internal state.

decapsulate(other)[source]

Remove a Multiaddr wrapping.

For example:
/ip4/1.2.3.4/tcp/80 decapsulate /ip4/1.2.3.4 = /tcp/80
encapsulate(other)[source]

Wrap this Multiaddr around another.

For example:
/ip4/1.2.3.4 encapsulate /tcp/80 = /ip4/1.2.3.4/tcp/80
protocols()[source]

Returns a list of Protocols this Multiaddr includes.

to_bytes()[source]

Returns the byte array representation of this Multiaddr.

value_for_protocol(code)[source]

Return the value (if any) following the specified protocol.

exception multiaddr.multiaddr.ProtocolNotFoundException[source]

Bases: exceptions.Exception

multiaddr.protocols module

class multiaddr.protocols.Protocol(code, size, name, vcode)[source]

Bases: object

code
name
size
vcode
multiaddr.protocols.add_protocol(proto)[source]
multiaddr.protocols.code_to_varint(num)[source]

Convert an integer to a varint-encoded byte.

multiaddr.protocols.protocol_with_code(code)[source]
multiaddr.protocols.protocol_with_name(name)[source]
multiaddr.protocols.protocols_with_string(string)[source]

Return a list of protocols matching given string.

multiaddr.protocols.read_varint_code(buf)[source]
multiaddr.protocols.varint_to_code(buf)[source]

multiaddr.util module

multiaddr.util.decode_big_endian_16(b)[source]
multiaddr.util.decode_big_endian_32(b)[source]

Take big-endian bytes and return int

multiaddr.util.encode_big_endian_16(i)[source]

Take an int and return big-endian bytes

multiaddr.util.encode_big_endian_32(i)[source]

Take an int and return big-endian bytes

multiaddr.util.int_to_hex(i, size)[source]

Encode a long value as a hex string, 0-padding to size.

Note that size is the size of the resulting hex string. So, for a 32Byte int, size should be 64 (two hex characters per byte”.

multiaddr.util.join(multiaddrs)[source]
multiaddr.util.split(ma)[source]

Return the sub-address portions of a multiaddr

Module contents