py-multiaddr
multiaddr implementation in Python
Usage
Simple
from multiaddr import Multiaddr
# construct from a string
m1 = Multiaddr("/ip4/127.0.0.1/udp/1234")
# construct from bytes
m2 = Multiaddr(bytes_addr=m1.to_bytes())
assert str(m1) == "/ip4/127.0.0.1/udp/1234"
assert str(m1) == str(m2)
assert m1.to_bytes() == m2.to_bytes()
assert m1 == m2
assert m2 == m1
assert not (m1 != m2)
assert not (m2 != m1)
Protocols
from multiaddr import Multiaddr
m1 = Multiaddr("/ip4/127.0.0.1/udp/1234")
# get the multiaddr protocol description objects
m1.protocols()
# [Protocol(code=4, name='ip4', size=32), Protocol(code=17, name='udp', size=16)]
En/decapsulate
from multiaddr import Multiaddr
m1 = Multiaddr("/ip4/127.0.0.1/udp/1234")
m1.encapsulate(Multiaddr("/sctp/5678"))
# <Multiaddr /ip4/127.0.0.1/udp/1234/sctp/5678>
m1.decapsulate(Multiaddr("/udp"))
# <Multiaddr /ip4/127.0.0.1>
Tunneling
Multiaddr allows expressing tunnels very nicely.
printer = Multiaddr("/ip4/192.168.0.13/tcp/80")
proxy = Multiaddr("/ip4/10.20.30.40/tcp/443")
printerOverProxy = proxy.encapsulate(printer)
print(printerOverProxy)
# /ip4/10.20.30.40/tcp/443/ip4/192.168.0.13/tcp/80
proxyAgain = printerOverProxy.decapsulate(printer)
print(proxyAgain)
# /ip4/10.20.30.40/tcp/443
Maintainers
Original author: @sbuss.
Contribute
Contributions welcome. Please check out the issues.
Check out our contributing document for more information on how we work, and about contributing in general. Please be aware that all interactions related to multiformats are subject to the IPFS Code of Conduct.
License
Dual-licensed:
History
0.0.10 (2022-9-9)
forked and applied dependency cleanup to support more recent projects
0.0.7 (2019-5-8)
include subpackage
refactor util and codec
0.0.5 (2019-5-7)
unhexilified bytes
new exceptions
miscellaneous improvements [via alexander255 #42]
0.0.2 (2016-5-4)
Fix a bug in decapsulate that threw an IndexError instead of a copy of the Multiaddr when the original multiaddr does not contain the multiaddr to decapsulate. [via fredthomsen #9]
Increase test coverage [via fredthomsen #9]
0.0.1 (2016-1-22)
First release on PyPI.
Metadata
Release files for planetmint-multiaddr 0.0.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| planetmint-multiaddr-0.0.10.tar.gz | 28.2 kB | Without provenance | Details |
Release files / planetmint-multiaddr-0.0.10.tar.gz
| Download URL | planetmint-multiaddr-0.0.10.tar.gz |
|---|---|
| Size | 28.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f6daf70931c3f73acfcb0c7c08f3e00721a8d70946d37687ba1b5e1f1f6ef129
|
|
BLAKE2b-256 checksum How to use checksums |
bd1291410826587e20375717befa917cb07c65df84b82d4ce516698f99880f79
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Security for planetmint-multiaddr 0.0.10
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.