Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/multiformats/py-multiaddr
multiaddr implementation in Python
https://github.com/multiformats/py-multiaddr
ipfs libp2p multiformats network python
Last synced: about 2 months ago
JSON representation
multiaddr implementation in Python
- Host: GitHub
- URL: https://github.com/multiformats/py-multiaddr
- Owner: multiformats
- License: other
- Archived: true
- Created: 2016-03-04T21:58:00.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-05-09T09:14:52.000Z (over 1 year ago)
- Last Synced: 2024-09-25T23:24:05.880Z (about 2 months ago)
- Topics: ipfs, libp2p, multiformats, network, python
- Language: Python
- Homepage: https://multiformats.io/
- Size: 196 KB
- Stars: 33
- Watchers: 12
- Forks: 23
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- Changelog: HISTORY.rst
- Contributing: CONTRIBUTING.rst
- License: LICENSE-APACHE2
- Authors: AUTHORS
Awesome Lists containing this project
README
**This project is no longer maintained and has been archived.**
py-multiaddr
==========================.. image:: https://img.shields.io/pypi/v/multiaddr.svg
:target: https://pypi.python.org/pypi/multiaddr.. image:: https://api.travis-ci.com/multiformats/py-multiaddr.svg?branch=master
:target: https://travis-ci.com/multiformats/py-multiaddr.. image:: https://codecov.io/github/multiformats/py-multiaddr/coverage.svg?branch=master
:target: https://codecov.io/github/multiformats/py-multiaddr?branch=master.. image:: https://readthedocs.org/projects/multiaddr/badge/?version=latest
:target: https://readthedocs.org/projects/multiaddr/?badge=latest
:alt: Documentation Status
..multiaddr_ implementation in Python
.. _multiaddr: https://github.com/multiformats/multiaddr
..
.. contents:: :local:
Usage
=====Simple
------.. code-block:: python
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
---------.. code-block:: python
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
--------------.. code-block:: python
from multiaddr import Multiaddr
m1 = Multiaddr("/ip4/127.0.0.1/udp/1234")
m1.encapsulate(Multiaddr("/sctp/5678"))
#
m1.decapsulate(Multiaddr("/udp"))
#Tunneling
---------Multiaddr allows expressing tunnels very nicely.
.. code-block:: python
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/80proxyAgain = printerOverProxy.decapsulate(printer)
print(proxyAgain)
# /ip4/10.20.30.40/tcp/443Maintainers
===========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:
- `MIT`_ © 2014 Steven Buss
- `Apache 2`_ © 2014 Steven Buss.. _the issues: https://github.com/multiformats/py-multiaddr/issues
.. _contributing document: https://github.com/multiformats/multiformats/blob/master/contributing.md
.. _Code of Conduct: https://github.com/ipfs/community/blob/master/code-of-conduct.md
.. _standard-readme: https://github.com/RichardLitt/standard-readme
.. _MIT: LICENSE-MIT
.. _Apache 2: LICENSE-APACHE2
.. _`@sbuss`: https://github.com/sbuss