multiaddr


Namemultiaddr JSON
Version 0.0.9 PyPI version JSON
download
home_pagehttps://github.com/multiformats/py-multiaddr
SummaryPython implementation of jbenet's multiaddr
upload_time2019-12-23 07:06:21
maintainer
docs_urlhttps://pythonhosted.org/multiaddr/
authorSteven Buss
requires_python>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*
licenseMIT License
keywords multiaddr
VCS
bugtrack_url
requirements varint base58 netaddr idna py-cid py-multicodec
Travis-CI
coveralls test coverage
            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"))
    # <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.


.. 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/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:

-  `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


History
=======

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`_]

.. _alexander255: https://github.com/alexander255
.. _`#42`: https://github.com/multiformats/py-multiaddr/pull/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`_]

.. _fredthomsen: https://github.com/fredthomsen
.. _`#9`: https://github.com/multiformats/py-multiaddr/pull/9

0.0.1 (2016-1-22)
------------------

* First release on PyPI.



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/multiformats/py-multiaddr",
    "name": "multiaddr",
    "maintainer": "",
    "docs_url": "https://pythonhosted.org/multiaddr/",
    "requires_python": ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*",
    "maintainer_email": "",
    "keywords": "multiaddr",
    "author": "Steven Buss",
    "author_email": "steven.buss@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/12/f4/fa5353022ad8e0fd364bfa8b474f9562c36ce1305fad31fe52b849e30795/multiaddr-0.0.9.tar.gz",
    "platform": "",
    "description": "py-multiaddr\n==========================\n\n.. image:: https://img.shields.io/pypi/v/multiaddr.svg\n        :target: https://pypi.python.org/pypi/multiaddr\n\n.. image:: https://api.travis-ci.com/multiformats/py-multiaddr.svg?branch=master\n        :target: https://travis-ci.com/multiformats/py-multiaddr\n\n.. image:: https://codecov.io/github/multiformats/py-multiaddr/coverage.svg?branch=master\n        :target: https://codecov.io/github/multiformats/py-multiaddr?branch=master\n\n.. image:: https://readthedocs.org/projects/multiaddr/badge/?version=latest\n        :target: https://readthedocs.org/projects/multiaddr/?badge=latest\n        :alt: Documentation Status\n..\n\n    multiaddr_ implementation in Python\n\n.. _multiaddr: https://github.com/multiformats/multiaddr\n\n..\n\n\n.. contents:: :local:\n\nUsage\n=====\n\nSimple\n------\n\n.. code-block:: python\n\n    from multiaddr import Multiaddr\n\n    # construct from a string\n    m1 = Multiaddr(\"/ip4/127.0.0.1/udp/1234\")\n\n    # construct from bytes\n    m2 = Multiaddr(bytes_addr=m1.to_bytes())\n\n    assert str(m1) == \"/ip4/127.0.0.1/udp/1234\"\n    assert str(m1) == str(m2)\n    assert m1.to_bytes() == m2.to_bytes()\n    assert m1 == m2\n    assert m2 == m1\n    assert not (m1 != m2)\n    assert not (m2 != m1)\n\n\nProtocols\n---------\n\n.. code-block:: python\n\n    from multiaddr import Multiaddr\n\n    m1 = Multiaddr(\"/ip4/127.0.0.1/udp/1234\")\n\n    # get the multiaddr protocol description objects\n    m1.protocols()\n    # [Protocol(code=4, name='ip4', size=32), Protocol(code=17, name='udp', size=16)]\n\n\nEn/decapsulate\n--------------\n\n.. code-block:: python\n\n    from multiaddr import Multiaddr\n\n    m1 = Multiaddr(\"/ip4/127.0.0.1/udp/1234\")\n    m1.encapsulate(Multiaddr(\"/sctp/5678\"))\n    # <Multiaddr /ip4/127.0.0.1/udp/1234/sctp/5678>\n    m1.decapsulate(Multiaddr(\"/udp\"))\n    # <Multiaddr /ip4/127.0.0.1>\n\n\nTunneling\n---------\n\nMultiaddr allows expressing tunnels very nicely.\n\n\n.. code-block:: python\n\n    printer = Multiaddr(\"/ip4/192.168.0.13/tcp/80\")\n    proxy = Multiaddr(\"/ip4/10.20.30.40/tcp/443\")\n    printerOverProxy = proxy.encapsulate(printer)\n    print(printerOverProxy)\n    # /ip4/10.20.30.40/tcp/443/ip4/192.168.0.13/tcp/80\n\n    proxyAgain = printerOverProxy.decapsulate(printer)\n    print(proxyAgain)\n    # /ip4/10.20.30.40/tcp/443\n\nMaintainers\n===========\n\nOriginal author: `@sbuss`_.\n\nContribute\n==========\n\nContributions welcome. Please check out `the issues`_.\n\nCheck out our `contributing document`_ for more information on how we work, and about contributing in general.\nPlease be aware that all interactions related to multiformats are subject to the IPFS `Code of Conduct`_.\n\nLicense\n=======\n\nDual-licensed:\n\n-  `MIT`_ \u00a9 2014 Steven Buss\n-  `Apache 2`_ \u00a9 2014 Steven Buss\n\n.. _the issues: https://github.com/multiformats/py-multiaddr/issues\n.. _contributing document: https://github.com/multiformats/multiformats/blob/master/contributing.md\n.. _Code of Conduct: https://github.com/ipfs/community/blob/master/code-of-conduct.md\n.. _standard-readme: https://github.com/RichardLitt/standard-readme\n.. _MIT: LICENSE-MIT\n.. _Apache 2: LICENSE-APACHE2\n.. _`@sbuss`: https://github.com/sbuss\n\n\nHistory\n=======\n\n0.0.7 (2019-5-8)\n----------------\n\n* include subpackage\n* refactor util and codec\n\n0.0.5 (2019-5-7)\n----------------\n\n* unhexilified bytes\n* new exceptions\n* miscellaneous improvements [via alexander255_ `#42`_]\n\n.. _alexander255: https://github.com/alexander255\n.. _`#42`: https://github.com/multiformats/py-multiaddr/pull/42\n\n0.0.2 (2016-5-4)\n----------------\n\n* Fix a bug in decapsulate that threw an IndexError instead of a copy of the\n  Multiaddr when the original multiaddr does not contain the multiaddr to\n  decapsulate. [via fredthomsen_ `#9`_]\n* Increase test coverage [via fredthomsen_ `#9`_]\n\n.. _fredthomsen: https://github.com/fredthomsen\n.. _`#9`: https://github.com/multiformats/py-multiaddr/pull/9\n\n0.0.1 (2016-1-22)\n------------------\n\n* First release on PyPI.\n\n\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "Python implementation of jbenet's multiaddr",
    "version": "0.0.9",
    "split_keywords": [
        "multiaddr"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "78003181e10fcc4fc03b1e54426e7d54",
                "sha256": "5c0f862cbcf19aada2a899f80ef896ddb2e85614e0c8f04dd287c06c69dac95b"
            },
            "downloads": -1,
            "filename": "multiaddr-0.0.9-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "78003181e10fcc4fc03b1e54426e7d54",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*",
            "size": 16281,
            "upload_time": "2019-12-23T07:06:18",
            "upload_time_iso_8601": "2019-12-23T07:06:18.915132Z",
            "url": "https://files.pythonhosted.org/packages/51/59/df732566d951c33f00a4022fc5bf9c5d1661b1c2cdaf56e75a1a5fa8f829/multiaddr-0.0.9-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "d5bb4acecd28cba4a52221fe0a7146b9",
                "sha256": "30b2695189edc3d5b90f1c303abb8f02d963a3a4edf2e7178b975eb417ab0ecf"
            },
            "downloads": -1,
            "filename": "multiaddr-0.0.9.tar.gz",
            "has_sig": false,
            "md5_digest": "d5bb4acecd28cba4a52221fe0a7146b9",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*",
            "size": 24726,
            "upload_time": "2019-12-23T07:06:21",
            "upload_time_iso_8601": "2019-12-23T07:06:21.146073Z",
            "url": "https://files.pythonhosted.org/packages/12/f4/fa5353022ad8e0fd364bfa8b474f9562c36ce1305fad31fe52b849e30795/multiaddr-0.0.9.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2019-12-23 07:06:21",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "multiformats",
    "github_project": "py-multiaddr",
    "travis_ci": true,
    "coveralls": true,
    "github_actions": false,
    "requirements": [
        {
            "name": "varint",
            "specs": []
        },
        {
            "name": "base58",
            "specs": []
        },
        {
            "name": "netaddr",
            "specs": []
        },
        {
            "name": "idna",
            "specs": []
        },
        {
            "name": "py-cid",
            "specs": []
        },
        {
            "name": "py-multicodec",
            "specs": [
                [
                    ">=",
                    "0.2.0"
                ]
            ]
        }
    ],
    "tox": true,
    "lcname": "multiaddr"
}
        
Elapsed time: 0.01974s