diff -Nru python-ifaddr-0.1.6/debian/changelog python-ifaddr-0.1.7/debian/changelog --- python-ifaddr-0.1.6/debian/changelog 2021-01-01 14:30:04.000000000 +0000 +++ python-ifaddr-0.1.7/debian/changelog 2021-01-16 08:22:39.000000000 +0000 @@ -1,9 +1,27 @@ -python-ifaddr (0.1.6-1.1) unstable; urgency=medium +python-ifaddr (0.1.7-1) unstable; urgency=medium - * Non maintainer upload by the Reproducible Builds team. - * No source change upload to rebuild on buildd with .buildinfo files. + * New upstream version - -- Holger Levsen Fri, 01 Jan 2021 15:30:04 +0100 + [ Ondřej Nový ] + * Use debhelper-compat instead of debian/compat. + * d/control: Update Maintainer field with new Debian Python Team + contact address. + * d/control: Update Vcs-* fields with new Debian Python Team Salsa + layout. + + [ Debian Janitor ] + * Update watch file format version to 4. + * Remove obsolete field Name from debian/upstream/metadata (already present in + machine-readable debian/copyright). + + [ Ruben Undheim ] + * Standards-Version: 4.5.1 (routine-update) + * debhelper-compat 13 (routine-update) + * Testsuite: autopkgtest-pkg-python (routine-update) + * Add salsa-ci file (routine-update) + * Rules-Requires-Root: no (routine-update) + + -- Ruben Undheim Sat, 16 Jan 2021 08:22:39 +0000 python-ifaddr (0.1.6-1) unstable; urgency=medium diff -Nru python-ifaddr-0.1.6/debian/compat python-ifaddr-0.1.7/debian/compat --- python-ifaddr-0.1.6/debian/compat 2018-12-21 20:47:07.000000000 +0000 +++ python-ifaddr-0.1.7/debian/compat 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -11 diff -Nru python-ifaddr-0.1.6/debian/control python-ifaddr-0.1.7/debian/control --- python-ifaddr-0.1.6/debian/control 2018-12-21 20:47:07.000000000 +0000 +++ python-ifaddr-0.1.7/debian/control 2021-01-16 08:22:39.000000000 +0000 @@ -1,16 +1,18 @@ Source: python-ifaddr Section: python +Testsuite: autopkgtest-pkg-python Priority: optional -Maintainer: Debian Python Modules Team +Maintainer: Debian Python Team Uploaders: Ruben Undheim -Build-Depends: debhelper (>= 11), +Build-Depends: debhelper-compat (= 13), dh-python, python3-all, python3-setuptools -Standards-Version: 4.2.1 +Standards-Version: 4.5.1 Homepage: https://github.com/pydron/ifaddr -Vcs-Browser: https://salsa.debian.org/python-team/modules/python-ifaddr -Vcs-Git: https://salsa.debian.org/python-team/modules/python-ifaddr.git +Rules-Requires-Root: no +Vcs-Browser: https://salsa.debian.org/python-team/packages/python-ifaddr +Vcs-Git: https://salsa.debian.org/python-team/packages/python-ifaddr.git Package: python3-ifaddr diff -Nru python-ifaddr-0.1.6/debian/salsa-ci.yml python-ifaddr-0.1.7/debian/salsa-ci.yml --- python-ifaddr-0.1.6/debian/salsa-ci.yml 1970-01-01 00:00:00.000000000 +0000 +++ python-ifaddr-0.1.7/debian/salsa-ci.yml 2021-01-16 08:22:39.000000000 +0000 @@ -0,0 +1,4 @@ +--- +include: + - https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/salsa-ci.yml + - https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/pipeline-jobs.yml diff -Nru python-ifaddr-0.1.6/debian/upstream/metadata python-ifaddr-0.1.7/debian/upstream/metadata --- python-ifaddr-0.1.6/debian/upstream/metadata 2018-12-21 20:47:07.000000000 +0000 +++ python-ifaddr-0.1.7/debian/upstream/metadata 2021-01-16 08:21:43.000000000 +0000 @@ -1,6 +1,5 @@ --- Bug-Database: https://github.com/pydron/ifaddr/issues Bug-Submit: https://github.com/pydron/ifaddr/issues/new -Name: ifaddr Repository: https://github.com/pydron/ifaddr.git Repository-Browse: https://github.com/pydron/ifaddr diff -Nru python-ifaddr-0.1.6/debian/watch python-ifaddr-0.1.7/debian/watch --- python-ifaddr-0.1.6/debian/watch 2018-12-21 20:47:07.000000000 +0000 +++ python-ifaddr-0.1.7/debian/watch 2021-01-16 08:21:43.000000000 +0000 @@ -1,2 +1,2 @@ -version=3 +version=4 https://github.com/pydron/ifaddr/releases /pydron/ifaddr/archive/(\d\S+)\.tar\.(?:bz2|gz|xz) diff -Nru python-ifaddr-0.1.6/doc/conf.py python-ifaddr-0.1.7/doc/conf.py --- python-ifaddr-0.1.6/doc/conf.py 2018-12-09 19:55:49.000000000 +0000 +++ python-ifaddr-0.1.7/doc/conf.py 2020-06-06 18:56:39.000000000 +0000 @@ -26,12 +26,12 @@ # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = ['sphinx.ext.autodoc', - 'sphinx.ext.doctest', + 'sphinx.ext.doctest', 'sphinx.ext.intersphinx', - 'sphinx.ext.todo', - 'sphinx.ext.coverage', - 'sphinx.ext.pngmath', - 'sphinx.ext.ifconfig', + 'sphinx.ext.todo', + 'sphinx.ext.coverage', + 'sphinx.ext.pngmath', + 'sphinx.ext.ifconfig', 'sphinx.ext.viewcode', 'sphinx.ext.graphviz'] @@ -266,4 +266,4 @@ return skip def setup(app): - app.connect("autodoc-skip-member", skip) \ No newline at end of file + app.connect("autodoc-skip-member", skip) diff -Nru python-ifaddr-0.1.6/doc/index.rst python-ifaddr-0.1.7/doc/index.rst --- python-ifaddr-0.1.6/doc/index.rst 2018-12-09 19:55:49.000000000 +0000 +++ python-ifaddr-0.1.7/doc/index.rst 2020-06-06 18:56:39.000000000 +0000 @@ -20,14 +20,14 @@ .. code-block:: python import ifaddr - + adapters = ifaddr.get_adapters() - + for adapter in adapters: - print "IPs of network adapter " + adapter.nice_name + print ("IPs of network adapter " + adapter.nice_name) for ip in adapter.ips: - print " %s/%s" % (ip.ip, ip.network_prefix) - + print (" %s/%s" % (ip.ip, ip.network_prefix)) + This will print: .. code-block:: none @@ -44,7 +44,7 @@ IPs of network adapter Software Loopback Interface 1 IP ('::1', 0L, 0L)/128 IP 127.0.0.1/8 - + You get both IPv4 and IPv6 addresses. The later complete with flowinfo and scope_id. @@ -57,18 +57,18 @@ .. py:function:: ifaddr.get_adapters() Receives all the network adapters with their IP addresses. - + :returns: List of :class:`ifaddr.Adapter` instances in the order they are provided by the operating system. - + And two simple classes: - + .. autoclass:: ifaddr.Adapter :members: name, ips, nice_name - + .. autoclass:: ifaddr.IP :members: ip, network_prefix, nice_name - + ----------------------------------- Bug Reports and other contributions ----------------------------------- @@ -79,7 +79,7 @@ Alternatives ------------ -Alastair Houghton develops `netifaces `_ +Alastair Houghton develops `netifaces `_ which can do everything this library can, and more. The only drawback is that it needs to be compiled, which can make the installation difficult. diff -Nru python-ifaddr-0.1.6/doc/_static/readme.txt python-ifaddr-0.1.7/doc/_static/readme.txt --- python-ifaddr-0.1.6/doc/_static/readme.txt 2018-12-09 19:55:49.000000000 +0000 +++ python-ifaddr-0.1.7/doc/_static/readme.txt 2020-06-06 18:56:39.000000000 +0000 @@ -1 +1 @@ -Static content of html content goes here. \ No newline at end of file +Static content of html content goes here. diff -Nru python-ifaddr-0.1.6/.github/workflows/ci.yml python-ifaddr-0.1.7/.github/workflows/ci.yml --- python-ifaddr-0.1.6/.github/workflows/ci.yml 1970-01-01 00:00:00.000000000 +0000 +++ python-ifaddr-0.1.7/.github/workflows/ci.yml 2020-06-06 18:56:39.000000000 +0000 @@ -0,0 +1,28 @@ +name: CI + +on: [push, pull_request] + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + python-version: [2.7, 3.5, 3.6, 3.7, 3.8, pypy2, pypy3] + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + pip install --upgrade -r requirements-dev.txt + pip install . + - name: Run tests + run: | + pytest + # Coveralls won't work here trivially because it can't ingest coverage.xml, so Codecov it is. + # https://github.com/coverallsapp/github-action/issues/30 + - name: Report coverage to Codecov + uses: codecov/codecov-action@v1 diff -Nru python-ifaddr-0.1.6/.gitignore python-ifaddr-0.1.7/.gitignore --- python-ifaddr-0.1.6/.gitignore 2018-12-09 19:55:49.000000000 +0000 +++ python-ifaddr-0.1.7/.gitignore 2020-06-06 18:56:39.000000000 +0000 @@ -52,4 +52,4 @@ docs/_build/ /.settings/org.eclipse.core.resources.prefs -.idea \ No newline at end of file +.idea diff -Nru python-ifaddr-0.1.6/ifaddr/__init__.py python-ifaddr-0.1.7/ifaddr/__init__.py --- python-ifaddr-0.1.6/ifaddr/__init__.py 2018-12-09 19:55:49.000000000 +0000 +++ python-ifaddr-0.1.7/ifaddr/__init__.py 2020-06-06 18:56:39.000000000 +0000 @@ -6,15 +6,15 @@ # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: -# +# # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. -# +# # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. diff -Nru python-ifaddr-0.1.6/ifaddr/_posix.py python-ifaddr-0.1.7/ifaddr/_posix.py --- python-ifaddr-0.1.6/ifaddr/_posix.py 2018-12-09 19:55:49.000000000 +0000 +++ python-ifaddr-0.1.7/ifaddr/_posix.py 2020-06-06 18:56:39.000000000 +0000 @@ -6,15 +6,15 @@ # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: -# +# # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. -# +# # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. @@ -24,6 +24,7 @@ import ctypes.util import ipaddress import collections +import socket import ifaddr._shared as shared #from ifaddr._shared import sockaddr, Interface, sockaddr_to_ip, ipv6_prefixlength @@ -36,10 +37,10 @@ ('ifa_addr', ctypes.POINTER(shared.sockaddr)), ('ifa_netmask', ctypes.POINTER(shared.sockaddr))] -libc = ctypes.CDLL(ctypes.util.find_library("c"), use_errno=True) +libc = ctypes.CDLL(ctypes.util.find_library("socket" if os.uname()[0] == "SunOS" else "c"), use_errno=True) def get_adapters(): - + addr0 = addr = ctypes.POINTER(ifaddrs)() retval = libc.getifaddrs(ctypes.byref(addr)) if retval != 0: @@ -47,13 +48,18 @@ raise OSError(eno, os.strerror(eno)) ips = collections.OrderedDict() - + def add_ip(adapter_name, ip): if not adapter_name in ips: - ips[adapter_name] = shared.Adapter(adapter_name, adapter_name, []) + try: + index = socket.if_nametoindex(adapter_name) + except (OSError, AttributeError): + index = None + ips[adapter_name] = shared.Adapter(adapter_name, adapter_name, [], + index=index) ips[adapter_name].ips.append(ip) - - + + while addr: name = addr[0].ifa_name if sys.version_info[0] > 2: diff -Nru python-ifaddr-0.1.6/ifaddr/_shared.py python-ifaddr-0.1.7/ifaddr/_shared.py --- python-ifaddr-0.1.6/ifaddr/_shared.py 2018-12-09 19:55:49.000000000 +0000 +++ python-ifaddr-0.1.7/ifaddr/_shared.py 2020-06-06 18:56:39.000000000 +0000 @@ -6,15 +6,15 @@ # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: -# +# # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. -# +# # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. @@ -28,21 +28,21 @@ """ Represents a network interface device controller (NIC), such as a network card. An adapter can have multiple IPs. - + On Linux aliasing (multiple IPs per physical NIC) is implemented by creating 'virtual' adapters, each represented by an instance of this class. Each of those 'virtual' adapters can have both a IPv4 and an IPv6 IP address. """ - - def __init__(self, name, nice_name, ips): - + + def __init__(self, name, nice_name, ips, index=None): + #: Unique name that identifies the adapter in the system. #: On Linux this is of the form of `eth0` or `eth0:1`, on #: Windows it is a UUID in string representation, such as #: `{846EE342-7039-11DE-9D20-806E6F6E6963}`. self.name = name - + #: Human readable name of the adpater. On Linux this #: is currently the same as :attr:`name`. On Windows #: this is the name of the device. @@ -51,12 +51,16 @@ #: List of :class:`ifaddr.IP` instances in the order they were #: reported by the system. self.ips = ips - + + #: Adapter index as used by some API (e.g. IPv6 multicast group join). + self.index = index + def __repr__(self): - return "Adapter(name={name}, nice_name={nice_name}, ips={ips})".format( + return "Adapter(name={name}, nice_name={nice_name}, ips={ips}, index={index})".format( name = repr(self.name), nice_name = repr(self.nice_name), - ips = repr(self.ips) + ips = repr(self.ips), + index=repr(self.index) ) @@ -64,27 +68,27 @@ """ Represents an IP address of an adapter. """ - + def __init__(self, ip, network_prefix, nice_name): - + #: IP address. For IPv4 addresses this is a string in #: "xxx.xxx.xxx.xxx" format. For IPv6 addresses this #: is a three-tuple `(ip, flowinfo, scope_id)`, where #: `ip` is a string in the usual collon separated #: hex format. self.ip = ip - + #: Number of bits of the IP that represent the #: network. For a `255.255.255.0` netmask, this #: number would be `24`. self.network_prefix = network_prefix - - #: Human readable name for this IP. + + #: Human readable name for this IP. #: On Linux is this currently the same as the adapter name. #: On Windows this is the name of the network connection #: as configured in the system control panel. self.nice_name = nice_name - + @property def is_IPv4(self): """ @@ -100,35 +104,35 @@ if it is an IPv4 address. """ return isinstance(self.ip, tuple) - - + + def __repr__(self): return "IP(ip={ip}, network_prefix={network_prefix}, nice_name={nice_name})".format( ip = repr(self.ip), network_prefix = repr(self.network_prefix), - nice_name = repr(self.nice_name) + nice_name = repr(self.nice_name) ) - + if platform.system() == "Darwin" or "BSD" in platform.system(): - + # BSD derived systems use marginally different structures # than either Linux or Windows. # I still keep it in `shared` since we can use # both structures equally. - + class sockaddr(ctypes.Structure): _fields_= [('sa_len', ctypes.c_uint8), ('sa_familiy', ctypes.c_uint8), ('sa_data', ctypes.c_uint8 * 14)] - + class sockaddr_in(ctypes.Structure): _fields_= [('sa_len', ctypes.c_uint8), ('sa_familiy', ctypes.c_uint8), ('sin_port', ctypes.c_uint16), ('sin_addr', ctypes.c_uint8 * 4), ('sin_zero', ctypes.c_uint8 * 8)] - + class sockaddr_in6(ctypes.Structure): _fields_= [('sa_len', ctypes.c_uint8), ('sa_familiy', ctypes.c_uint8), @@ -142,21 +146,21 @@ class sockaddr(ctypes.Structure): _fields_= [('sa_familiy', ctypes.c_uint16), ('sa_data', ctypes.c_uint8 * 14)] - + class sockaddr_in(ctypes.Structure): _fields_= [('sin_familiy', ctypes.c_uint16), ('sin_port', ctypes.c_uint16), ('sin_addr', ctypes.c_uint8 * 4), ('sin_zero', ctypes.c_uint8 * 8)] - + class sockaddr_in6(ctypes.Structure): _fields_= [('sin6_familiy', ctypes.c_uint16), ('sin6_port', ctypes.c_uint16), ('sin6_flowinfo', ctypes.c_uint32), ('sin6_addr', ctypes.c_uint8 * 16), ('sin6_scope_id', ctypes.c_uint32)] - - + + def sockaddr_to_ip(sockaddr_ptr): if sockaddr_ptr: if sockaddr_ptr[0].sa_familiy == socket.AF_INET: diff -Nru python-ifaddr-0.1.6/ifaddr/test_ifaddr.py python-ifaddr-0.1.7/ifaddr/test_ifaddr.py --- python-ifaddr-0.1.6/ifaddr/test_ifaddr.py 2018-12-09 19:55:49.000000000 +0000 +++ python-ifaddr-0.1.7/ifaddr/test_ifaddr.py 2020-06-06 18:56:39.000000000 +0000 @@ -6,19 +6,19 @@ class TestIfaddr(unittest.TestCase): """ Unittests for :mod:`ifaddr`. - + There isn't much unit-testing that can be done without making assumptions on the system or mocking of operating system APIs. So this just contains a sanity check for the moment. """ - + def test_get_adapters_contains_localhost(self): - + found = False adapters = ifaddr.get_adapters() for adapter in adapters: for ip in adapter.ips: if ip.ip == "127.0.0.1": found = True - - self.assertTrue(found, "No adapter has IP 127.0.0.1: %s" % str(adapters)) \ No newline at end of file + + self.assertTrue(found, "No adapter has IP 127.0.0.1: %s" % str(adapters)) diff -Nru python-ifaddr-0.1.6/ifaddr/_win32.py python-ifaddr-0.1.7/ifaddr/_win32.py --- python-ifaddr-0.1.6/ifaddr/_win32.py 2018-12-09 19:55:49.000000000 +0000 +++ python-ifaddr-0.1.7/ifaddr/_win32.py 2020-06-06 18:56:39.000000000 +0000 @@ -6,15 +6,15 @@ # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: -# +# # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. -# +# # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. @@ -32,11 +32,11 @@ AF_UNSPEC = 0 - + class SOCKET_ADDRESS(ctypes.Structure): _fields_ = [('lpSockaddr', ctypes.POINTER(shared.sockaddr)), ('iSockaddrLength', wintypes.INT)] - + class IP_ADAPTER_UNICAST_ADDRESS(ctypes.Structure): pass IP_ADAPTER_UNICAST_ADDRESS._fields_ = \ @@ -73,7 +73,7 @@ def enumerate_interfaces_of_adapter(nice_name, address): - + # Iterate through linked list and fill list addresses = [] while True: @@ -81,15 +81,15 @@ if not address.Next: break address = address.Next[0] - + for address in addresses: ip = shared.sockaddr_to_ip(address.Address.lpSockaddr) network_prefix = address.OnLinkPrefixLength yield shared.IP(ip, network_prefix, nice_name) - - + + def get_adapters(): - + # Call GetAdaptersAddresses() with error and buffer size handling addressbuffersize = wintypes.ULONG(15*1024) @@ -103,7 +103,7 @@ ctypes.byref(addressbuffersize)) if retval != NO_ERROR: raise ctypes.WinError() - + # Iterate through adapters fill array address_infos = [] address_info = IP_ADAPTER_ADDRESSES.from_buffer(addressbuffer) @@ -112,18 +112,20 @@ if not address_info.Next: break address_info = address_info.Next[0] - - + + # Iterate through unicast addresses result = [] for adapter_info in address_infos: - + name = adapter_info.AdapterName nice_name = adapter_info.Description - + index = adapter_info.IfIndex + if adapter_info.FirstUnicastAddress: ips = enumerate_interfaces_of_adapter(adapter_info.FriendlyName, adapter_info.FirstUnicastAddress[0]) ips = list(ips) - result.append(shared.Adapter(name, nice_name, ips)) + result.append(shared.Adapter(name, nice_name, ips, + index=index)) return result diff -Nru python-ifaddr-0.1.6/MANIFEST.in python-ifaddr-0.1.7/MANIFEST.in --- python-ifaddr-0.1.6/MANIFEST.in 2018-12-09 19:55:49.000000000 +0000 +++ python-ifaddr-0.1.7/MANIFEST.in 2020-06-06 18:56:39.000000000 +0000 @@ -1 +1,2 @@ include README.rst +include LICENSE.txt diff -Nru python-ifaddr-0.1.6/pytest.ini python-ifaddr-0.1.7/pytest.ini --- python-ifaddr-0.1.6/pytest.ini 1970-01-01 00:00:00.000000000 +0000 +++ python-ifaddr-0.1.7/pytest.ini 2020-06-06 18:56:39.000000000 +0000 @@ -0,0 +1,2 @@ +[pytest] +addopts = -v --cov-report term --cov-report html --cov-report xml --cov-report term-missing --cov=ifaddr --cov-branch diff -Nru python-ifaddr-0.1.6/README.rst python-ifaddr-0.1.7/README.rst --- python-ifaddr-0.1.6/README.rst 2018-12-09 19:55:49.000000000 +0000 +++ python-ifaddr-0.1.7/README.rst 2020-06-06 18:56:39.000000000 +0000 @@ -1,73 +1,84 @@ +ifaddr - Enumerate network interfaces/adapters and their IP addresses +===================================================================== +.. image:: https://github.com/pydron/ifaddr/workflows/CI/badge.svg + :target: https://github.com/pydron/ifaddr/actions?query=workflow%3ACI+branch%3Amaster -ifaddr - Enumerate IP addresses on the local network adapters -============================================================= +.. image:: https://img.shields.io/pypi/v/ifaddr.svg + :target: https://pypi.python.org/pypi/ifaddr + +.. image:: https://codecov.io/gh/pydron/ifaddr/branch/master/graph/badge.svg + :target: https://codecov.io/gh/pydron/ifaddr `ifaddr` is a small Python library that allows you to find all the IP addresses of the computer. It is tested on **Linux**, **OS X**, and **Windows**. Other BSD derivatives like **OpenBSD**, **FreeBSD**, and **NetBSD** should work too, but I haven't personally tested those. +**Solaris/Illumos** should also work. -This library is open source and released under the MIT License. +This library is open source and released under the MIT License. It works +with Python 2.7 and 3.5+. You can install it with `pip install ifaddr`. It doesn't need to compile anything, so there shouldn't be any surprises. Even on Windows. +Project links: + +* `ifaddr GitHub page `_ +* `ifaddr documentation (although there isn't much to document) `_ +* `ifaddr on PyPI `_ + + ---------------------- Let's get going! ---------------------- .. code-block:: python - import ifaddr - - adapters = ifaddr.get_adapters() - - for adapter in adapters: - print "IPs of network adapter " + adapter.nice_name - for ip in adapter.ips: - print " %s/%s" % (ip.ip, ip.network_prefix) - -This will print: + import ifaddr -.. code-block:: python + adapters = ifaddr.get_adapters() + + for adapter in adapters: + print("IPs of network adapter " + adapter.nice_name) + for ip in adapter.ips: + print(" %s/%s" % (ip.ip, ip.network_prefix)) + +This will print:: + + IPs of network adapter H5321 gw Mobile Broadband Driver + IP ('fe80::9:ebdf:30ab:39a3', 0L, 17L)/64 + IP 169.254.57.163/16 + IPs of network adapter Intel(R) Centrino(R) Advanced-N 6205 + IP ('fe80::481f:3c9d:c3f6:93f8', 0L, 12L)/64 + IP 192.168.0.51/24 + IPs of network adapter Intel(R) 82579LM Gigabit Network Connection + IP ('fe80::85cd:e07e:4f7a:6aa6', 0L, 11L)/64 + IP 192.168.0.53/24 + IPs of network adapter Software Loopback Interface 1 + IP ('::1', 0L, 0L)/128 + IP 127.0.0.1/8 - IPs of network adapter H5321 gw Mobile Broadband Driver - IP ('fe80::9:ebdf:30ab:39a3', 0L, 17L)/64 - IP 169.254.57.163/16 - IPs of network adapter Intel(R) Centrino(R) Advanced-N 6205 - IP ('fe80::481f:3c9d:c3f6:93f8', 0L, 12L)/64 - IP 192.168.0.51/24 - IPs of network adapter Intel(R) 82579LM Gigabit Network Connection - IP ('fe80::85cd:e07e:4f7a:6aa6', 0L, 11L)/64 - IP 192.168.0.53/24 - IPs of network adapter Software Loopback Interface 1 - IP ('::1', 0L, 0L)/128 - IP 127.0.0.1/8 - You get both IPv4 and IPv6 addresses. The later complete with flowinfo and scope_id. -------------- -Documentation -------------- - -The complete documentation (there isn't much to document) can be found here: -`ifaddr Documentation `_. - ------------------------------------ -Bug Reports and other contributions ------------------------------------ +--------- +Changelog +--------- + +0.1.7 +----- + +* Fixed Python 3 compatibility in the examples, thanks to Tristan Stenner and Josef Schlehofer +* Exposed network interface indexes in Adapter.index, thanks to Dmitry Tantsur +* Added the license file to distributions on PyPI, thanks to Tomáš Chvátal +* Fixed Illumos/Solaris compatibility based on a patch proposed by Jorge Schrauwen +* Set up universal wheels, ifaddr will have both source and wheel distributions on PyPI from now on -This project is hosted here `ifaddr github page `_. - ------------ Alternatives ------------ -Alastair Houghton develops `netifaces `_ +Alastair Houghton develops `netifaces `_ which can do everything this library can, and more. The only drawback is that it needs to be compiled, which can make the installation difficult. - - - diff -Nru python-ifaddr-0.1.6/requirements-dev.txt python-ifaddr-0.1.7/requirements-dev.txt --- python-ifaddr-0.1.6/requirements-dev.txt 1970-01-01 00:00:00.000000000 +0000 +++ python-ifaddr-0.1.7/requirements-dev.txt 2020-06-06 18:56:39.000000000 +0000 @@ -0,0 +1,2 @@ +pytest +pytest-cov diff -Nru python-ifaddr-0.1.6/setup.cfg python-ifaddr-0.1.7/setup.cfg --- python-ifaddr-0.1.6/setup.cfg 2018-12-09 19:55:49.000000000 +0000 +++ python-ifaddr-0.1.7/setup.cfg 2020-06-06 18:56:39.000000000 +0000 @@ -3,3 +3,5 @@ build-dir = build/doc all_files = 1 +[wheel] +universal = True diff -Nru python-ifaddr-0.1.6/setup.py python-ifaddr-0.1.7/setup.py --- python-ifaddr-0.1.6/setup.py 2018-12-09 19:55:49.000000000 +0000 +++ python-ifaddr-0.1.7/setup.py 2020-06-06 18:56:39.000000000 +0000 @@ -18,7 +18,6 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. -import sys import os.path from setuptools import setup, find_packages @@ -30,12 +29,27 @@ setup( name = 'ifaddr', - version = '0.1.6', - description='Enumerates all IP addresses on all network adapters of the system.', + version = '0.1.7', + description='Cross-platform network interface and IP address enumeration library', long_description=long_description, author='Stefan C. Mueller', author_email='scm@smurn.org', url='https://github.com/pydron/ifaddr', packages = find_packages(), - install_requires = ['ipaddress'] if sys.version_info[:2] < (3, 3) else [], -) \ No newline at end of file + license='MIT', + install_requires = ['ipaddress;python_version<"3.3"'], + classifiers=[ + 'Intended Audience :: Developers', + 'License :: OSI Approved :: MIT License', + 'Topic :: System :: Networking', + 'Programming Language :: Python', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + ], + keywords=['network interfaces', 'network adapters', 'network addresses', 'IP addresses'], +)