* Remove ifaddr since psutil provides access to net interfaces
+ added mimcvdf dependency for future block spec
This commit is contained in:
parent
d4f4487fb6
commit
fe3b6c01c4
@ -13,4 +13,4 @@ toomanyobjs==1.1.0
|
|||||||
niceware==0.2.1
|
niceware==0.2.1
|
||||||
psutil==5.7.0
|
psutil==5.7.0
|
||||||
filenuke==0.0.0
|
filenuke==0.0.0
|
||||||
ifaddr==0.1.6
|
mimcvdf==0.0.0
|
@ -47,13 +47,16 @@ click==7.0 \
|
|||||||
--hash=sha256:5b94b49521f6456670fdb30cd82a4eca9412788a93fa6dd6df72c94d5a8ff2d7 \
|
--hash=sha256:5b94b49521f6456670fdb30cd82a4eca9412788a93fa6dd6df72c94d5a8ff2d7 \
|
||||||
# via flask
|
# via flask
|
||||||
deadsimplekv==0.2.0 \
|
deadsimplekv==0.2.0 \
|
||||||
--hash=sha256:81405408a4d23cc94ac359f9570e0ff198b67e5a93e3ae32eca85e3b62252f38
|
--hash=sha256:81405408a4d23cc94ac359f9570e0ff198b67e5a93e3ae32eca85e3b62252f38 \
|
||||||
|
# via -r requirements.in
|
||||||
filenuke==0.0.0 \
|
filenuke==0.0.0 \
|
||||||
--hash=sha256:147011c0125121469cae0a8a7f4df399f470e54aa29a08f2d2c099bf0118dcee \
|
--hash=sha256:147011c0125121469cae0a8a7f4df399f470e54aa29a08f2d2c099bf0118dcee \
|
||||||
--hash=sha256:c55535dcecfdb27c5f4ce664d46e115950b5429763b5db75c198053646177f8f
|
--hash=sha256:c55535dcecfdb27c5f4ce664d46e115950b5429763b5db75c198053646177f8f \
|
||||||
|
# via -r requirements.in
|
||||||
flask==1.1.1 \
|
flask==1.1.1 \
|
||||||
--hash=sha256:13f9f196f330c7c2c5d7a5cf91af894110ca0215ac051b5844701f2bfd934d52 \
|
--hash=sha256:13f9f196f330c7c2c5d7a5cf91af894110ca0215ac051b5844701f2bfd934d52 \
|
||||||
--hash=sha256:45eb5a6fd193d6cf7e0cf5d8a5b31f83d5faae0293695626f539a823e93b13f6
|
--hash=sha256:45eb5a6fd193d6cf7e0cf5d8a5b31f83d5faae0293695626f539a823e93b13f6 \
|
||||||
|
# via -r requirements.in
|
||||||
gevent==1.4.0 \
|
gevent==1.4.0 \
|
||||||
--hash=sha256:0774babec518a24d9a7231d4e689931f31b332c4517a771e532002614e270a64 \
|
--hash=sha256:0774babec518a24d9a7231d4e689931f31b332c4517a771e532002614e270a64 \
|
||||||
--hash=sha256:0e1e5b73a445fe82d40907322e1e0eec6a6745ca3cea19291c6f9f50117bb7ea \
|
--hash=sha256:0e1e5b73a445fe82d40907322e1e0eec6a6745ca3cea19291c6f9f50117bb7ea \
|
||||||
@ -77,7 +80,8 @@ gevent==1.4.0 \
|
|||||||
--hash=sha256:ab4dc33ef0e26dc627559786a4fba0c2227f125db85d970abbf85b77506b3f51 \
|
--hash=sha256:ab4dc33ef0e26dc627559786a4fba0c2227f125db85d970abbf85b77506b3f51 \
|
||||||
--hash=sha256:d1e6d1f156e999edab069d79d890859806b555ce4e4da5b6418616322f0a3df1 \
|
--hash=sha256:d1e6d1f156e999edab069d79d890859806b555ce4e4da5b6418616322f0a3df1 \
|
||||||
--hash=sha256:d752bcf1b98174780e2317ada12013d612f05116456133a6acf3e17d43b71f05 \
|
--hash=sha256:d752bcf1b98174780e2317ada12013d612f05116456133a6acf3e17d43b71f05 \
|
||||||
--hash=sha256:e5bcc4270671936349249d26140c267397b7b4b1381f5ec8b13c53c5b53ab6e1
|
--hash=sha256:e5bcc4270671936349249d26140c267397b7b4b1381f5ec8b13c53c5b53ab6e1 \
|
||||||
|
# via -r requirements.in
|
||||||
greenlet==0.4.15 \
|
greenlet==0.4.15 \
|
||||||
--hash=sha256:000546ad01e6389e98626c1367be58efa613fa82a1be98b0c6fc24b563acc6d0 \
|
--hash=sha256:000546ad01e6389e98626c1367be58efa613fa82a1be98b0c6fc24b563acc6d0 \
|
||||||
--hash=sha256:0d48200bc50cbf498716712129eef819b1729339e34c3ae71656964dac907c28 \
|
--hash=sha256:0d48200bc50cbf498716712129eef819b1729339e34c3ae71656964dac907c28 \
|
||||||
@ -103,15 +107,14 @@ idna==2.7 \
|
|||||||
--hash=sha256:156a6814fb5ac1fc6850fb002e0852d56c0c8d2531923a51032d1b70760e186e \
|
--hash=sha256:156a6814fb5ac1fc6850fb002e0852d56c0c8d2531923a51032d1b70760e186e \
|
||||||
--hash=sha256:684a38a6f903c1d71d6d5fac066b58d7768af4de2b832e426ec79c30daa94a16 \
|
--hash=sha256:684a38a6f903c1d71d6d5fac066b58d7768af4de2b832e426ec79c30daa94a16 \
|
||||||
# via requests
|
# via requests
|
||||||
ifaddr==0.1.6 \
|
|
||||||
--hash=sha256:c19c64882a7ad51a394451dabcbbed72e98b5625ec1e79789924d5ea3e3ecb93
|
|
||||||
itsdangerous==1.1.0 \
|
itsdangerous==1.1.0 \
|
||||||
--hash=sha256:321b033d07f2a4136d3ec762eac9f16a10ccd60f53c0c91af90217ace7ba1f19 \
|
--hash=sha256:321b033d07f2a4136d3ec762eac9f16a10ccd60f53c0c91af90217ace7ba1f19 \
|
||||||
--hash=sha256:b12271b2047cb23eeb98c8b5622e2e5c5e9abd9784a153e9d8ef9cb4dd09d749 \
|
--hash=sha256:b12271b2047cb23eeb98c8b5622e2e5c5e9abd9784a153e9d8ef9cb4dd09d749 \
|
||||||
# via flask
|
# via flask
|
||||||
jinja2==2.11.1 \
|
jinja2==2.11.1 \
|
||||||
--hash=sha256:93187ffbc7808079673ef52771baa950426fd664d3aad1d0fa3e95644360e250 \
|
--hash=sha256:93187ffbc7808079673ef52771baa950426fd664d3aad1d0fa3e95644360e250 \
|
||||||
--hash=sha256:b0eaf100007721b5c16c1fc1eecb87409464edc10469ddc9a22a27a99123be49
|
--hash=sha256:b0eaf100007721b5c16c1fc1eecb87409464edc10469ddc9a22a27a99123be49 \
|
||||||
|
# via -r requirements.in, flask
|
||||||
markupsafe==1.1.1 \
|
markupsafe==1.1.1 \
|
||||||
--hash=sha256:00bc623926325b26bb9605ae9eae8a215691f33cae5df11ca5424f06f2d1f473 \
|
--hash=sha256:00bc623926325b26bb9605ae9eae8a215691f33cae5df11ca5424f06f2d1f473 \
|
||||||
--hash=sha256:09027a7803a62ca78792ad89403b1b7a73a01c8cb65909cd876f7fcebd79b161 \
|
--hash=sha256:09027a7803a62ca78792ad89403b1b7a73a01c8cb65909cd876f7fcebd79b161 \
|
||||||
@ -142,9 +145,14 @@ markupsafe==1.1.1 \
|
|||||||
--hash=sha256:cd5df75523866410809ca100dc9681e301e3c27567cf498077e8551b6d20e42f \
|
--hash=sha256:cd5df75523866410809ca100dc9681e301e3c27567cf498077e8551b6d20e42f \
|
||||||
--hash=sha256:e249096428b3ae81b08327a63a485ad0878de3fb939049038579ac0ef61e17e7 \
|
--hash=sha256:e249096428b3ae81b08327a63a485ad0878de3fb939049038579ac0ef61e17e7 \
|
||||||
# via jinja2
|
# via jinja2
|
||||||
|
mimcvdf==0.0.0 \
|
||||||
|
--hash=sha256:3a0fe81794a3e14cdc736cb3b700013a6f0526eed982d06fb0a5e5391ac2b945 \
|
||||||
|
--hash=sha256:c15f0d8d81900a3eead1f77725c5d05b119d57c3e66b7b14cbf5c122b9627b26 \
|
||||||
|
# via -r requirements.in
|
||||||
niceware==0.2.1 \
|
niceware==0.2.1 \
|
||||||
--hash=sha256:0f8b192f2a1e800e068474f6e208be9c7e2857664b33a96f4045340de4e5c69c \
|
--hash=sha256:0f8b192f2a1e800e068474f6e208be9c7e2857664b33a96f4045340de4e5c69c \
|
||||||
--hash=sha256:cf2dc0e1567d36d067c61b32fed0f1b9c4534ed511f9eeead4ba548d03b5c9eb
|
--hash=sha256:cf2dc0e1567d36d067c61b32fed0f1b9c4534ed511f9eeead4ba548d03b5c9eb \
|
||||||
|
# via -r requirements.in
|
||||||
psutil==5.7.0 \
|
psutil==5.7.0 \
|
||||||
--hash=sha256:1413f4158eb50e110777c4f15d7c759521703bd6beb58926f1d562da40180058 \
|
--hash=sha256:1413f4158eb50e110777c4f15d7c759521703bd6beb58926f1d562da40180058 \
|
||||||
--hash=sha256:298af2f14b635c3c7118fd9183843f4e73e681bb6f01e12284d4d70d48a60953 \
|
--hash=sha256:298af2f14b635c3c7118fd9183843f4e73e681bb6f01e12284d4d70d48a60953 \
|
||||||
@ -156,7 +164,8 @@ psutil==5.7.0 \
|
|||||||
--hash=sha256:d008ddc00c6906ec80040d26dc2d3e3962109e40ad07fd8a12d0284ce5e0e4f8 \
|
--hash=sha256:d008ddc00c6906ec80040d26dc2d3e3962109e40ad07fd8a12d0284ce5e0e4f8 \
|
||||||
--hash=sha256:d84029b190c8a66a946e28b4d3934d2ca1528ec94764b180f7d6ea57b0e75e26 \
|
--hash=sha256:d84029b190c8a66a946e28b4d3934d2ca1528ec94764b180f7d6ea57b0e75e26 \
|
||||||
--hash=sha256:e2d0c5b07c6fe5a87fa27b7855017edb0d52ee73b71e6ee368fae268605cc3f5 \
|
--hash=sha256:e2d0c5b07c6fe5a87fa27b7855017edb0d52ee73b71e6ee368fae268605cc3f5 \
|
||||||
--hash=sha256:f344ca230dd8e8d5eee16827596f1c22ec0876127c28e800d7ae20ed44c4b310
|
--hash=sha256:f344ca230dd8e8d5eee16827596f1c22ec0876127c28e800d7ae20ed44c4b310 \
|
||||||
|
# via -r requirements.in
|
||||||
pycparser==2.19 \
|
pycparser==2.19 \
|
||||||
--hash=sha256:a988718abfad80b6b157acce7bf130a30876d27603738ac39f140993246b25b3 \
|
--hash=sha256:a988718abfad80b6b157acce7bf130a30876d27603738ac39f140993246b25b3 \
|
||||||
# via cffi
|
# via cffi
|
||||||
@ -179,30 +188,38 @@ pynacl==1.3.0 \
|
|||||||
--hash=sha256:aabb0c5232910a20eec8563503c153a8e78bbf5459490c49ab31f6adf3f3a415 \
|
--hash=sha256:aabb0c5232910a20eec8563503c153a8e78bbf5459490c49ab31f6adf3f3a415 \
|
||||||
--hash=sha256:bd4ecb473a96ad0f90c20acba4f0bf0df91a4e03a1f4dd6a4bdc9ca75aa3a715 \
|
--hash=sha256:bd4ecb473a96ad0f90c20acba4f0bf0df91a4e03a1f4dd6a4bdc9ca75aa3a715 \
|
||||||
--hash=sha256:e2da3c13307eac601f3de04887624939aca8ee3c9488a0bb0eca4fb9401fc6b1 \
|
--hash=sha256:e2da3c13307eac601f3de04887624939aca8ee3c9488a0bb0eca4fb9401fc6b1 \
|
||||||
--hash=sha256:f67814c38162f4deb31f68d590771a29d5ae3b1bd64b75cf232308e5c74777e0
|
--hash=sha256:f67814c38162f4deb31f68d590771a29d5ae3b1bd64b75cf232308e5c74777e0 \
|
||||||
|
# via -r requirements.in
|
||||||
pysocks==1.7.1 \
|
pysocks==1.7.1 \
|
||||||
--hash=sha256:08e69f092cc6dbe92a0fdd16eeb9b9ffbc13cadfe5ca4c7bd92ffb078b293299 \
|
--hash=sha256:08e69f092cc6dbe92a0fdd16eeb9b9ffbc13cadfe5ca4c7bd92ffb078b293299 \
|
||||||
--hash=sha256:2725bd0a9925919b9b51739eea5f9e2bae91e83288108a9ad338b2e3a4435ee5 \
|
--hash=sha256:2725bd0a9925919b9b51739eea5f9e2bae91e83288108a9ad338b2e3a4435ee5 \
|
||||||
--hash=sha256:3f8804571ebe159c380ac6de37643bb4685970655d3bba243530d6558b799aa0
|
--hash=sha256:3f8804571ebe159c380ac6de37643bb4685970655d3bba243530d6558b799aa0 \
|
||||||
|
# via -r requirements.in
|
||||||
requests==2.23.0 \
|
requests==2.23.0 \
|
||||||
--hash=sha256:43999036bfa82904b6af1d99e4882b560e5e2c68e5c4b0aa03b655f3d7d73fee \
|
--hash=sha256:43999036bfa82904b6af1d99e4882b560e5e2c68e5c4b0aa03b655f3d7d73fee \
|
||||||
--hash=sha256:b3f43d496c6daba4493e7c431722aeb7dbc6288f52a6e04e7b6023b0247817e6
|
--hash=sha256:b3f43d496c6daba4493e7c431722aeb7dbc6288f52a6e04e7b6023b0247817e6 \
|
||||||
|
# via -r requirements.in, streamedrequests
|
||||||
six==1.12.0 \
|
six==1.12.0 \
|
||||||
--hash=sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c \
|
--hash=sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c \
|
||||||
--hash=sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73 \
|
--hash=sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73 \
|
||||||
# via pynacl
|
# via pynacl
|
||||||
stem==1.8.0 \
|
stem==1.8.0 \
|
||||||
--hash=sha256:a0b48ea6224e95f22aa34c0bc3415f0eb4667ddeae3dfb5e32a6920c185568c2
|
--hash=sha256:a0b48ea6224e95f22aa34c0bc3415f0eb4667ddeae3dfb5e32a6920c185568c2 \
|
||||||
|
# via -r requirements.in
|
||||||
streamedrequests==1.0.0 \
|
streamedrequests==1.0.0 \
|
||||||
--hash=sha256:1d9d07394804a6e1fd66bde74a804e71cab98e6920053865574a459f1cf7d3b7
|
--hash=sha256:1d9d07394804a6e1fd66bde74a804e71cab98e6920053865574a459f1cf7d3b7 \
|
||||||
|
# via -r requirements.in
|
||||||
toomanyobjs==1.1.0 \
|
toomanyobjs==1.1.0 \
|
||||||
--hash=sha256:99e27468f9dad19127be9e2fb086b42acd69aed9ad7e63cef74d6e4389be0534
|
--hash=sha256:99e27468f9dad19127be9e2fb086b42acd69aed9ad7e63cef74d6e4389be0534 \
|
||||||
|
# via -r requirements.in
|
||||||
unpaddedbase32==0.2.0 \
|
unpaddedbase32==0.2.0 \
|
||||||
--hash=sha256:4aacee75f8fd6c8cf129842ecba45ca59c11bfb13dae19d86f32b48fa3715403 \
|
--hash=sha256:4aacee75f8fd6c8cf129842ecba45ca59c11bfb13dae19d86f32b48fa3715403 \
|
||||||
--hash=sha256:b7b780c31d27d55e66abf6c221216a35690ee8892c2daacff7f2528e229bd9c3
|
--hash=sha256:b7b780c31d27d55e66abf6c221216a35690ee8892c2daacff7f2528e229bd9c3 \
|
||||||
|
# via -r requirements.in
|
||||||
urllib3==1.25.8 \
|
urllib3==1.25.8 \
|
||||||
--hash=sha256:2f3db8b19923a873b3e5256dc9c2dedfa883e33d87c690d9c7913e1f40673cdc \
|
--hash=sha256:2f3db8b19923a873b3e5256dc9c2dedfa883e33d87c690d9c7913e1f40673cdc \
|
||||||
--hash=sha256:87716c2d2a7121198ebcb7ce7cccf6ce5e9ba539041cfbaeecfb641dc0bf6acc
|
--hash=sha256:87716c2d2a7121198ebcb7ce7cccf6ce5e9ba539041cfbaeecfb641dc0bf6acc \
|
||||||
|
# via -r requirements.in, requests
|
||||||
werkzeug==0.15.5 \
|
werkzeug==0.15.5 \
|
||||||
--hash=sha256:87ae4e5b5366da2347eb3116c0e6c681a0e939a33b2805e2c0cbd282664932c4 \
|
--hash=sha256:87ae4e5b5366da2347eb3116c0e6c681a0e939a33b2805e2c0cbd282664932c4 \
|
||||||
--hash=sha256:a13b74dd3c45f758d4ebdb224be8f1ab8ef58b3c0ffc1783a8c7d9f4f50227e6 \
|
--hash=sha256:a13b74dd3c45f758d4ebdb224be8f1ab8ef58b3c0ffc1783a8c7d9f4f50227e6 \
|
||||||
|
@ -1,26 +1,44 @@
|
|||||||
|
"""Onionr - Private P2P Communication.
|
||||||
|
|
||||||
|
Identify LAN ip addresses and determine the best one
|
||||||
|
"""
|
||||||
from ipaddress import IPv4Address
|
from ipaddress import IPv4Address
|
||||||
|
|
||||||
from ifaddr import get_adapters
|
from psutil import net_if_addrs
|
||||||
|
from socket import AF_INET
|
||||||
|
"""
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
"""
|
||||||
|
|
||||||
lan_ips = []
|
lan_ips = []
|
||||||
|
|
||||||
for adapter in get_adapters():
|
# https://psutil.readthedocs.io/en/latest/#psutil.net_if_addrs
|
||||||
for ip in adapter.ips:
|
for interface in net_if_addrs().keys():
|
||||||
ip = ip.ip
|
for address in net_if_addrs()[interface]:
|
||||||
try:
|
# Don't see benefit in ipv6, so just check for v4 addresses
|
||||||
ip = IPv4Address(ip)
|
if address[0] == AF_INET:
|
||||||
if not ip.is_private or ip.is_loopback:
|
# Mark the address for use in LAN if it is a private address
|
||||||
raise ValueError
|
if IPv4Address(address[1]).is_private:
|
||||||
except ValueError:
|
lan_ips.append(address[1])
|
||||||
# Raised if not ipv4 or not link local
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
lan_ips.append(ip.exploded)
|
|
||||||
|
|
||||||
|
# These are more likely to be actual local subnets rather than VPNs
|
||||||
for ip in lan_ips:
|
for ip in lan_ips:
|
||||||
if '192.168' in ip:
|
if '192.168' in ip:
|
||||||
best_ip = ip
|
best_ip = ip
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
best_ip = lan_ips[0]
|
try:
|
||||||
|
best_ip = lan_ips[0]
|
||||||
|
except IndexError:
|
||||||
|
best_ip = ""
|
||||||
|
@ -9,7 +9,7 @@ print("Test directory:", TEST_DIR)
|
|||||||
os.environ["ONIONR_HOME"] = TEST_DIR
|
os.environ["ONIONR_HOME"] = TEST_DIR
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from lan.getip import lan_ips
|
from lan.getip import lan_ips, best_ip
|
||||||
|
|
||||||
class TestGetLanIps(unittest.TestCase):
|
class TestGetLanIps(unittest.TestCase):
|
||||||
def test_get_lan_ips(self):
|
def test_get_lan_ips(self):
|
||||||
@ -19,5 +19,11 @@ class TestGetLanIps(unittest.TestCase):
|
|||||||
if not ip.is_private or ip.is_multicast or ip.is_reserved:
|
if not ip.is_private or ip.is_multicast or ip.is_reserved:
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
|
def test_best_lan_ip(self):
|
||||||
|
ip = best_ip
|
||||||
|
ip = ipaddress.IPv4Address(ip)
|
||||||
|
if not ip.is_private or ip.is_multicast or ip.is_reserved:
|
||||||
|
raise ValueError
|
||||||
|
|
||||||
|
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Loading…
Reference in New Issue
Block a user