multiaddr 0.0.11__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,351 @@
1
+ Metadata-Version: 2.4
2
+ Name: multiaddr
3
+ Version: 0.0.11
4
+ Summary: Python implementation of jbenet's multiaddr
5
+ Author-email: Steven Buss <steven.buss@gmail.com>
6
+ Maintainer: acul71
7
+ Maintainer-email: pacrob <pacrob@protonmail.com>, Manu Sheel Gupta <manu@seeta.in>
8
+ License: MIT License
9
+ Project-URL: Homepage, https://github.com/multiformats/py-multiaddr
10
+ Project-URL: Download, https://github.com/multiformats/py-multiaddr/tarball/0.0.11
11
+ Keywords: multiaddr
12
+ Classifier: Development Status :: 2 - Pre-Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Natural Language :: English
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Requires-Python: <4.0,>=3.10
22
+ Description-Content-Type: text/x-rst
23
+ License-File: LICENSE-APACHE2
24
+ License-File: LICENSE-MIT
25
+ License-File: AUTHORS
26
+ Requires-Dist: base58
27
+ Requires-Dist: dnspython>=2.7.0
28
+ Requires-Dist: idna
29
+ Requires-Dist: netaddr
30
+ Requires-Dist: psutil
31
+ Requires-Dist: py-cid>=0.3.1
32
+ Requires-Dist: py-multicodec>=0.2.0
33
+ Requires-Dist: trio-typing>=0.0.4
34
+ Requires-Dist: trio>=0.26.0
35
+ Requires-Dist: varint
36
+ Provides-Extra: dev
37
+ Requires-Dist: Sphinx>=5.0.0; extra == "dev"
38
+ Requires-Dist: build>=0.9.0; extra == "dev"
39
+ Requires-Dist: bump_my_version>=1.2.0; extra == "dev"
40
+ Requires-Dist: coverage>=6.5.0; extra == "dev"
41
+ Requires-Dist: mypy; extra == "dev"
42
+ Requires-Dist: pre-commit; extra == "dev"
43
+ Requires-Dist: pyrefly; extra == "dev"
44
+ Requires-Dist: pyright; extra == "dev"
45
+ Requires-Dist: pytest; extra == "dev"
46
+ Requires-Dist: pytest-cov; extra == "dev"
47
+ Requires-Dist: pytest-runner; extra == "dev"
48
+ Requires-Dist: pytest-trio>=0.5.2; extra == "dev"
49
+ Requires-Dist: ruff; extra == "dev"
50
+ Requires-Dist: towncrier<25,>=24; extra == "dev"
51
+ Requires-Dist: tox>=4.10.0; extra == "dev"
52
+ Requires-Dist: twine; extra == "dev"
53
+ Requires-Dist: types-netaddr; extra == "dev"
54
+ Requires-Dist: types-psutil; extra == "dev"
55
+ Requires-Dist: watchdog>=3.0.0; extra == "dev"
56
+ Requires-Dist: wheel>=0.31.0; extra == "dev"
57
+ Dynamic: license-file
58
+
59
+ py-multiaddr
60
+ ==========================
61
+
62
+ .. image:: https://img.shields.io/pypi/v/multiaddr.svg
63
+ :target: https://pypi.python.org/pypi/multiaddr
64
+
65
+ .. image:: https://github.com/multiformats/py-multiaddr/actions/workflows/ci.yml/badge.svg
66
+ :target: https://github.com/multiformats/py-multiaddr/actions
67
+
68
+ .. image:: https://codecov.io/github/multiformats/py-multiaddr/coverage.svg?branch=master
69
+ :target: https://codecov.io/github/multiformats/py-multiaddr?branch=master
70
+
71
+ .. image:: https://readthedocs.org/projects/multiaddr/badge/?version=latest
72
+ :target: https://readthedocs.org/projects/multiaddr/?badge=latest
73
+ :alt: Documentation Status
74
+ ..
75
+
76
+ multiaddr_ implementation in Python
77
+
78
+ .. _multiaddr: https://github.com/multiformats/multiaddr
79
+
80
+ ..
81
+
82
+
83
+ .. contents:: :local:
84
+
85
+ Installation
86
+ ============
87
+
88
+ .. code-block:: bash
89
+
90
+ pip install multiaddr
91
+
92
+ Requirements
93
+ ------------
94
+
95
+ - Python 3.10+
96
+ - trio (for async DNS resolution)
97
+
98
+ Usage
99
+ =====
100
+
101
+ Simple
102
+ ------
103
+
104
+ .. code-block:: python
105
+
106
+ from multiaddr import Multiaddr
107
+
108
+ # construct from a string
109
+ m1 = Multiaddr("/ip4/127.0.0.1/udp/1234")
110
+
111
+ # construct from bytes
112
+ #m2 = Multiaddr(bytes_addr=m1.to_bytes()) # deprecated
113
+ m2 = Multiaddr(m1.to_bytes())
114
+
115
+ assert str(m1) == "/ip4/127.0.0.1/udp/1234"
116
+ assert str(m1) == str(m2)
117
+ assert m1.to_bytes() == m2.to_bytes()
118
+ assert m1 == m2
119
+ assert m2 == m1
120
+ assert not (m1 != m2)
121
+ assert not (m2 != m1)
122
+
123
+
124
+ Protocols
125
+ ---------
126
+
127
+ .. code-block:: python
128
+
129
+ from multiaddr import Multiaddr
130
+
131
+ m1 = Multiaddr("/ip4/127.0.0.1/udp/1234")
132
+
133
+ # get the multiaddr protocol description objects
134
+ m1.protocols()
135
+ # [Protocol(code=4, name='ip4', size=32), Protocol(code=17, name='udp', size=16)]
136
+
137
+
138
+ En/decapsulate
139
+ --------------
140
+
141
+ .. code-block:: python
142
+
143
+ from multiaddr import Multiaddr
144
+
145
+ m1 = Multiaddr("/ip4/127.0.0.1/udp/1234")
146
+ m1.encapsulate(Multiaddr("/sctp/5678"))
147
+ # <Multiaddr /ip4/127.0.0.1/udp/1234/sctp/5678>
148
+ m1.decapsulate(Multiaddr("/udp"))
149
+ # <Multiaddr /ip4/127.0.0.1>
150
+
151
+ # Decapsulate by protocol code
152
+ m2 = Multiaddr("/ip4/192.168.1.1/tcp/8080/udp/1234")
153
+ m2.decapsulate_code(6) # TCP protocol code
154
+ # <Multiaddr /ip4/192.168.1.1>
155
+
156
+ # Decapsulate multiple layers
157
+ m3 = Multiaddr("/ip4/10.0.0.1/tcp/443/tls/p2p/QmPeer")
158
+ m3.decapsulate_code(6) # Remove TCP and everything after
159
+ # <Multiaddr /ip4/10.0.0.1>
160
+
161
+
162
+ Tunneling
163
+ ---------
164
+
165
+ Multiaddr allows expressing tunnels very nicely.
166
+
167
+
168
+ .. code-block:: python
169
+
170
+ printer = Multiaddr("/ip4/192.168.0.13/tcp/80")
171
+ proxy = Multiaddr("/ip4/10.20.30.40/tcp/443")
172
+ printerOverProxy = proxy.encapsulate(printer)
173
+ print(printerOverProxy)
174
+ # /ip4/10.20.30.40/tcp/443/ip4/192.168.0.13/tcp/80
175
+
176
+ proxyAgain = printerOverProxy.decapsulate(printer)
177
+ print(proxyAgain)
178
+ # /ip4/10.20.30.40/tcp/443
179
+
180
+ DNS Resolution
181
+ --------------
182
+
183
+ Multiaddr supports DNS-based address resolution using the DNSADDR protocol. This is particularly useful for resolving bootstrap node addresses and maintaining peer IDs during resolution.
184
+
185
+
186
+ .. code-block:: python
187
+
188
+ from multiaddr import Multiaddr
189
+ import trio
190
+
191
+ # Basic DNS resolution
192
+ ma = Multiaddr("/dns/example.com")
193
+ resolved = await ma.resolve()
194
+ print(resolved)
195
+ # [Multiaddr("/ip4/93.184.216.34"), Multiaddr("/ip6/2606:2800:220:1:248:1893:25c8:1946")]
196
+
197
+ # DNSADDR with peer ID (bootstrap node style)
198
+ ma_with_peer = Multiaddr("/dnsaddr/bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN")
199
+ resolved_with_peer = await ma_with_peer.resolve()
200
+ print(resolved_with_peer)
201
+ # [Multiaddr("/ip4/147.75.83.83/tcp/4001/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN")]
202
+
203
+ # DNS4 and DNS6 resolution (IPv4/IPv6 specific)
204
+ ma_dns4 = Multiaddr("/dns4/example.com/tcp/443")
205
+ resolved_dns4 = await ma_dns4.resolve()
206
+ print(resolved_dns4)
207
+ # [Multiaddr("/ip4/93.184.216.34/tcp/443")]
208
+
209
+ ma_dns6 = Multiaddr("/dns6/example.com/tcp/443")
210
+ resolved_dns6 = await ma_dns6.resolve()
211
+ print(resolved_dns6)
212
+ # [Multiaddr("/ip6/2606:2800:220:1:248:1893:25c8:1946/tcp/443")]
213
+
214
+ # Using the DNS resolver directly
215
+ from multiaddr.resolvers import DNSResolver
216
+ resolver = DNSResolver()
217
+ resolved = await resolver.resolve(ma)
218
+ print(resolved)
219
+ # [Multiaddr("/ip4/93.184.216.34"), Multiaddr("/ip6/2606:2800:220:1:248:1893:25c8:1946")]
220
+
221
+ # Peer ID preservation test
222
+ original_peer_id = ma_with_peer.get_peer_id()
223
+ print(f"Original peer ID: {original_peer_id}")
224
+ # Original peer ID: QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN
225
+
226
+ for resolved_addr in resolved_with_peer:
227
+ preserved_peer_id = resolved_addr.get_peer_id()
228
+ print(f"Resolved peer ID: {preserved_peer_id}")
229
+ # Resolved peer ID: QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN
230
+
231
+ For comprehensive examples including bootstrap node resolution, protocol comparison, and py-libp2p integration, see the `DNS examples <https://github.com/multiformats/py-multiaddr/tree/master/examples/dns>`_ in the examples directory.
232
+
233
+ Thin Waist Address Validation
234
+ -----------------------------
235
+
236
+ Multiaddr provides thin waist address validation functionality to process multiaddrs and expand wildcard addresses to all available network interfaces. This is particularly useful for server configuration, network discovery, and dynamic port management.
237
+
238
+
239
+ .. code-block:: python
240
+
241
+ from multiaddr import Multiaddr
242
+ from multiaddr.utils import get_thin_waist_addresses, get_network_addrs
243
+
244
+ # Network interface discovery
245
+ ipv4_addrs = get_network_addrs(4)
246
+ print(f"Available IPv4 addresses: {ipv4_addrs}")
247
+ # Available IPv4 addresses: ['192.168.1.12', '10.152.168.99']
248
+
249
+ # Specific address (no expansion)
250
+ addr = Multiaddr("/ip4/192.168.1.100/tcp/8080")
251
+ result = get_thin_waist_addresses(addr)
252
+ print(result)
253
+ # [<Multiaddr /ip4/192.168.1.100/tcp/8080>]
254
+
255
+ # IPv4 wildcard expansion
256
+ addr = Multiaddr("/ip4/0.0.0.0/tcp/8080")
257
+ result = get_thin_waist_addresses(addr)
258
+ print(result)
259
+ # [<Multiaddr /ip4/192.168.1.12/tcp/8080>, <Multiaddr /ip4/10.152.168.99/tcp/8080>]
260
+
261
+ # IPv6 wildcard expansion
262
+ addr = Multiaddr("/ip6/::/tcp/8080")
263
+ result = get_thin_waist_addresses(addr)
264
+ print(result)
265
+ # [<Multiaddr /ip6/::1/tcp/8080>, <Multiaddr /ip6/fd9b:9eba:8224:1:41a1:8939:231a:b414/tcp/8080>]
266
+
267
+ # Port override
268
+ addr = Multiaddr("/ip4/0.0.0.0/tcp/8080")
269
+ result = get_thin_waist_addresses(addr, port=9000)
270
+ print(result)
271
+ # [<Multiaddr /ip4/192.168.1.12/tcp/9000>, <Multiaddr /ip4/10.152.168.99/tcp/9000>]
272
+
273
+ # UDP transport support
274
+ addr = Multiaddr("/ip4/0.0.0.0/udp/1234")
275
+ result = get_thin_waist_addresses(addr)
276
+ print(result)
277
+ # [<Multiaddr /ip4/192.168.1.12/udp/1234>, <Multiaddr /ip4/10.152.168.99/udp/1234>]
278
+
279
+ # Server binding scenario
280
+ wildcard = Multiaddr("/ip4/0.0.0.0/tcp/8080")
281
+ interfaces = get_thin_waist_addresses(wildcard)
282
+ print("Available interfaces for server binding:")
283
+ for i, interface in enumerate(interfaces, 1):
284
+ print(f" {i}. {interface}")
285
+ # Available interfaces for server binding:
286
+ # 1. /ip4/192.168.1.12/tcp/8080
287
+ # 2. /ip4/10.152.168.99/tcp/8080
288
+
289
+ For comprehensive examples including error handling, practical usage scenarios, and detailed network interface information, see the `thin waist examples <https://github.com/multiformats/py-multiaddr/tree/master/examples/thin_waist>`_ in the examples directory.
290
+
291
+ Features
292
+ ========
293
+
294
+ - **Multiaddr Protocol Support**: Full support for the multiaddr specification
295
+ - **DNS Resolution**: Async DNS and DNSADDR resolution with trio
296
+ - **Thin Waist Validation**: Network interface discovery and wildcard expansion
297
+ - **Protocol Support**: IPv4, IPv6, TCP, UDP, DNS, DNS4, DNS6, DNSADDR, p2p, p2p-circuit, onion, onion3, quic, tls, and more
298
+ - **Type Safety**: Full type hints and mypy support
299
+ - **Modern Python**: Python 3.10+ support with modern tooling
300
+
301
+ Maintainers
302
+ ===========
303
+
304
+ Original author: `@sbuss`_.
305
+
306
+ Current maintainers: `@acul71`_, `@pacrob`_, `@manusheel`_.
307
+
308
+ Contribute
309
+ ==========
310
+
311
+ Contributions welcome. Please check out `the issues`_.
312
+
313
+ Check out our `contributing document`_ for more information on how we work, and about contributing in general.
314
+ Please be aware that all interactions related to multiformats are subject to the IPFS `Code of Conduct`_.
315
+
316
+ Development
317
+ -----------
318
+
319
+ For development setup, see `py-multiaddr contributing`_.
320
+
321
+ .. code-block:: bash
322
+
323
+ # Clone the repository
324
+ git clone https://github.com/multiformats/py-multiaddr.git
325
+ cd py-multiaddr
326
+
327
+ # Install in development mode
328
+ pip install -e ".[dev]"
329
+
330
+ # Run the development workflow
331
+ make pr
332
+
333
+ License
334
+ =======
335
+
336
+ Dual-licensed:
337
+
338
+ - `MIT`_ © 2014 Steven Buss
339
+ - `Apache 2`_ © 2014 Steven Buss
340
+
341
+ .. _the issues: https://github.com/multiformats/py-multiaddr/issues
342
+ .. _contributing document: https://github.com/multiformats/multiformats/blob/master/contributing.md
343
+ .. _py-multiaddr contributing: https://github.com/multiformats/py-multiaddr/blob/master/CONTRIBUTING.rst
344
+ .. _Code of Conduct: https://github.com/ipfs/community/blob/master/code-of-conduct.md
345
+ .. _standard-readme: https://github.com/RichardLitt/standard-readme
346
+ .. _MIT: LICENSE-MIT
347
+ .. _Apache 2: LICENSE-APACHE2
348
+ .. _`@sbuss`: https://github.com/sbuss
349
+ .. _`@acul71`: https://github.com/acul71
350
+ .. _`@pacrob`: https://github.com/pacrob
351
+ .. _`@manusheel`: https://github.com/manusheel
@@ -0,0 +1,27 @@
1
+ multiaddr/__init__.py,sha256=DfVkbEogAcnTHjeTUAF8HaS3oOHoqk8FMYq8M7RZrU8,128
2
+ multiaddr/exceptions.py,sha256=_-w9PJ83IiVzNkSBXUFO_NQNhuamaOqIRX2QNoziURk,3972
3
+ multiaddr/multiaddr.py,sha256=JxqUzCsVVydVAWaaU2Q74DNXAxJ0qe-gw2vu5VM4Rug,18498
4
+ multiaddr/protocols.py,sha256=jFsd8Ffl27cfmjdVQ3ClWrdv22vpGwUBkLr6jnCInFg,16824
5
+ multiaddr/transforms.py,sha256=m-Q49LNImR39wovEmb6n6W_OFfQ7kQu6YS4ishi4V_8,6562
6
+ multiaddr/utils.py,sha256=vjlnjsETMdEvjOok9aSKtkzyV1nBRDAZ9GusGu0JXsc,4002
7
+ multiaddr/codecs/__init__.py,sha256=YZNHEL2tkAVCOCvlzicu-b-XoQYqdazMElPArruBMzY,1067
8
+ multiaddr/codecs/cid.py,sha256=vBolruH-9mUbGXOKDJ7Cqsq5-lDIcCX-tK-ovKa9BrY,6001
9
+ multiaddr/codecs/domain.py,sha256=fNAh-wM4RmJL3zUqzeQlm97usQNf987lGwMId0LEA0U,1678
10
+ multiaddr/codecs/fspath.py,sha256=F1MeBomc3YcIVnGrYn8jFIHS2tUMurxvmaTKLKRRlzo,2432
11
+ multiaddr/codecs/ip4.py,sha256=3kWZZwL2oj2yetBg8PYuDH0WYSEpicS1gX96syjdi00,614
12
+ multiaddr/codecs/ip6.py,sha256=kyJQhif9cd-IgoxdtEvHSaxtdD8KMBnElhUp42bsXZU,425
13
+ multiaddr/codecs/memory.py,sha256=ZKn0dRCjWfnOm-4hnHOBkZBxlZiK2RO0VvuIcXKdWW4,902
14
+ multiaddr/codecs/onion.py,sha256=uTu_h31YExrdIwEhNXnzLp7ll7Bbz_G9HFQAbrixzCc,2111
15
+ multiaddr/codecs/onion3.py,sha256=uolJQifYz9rp4_U1ufwXAg3U1kGPAzUdWpV-1h8vA_M,2151
16
+ multiaddr/codecs/uint16be.py,sha256=hFblJWo639dXgmz-FPDvMQdYKcQtRfXbsWVJvgTNyJY,677
17
+ multiaddr/codecs/utf8.py,sha256=Sym6bUB07BiHD_rGgdO3bCKKGW92oDHiMiuxYJN2-9w,1902
18
+ multiaddr/resolvers/__init__.py,sha256=s47KFBiZpQkDJGRjhM15ycVMBIttv9-ZhUPND5bnAFw,140
19
+ multiaddr/resolvers/base.py,sha256=uF_YwF7l2lEIo-d0q2E4uGr-d6_YcJjYxJ6C1Rj96eM,704
20
+ multiaddr/resolvers/dns.py,sha256=RTPh97qBal7CYoz1aaZM_BqGJQxe_Cq6Jh7FszhvuO0,16342
21
+ multiaddr-0.0.11.dist-info/licenses/AUTHORS,sha256=p6oWjSpNNS_hZb7HVOWhkc4A0HciWFcs44h41Jtbxpc,281
22
+ multiaddr-0.0.11.dist-info/licenses/LICENSE-APACHE2,sha256=sTXpLn8GKlUas03I9HZ5x3pozzPYhWVwYEhmjDLhpg4,552
23
+ multiaddr-0.0.11.dist-info/licenses/LICENSE-MIT,sha256=a8I2qPl2z1TKZj9n2CZkfLH4y7mVg845L-ho_p2YUqE,1125
24
+ multiaddr-0.0.11.dist-info/METADATA,sha256=h0AyLfLwMqXZRIa1KwOdlarKBoI4J8x8IUlrOEBtYT8,11677
25
+ multiaddr-0.0.11.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
26
+ multiaddr-0.0.11.dist-info/top_level.txt,sha256=3M3vjbzUZjGnZtx9EMrKH7gxNj2GNXoFvTucE3szDCI,10
27
+ multiaddr-0.0.11.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,18 @@
1
+ Steven Buss <steven.buss@gmail.com>
2
+ Alexander Schlarb <alexander@ninetailed.ninja>
3
+ Fred Thomsen <fredthomsen@fredthomsen.net>
4
+ Jesse Weinstein <jesse@wefu.org>
5
+ mhchia
6
+ acul71
7
+ arcinston
8
+ pacrob
9
+ raulk
10
+ robzajac
11
+ zixuanzh
12
+ hugovk
13
+ justheuristic
14
+ manusheel
15
+ rodvagg
16
+ venkat
17
+ fredthomsen
18
+ web3-bot
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2018 Steven Buss
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
4
+
5
+ http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014-2015 Steven Buss
4
+ Copyright (c) 2019-2020 Alexander Schlarb
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ multiaddr