Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #103397
| From | Cameron Simpson <cs@zip.com.au> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Testing whether the VPN is running? |
| Date | 2016-02-23 19:24 +1100 |
| Message-ID | <mailman.62.1456215889.20994.python-list@python.org> (permalink) |
| References | <8ghgpcxrd3.ln2@news.ducksburg.com> |
On 18Feb2016 10:03, Adam Funk <a24061@ducksburg.com> wrote: >On 2016-02-18, Ervin Hegedüs wrote: >> I think that the psutil modul could be better for you for this >> task: >> https://pypi.python.org/pypi/psutil/ >> >> and see the "Network" section. > >if 'tun0' in psutil.net_if_addrs(): > # vpn is running > >Brilliant! I've used psutil for something else, but I didn't know it >did that too. My excuse is that the version on my system was 2.2.1, >which does not do that, so I installed the newer version with pip3. >Thanks for pointing me to that. You might also want to check that the interface is up. My personal hack (not for a VPN, but for "being online", which turns my ssh tunnels on and off) is to look in the output of "netstat -rn" for a default route. This may imply that an alternative test for you is to test for a route to your VPN's address range? Just an idea. Cheers, Cameron Simpson <cs@zip.com.au>
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Testing whether the VPN is running? Adam Funk <a24061@ducksburg.com> - 2016-02-18 09:26 +0000
Re: Testing whether the VPN is running? Ervin Hegedüs <airween@gmail.com> - 2016-02-18 10:45 +0100
Re: Testing whether the VPN is running? Adam Funk <a24061@ducksburg.com> - 2016-02-18 10:03 +0000
Re: Testing whether the VPN is running? Cameron Simpson <cs@zip.com.au> - 2016-02-23 19:24 +1100
Re: Testing whether the VPN is running? Adam Funk <a24061@ducksburg.com> - 2016-02-25 13:25 +0000
Re: Testing whether the VPN is running? Gisle Vanem <gvanem@yahoo.no> - 2016-02-23 10:40 +0100
Re: Testing whether the VPN is running? Dan Stromberg <drsalists@gmail.com> - 2016-02-25 15:01 -0800
csiph-web