Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Linux: Detect PPP as Internet connection (bug 1702)
PPP connections on Linux have state "UNKNOWN", and are
therefore not detected as such. We fix this now by assuming
that all "UNKNOWN" connections are actually working Internet
connections, and filter the loopback interface (which is also
an "UNKNOWN" connection).

Thanks to Sudaraka Wijesinghe for the bug report, initial
patch and testing/feedback.
  • Loading branch information
thp committed Nov 3, 2012
1 parent 632cd3b commit cdf27fe
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/gpodder/util.py
Expand Up @@ -1635,8 +1635,10 @@ def linux_get_active_interfaces():
empty list if the device is offline. The loopback
interface is not included.
"""
stdout = subprocess.check_output(['ip', 'link'])
return re.findall(r'\d+: ([^:]+):.*state UP', stdout)
data = subprocess.check_output(['ip', 'link'])
for interface, _ in re.findall(r'\d+: ([^:]+):.*state (UP|UNKNOWN)', data):
if interface != 'lo':
yield interface


def osx_get_active_interfaces():
Expand Down Expand Up @@ -1668,7 +1670,7 @@ def connection_available():
return len(list(osx_get_active_interfaces())) > 0
return True
else:
return len(linux_get_active_interfaces()) > 0
return len(list(linux_get_active_interfaces())) > 0
except Exception, e:
logger.warn('Cannot get connection status: %s', e, exc_info=True)
return False
Expand Down

0 comments on commit cdf27fe

Please sign in to comment.