mirror of
https://github.com/markqvist/Reticulum.git
synced 2024-12-14 10:24:29 -05:00
Allow binding to IPv6 (if present)
If an interface has an IPv6 address record associated with it then, and only then, prefer that. Otherwise AF_INET is used (Ipv4 address)
This commit is contained in:
parent
d002a75f34
commit
f55004a574
@ -412,6 +412,11 @@ class TCPServerInterface(Interface):
|
|||||||
def get_address_for_if(name):
|
def get_address_for_if(name):
|
||||||
import RNS.vendor.ifaddr.niwrapper as netinfo
|
import RNS.vendor.ifaddr.niwrapper as netinfo
|
||||||
ifaddr = netinfo.ifaddresses(name)
|
ifaddr = netinfo.ifaddresses(name)
|
||||||
|
|
||||||
|
# IPv6 preference (if present)
|
||||||
|
if(netinfo.AF_INET6 in ifaddr):
|
||||||
|
return ifaddr[netinfo.AF_INET6][0]["addr"]
|
||||||
|
|
||||||
return ifaddr[netinfo.AF_INET][0]["addr"]
|
return ifaddr[netinfo.AF_INET][0]["addr"]
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
Loading…
Reference in New Issue
Block a user