mirror of
https://github.com/markqvist/Reticulum.git
synced 2024-11-22 13:40:19 +00:00
Removed dependency on netifaces.
This commit is contained in:
parent
a3bee4baa9
commit
5e5d89cc92
@ -190,7 +190,6 @@ these dependencies, and when the `rns` package is installed with `pip`, they
|
||||
will be downloaded and installed as well.
|
||||
|
||||
- [PyCA/cryptography](https://github.com/pyca/cryptography)
|
||||
- [netifaces](https://github.com/al45tair/netifaces)
|
||||
- [pyserial](https://github.com/pyserial/pyserial)
|
||||
|
||||
On more unusual systems, and in some rare cases, it might not be possible to
|
||||
|
@ -408,25 +408,15 @@ class TCPServerInterface(Interface):
|
||||
|
||||
@staticmethod
|
||||
def get_address_for_if(name):
|
||||
import importlib
|
||||
if importlib.util.find_spec('netifaces') != None:
|
||||
import netifaces
|
||||
return netifaces.ifaddresses(name)[netifaces.AF_INET][0]['addr']
|
||||
else:
|
||||
RNS.log("Getting interface addresses from device names requires the netifaces module.", RNS.LOG_CRITICAL)
|
||||
RNS.log("You can install it with the command: python3 -m pip install netifaces", RNS.LOG_CRITICAL)
|
||||
RNS.panic()
|
||||
import RNS.vendor.ifaddr.niwrapper as netinfo
|
||||
ifaddr = netinfo.ifaddresses(name)
|
||||
return ifaddr[netinfo.AF_INET][0]["addr"]
|
||||
|
||||
@staticmethod
|
||||
def get_broadcast_for_if(name):
|
||||
import importlib
|
||||
if importlib.util.find_spec('netifaces') != None:
|
||||
import netifaces
|
||||
return netifaces.ifaddresses(name)[netifaces.AF_INET][0]['broadcast']
|
||||
else:
|
||||
RNS.log("Getting interface addresses from device names requires the netifaces module.", RNS.LOG_CRITICAL)
|
||||
RNS.log("You can install it with the command: python3 -m pip install netifaces", RNS.LOG_CRITICAL)
|
||||
RNS.panic()
|
||||
import RNS.vendor.ifaddr.niwrapper as netinfo
|
||||
ifaddr = netinfo.ifaddresses(name)
|
||||
return ifaddr[netinfo.AF_INET][0]["broadcast"]
|
||||
|
||||
def __init__(self, owner, name, device=None, bindip=None, bindport=None, i2p_tunneled=False):
|
||||
self.rxb = 0
|
||||
|
@ -34,25 +34,15 @@ class UDPInterface(Interface):
|
||||
|
||||
@staticmethod
|
||||
def get_address_for_if(name):
|
||||
import importlib
|
||||
if importlib.util.find_spec('netifaces') != None:
|
||||
import netifaces
|
||||
return netifaces.ifaddresses(name)[netifaces.AF_INET][0]['addr']
|
||||
else:
|
||||
RNS.log("Getting interface addresses from device names requires the netifaces module.", RNS.LOG_CRITICAL)
|
||||
RNS.log("You can install it with the command: python3 -m pip install netifaces", RNS.LOG_CRITICAL)
|
||||
RNS.panic()
|
||||
import RNS.vendor.ifaddr.niwrapper as netinfo
|
||||
ifaddr = netinfo.ifaddresses(name)
|
||||
return ifaddr[netinfo.AF_INET][0]["addr"]
|
||||
|
||||
@staticmethod
|
||||
def get_broadcast_for_if(name):
|
||||
import importlib
|
||||
if importlib.util.find_spec('netifaces') != None:
|
||||
import netifaces
|
||||
return netifaces.ifaddresses(name)[netifaces.AF_INET][0]['broadcast']
|
||||
else:
|
||||
RNS.log("Getting interface addresses from device names requires the netifaces module.", RNS.LOG_CRITICAL)
|
||||
RNS.log("You can install it with the command: python3 -m pip install netifaces", RNS.LOG_CRITICAL)
|
||||
RNS.panic()
|
||||
import RNS.vendor.ifaddr.niwrapper as netinfo
|
||||
ifaddr = netinfo.ifaddresses(name)
|
||||
return ifaddr[netinfo.AF_INET][0]["broadcast"]
|
||||
|
||||
def __init__(self, owner, name, device=None, bindip=None, bindport=None, forwardip=None, forwardport=None):
|
||||
self.rxb = 0
|
||||
|
6
RNS/vendor/ifaddr/niwrapper.py
vendored
6
RNS/vendor/ifaddr/niwrapper.py
vendored
@ -1,5 +1,4 @@
|
||||
# netifaces compatibility layer
|
||||
|
||||
import ipaddress
|
||||
import ifaddr
|
||||
import socket
|
||||
|
||||
@ -22,7 +21,10 @@ def ifaddresses(ifname) -> dict:
|
||||
for ip in a.ips:
|
||||
t = {}
|
||||
if ip.is_IPv4:
|
||||
net = ipaddress.ip_network(str(ip.ip)+"/"+str(ip.network_prefix), strict=False)
|
||||
t["addr"] = ip.ip
|
||||
t["prefix"] = ip.network_prefix
|
||||
t["broadcast"] = str(net.broadcast_address)
|
||||
ipv4s.append(t)
|
||||
if ip.is_IPv6:
|
||||
t["addr"] = ip.ip[0]
|
||||
|
48
RNS/vendor/ifaddr/test_ifaddr.py
vendored
48
RNS/vendor/ifaddr/test_ifaddr.py
vendored
@ -1,48 +0,0 @@
|
||||
# Copyright (C) 2015 Stefan C. Mueller
|
||||
|
||||
import unittest
|
||||
|
||||
import pytest
|
||||
|
||||
import ifaddr
|
||||
import ifaddr.netifaces
|
||||
|
||||
|
||||
try:
|
||||
import netifaces
|
||||
except ImportError:
|
||||
skip_netifaces = True
|
||||
else:
|
||||
skip_netifaces = False
|
||||
|
||||
|
||||
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) -> None:
|
||||
|
||||
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))
|
||||
|
||||
|
||||
@pytest.mark.skipif(skip_netifaces, reason='netifaces not installed')
|
||||
def test_netifaces_compatibility() -> None:
|
||||
interfaces = ifaddr.netifaces.interfaces()
|
||||
assert interfaces == netifaces.interfaces()
|
||||
# TODO: implement those as well
|
||||
# for interface in interfaces:
|
||||
# print(interface)
|
||||
# assert ifaddr.netifaces.ifaddresses(interface) == netifaces.ifaddresses(interface)
|
||||
# assert ifaddr.netifaces.gateways() == netifaces.gateways()
|
@ -38,7 +38,7 @@ These efforts are aimed at improving the ease of which Reticulum is understood,
|
||||
- Update NomadNet screenshots
|
||||
- Update Sideband screenshots
|
||||
- Installation
|
||||
- Install docs for fedora, needs `python3-netifaces`
|
||||
- Remove references to netifaces
|
||||
- Add a *Reticulum On Raspberry Pi* section
|
||||
- Update *Reticulum On Android* section if necessary
|
||||
- Update Android install documentation.
|
||||
|
Binary file not shown.
Binary file not shown.
2
setup.py
2
setup.py
@ -20,7 +20,7 @@ if pure_python:
|
||||
long_description = long_description.replace("</p>", "</p>"+pure_notice)
|
||||
else:
|
||||
pkg_name = "rns"
|
||||
requirements = ['cryptography>=3.4.7', 'pyserial>=3.5', 'netifaces']
|
||||
requirements = ['cryptography>=3.4.7', 'pyserial>=3.5']
|
||||
|
||||
excluded_modules = exclude=["tests.*", "tests"]
|
||||
packages = setuptools.find_packages(exclude=excluded_modules)
|
||||
|
Loading…
Reference in New Issue
Block a user