Skip to content

Commit

Permalink
improve auto detection of IPv6 - try to check sysctl net.ipv6.conf.al…
Browse files Browse the repository at this point in the history
…l.disable_ipv6 (prefer value read from `/proc/sys/net/ipv6/conf/all/disable_ipv6`)
  • Loading branch information
sebres committed Jan 9, 2023
1 parent 58834b6 commit d8a9812
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions fail2ban/server/ipdns.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,13 @@ def getSelfIPs():
def _IPv6IsSupportedBySystem():
if not socket.has_ipv6:
return False
# try to check sysctl net.ipv6.conf.all.disable_ipv6:
try:
with open('/proc/sys/net/ipv6/conf/all/disable_ipv6', 'rb') as f:
# if 1 - disabled, 0 - enabled
return not int(f.read())
except:
pass
s = None
try:
# try to create INET6 socket:
Expand Down

0 comments on commit d8a9812

Please sign in to comment.