Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #103522

Re: Testing whether the VPN is running?

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Dan Stromberg <drsalists@gmail.com>
Newsgroups comp.lang.python
Subject Re: Testing whether the VPN is running?
Date Thu, 25 Feb 2016 15:01:22 -0800
Lines 31
Message-ID <mailman.137.1456441753.20994.python-list@python.org> (permalink)
References <2cfgpcxdg2.ln2@news.ducksburg.com> <20160218094531.GA5510@arxnet.hu>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
X-Trace news.uni-berlin.de Ki2nwkbrptTNQfIYKoXQQQmeeY3Qg1xqTT/xbPdQrN0g==
Return-Path <drsalists@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'url:pypi': 0.03; 'anyway.': 0.04; 'cc:addr:python-list': 0.09; 'python': 0.10; 'output': 0.13; 'section.': 0.15; 'thu,': 0.15; '2016': 0.16; 'adam': 0.16; 'cc:name:python list': 0.16; 'command,': 0.16; 'modul': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subprocess': 0.16; 'task:': 0.16; 'vpn': 0.16; 'wrote:': 0.16; 'cc:addr:python.org': 0.20; 'cc:2**1': 0.22; 'keywords,': 0.22; 'am,': 0.23; 'feb': 0.23; 'header:In-Reply-To:1': 0.24; 'module': 0.25; "doesn't": 0.26; 'linux': 0.26; 'not.': 0.27; 'message- id:@mail.gmail.com': 0.27; 'host': 0.28; 'way?': 0.29; "i'm": 0.30; "i'd": 0.31; 'probably': 0.31; 'run': 0.33; 'url:python': 0.33; 'accessible': 0.33; 'running': 0.34; 'that,': 0.34; 'received:google.com': 0.35; 'behind': 0.35; 'could': 0.35; 'but': 0.36; 'should': 0.36; 'there': 0.36; 'url:org': 0.36; 'received:209.85': 0.36; 'possible': 0.36; 'hosted': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'mac': 0.37; 'received:209': 0.38; 'stuff': 0.38; 'test': 0.39; 'subject:the': 0.39; "didn't": 0.39; 'received:209.85.214': 0.39; 'still': 0.40; 'some': 0.40; 'mac.': 0.84; 'subject:Testing': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=NeWZ2p20ZuJD+k6tGqH7SvGx3gkoV81s+zJFeHuyinU=; b=F+U697H1PAtLU8jTfCfbhPQRJCatnPBLz6NwNTJ5KBwdA5h0lunJgYksfVNRMzuVPR KYKtmcg9LBzyx0b7+BchajIMgnrz/C2LGX4uod8tHljfNe3XucrJbcFmv/YmgppMSqZz bfxntzBmQrJReIr7li51WJwZzeNwc7FddCittuYqWv3Yt/sakm09/Xh97QgMI+5XHTOr DZEoBSelasWzAyfxAyPwIczgXOtR+nvwRWxxDdYp7/ITmJ1Aid4dQSCPQTVo6JwF041C QMAfnHYGc7tUYf88f5sHwPwLX/XpzXn8ycED5WZLOZt6zbo1dryA/m3TKFkvFzoyrN6B DZzA==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=NeWZ2p20ZuJD+k6tGqH7SvGx3gkoV81s+zJFeHuyinU=; b=SgLAb98PRiOurNEa/JLPtpY+n30/9P/BVjoLtFxiIdkoMMOWvqiN8BmYwYlLIRxgsI fm2DIyalXl1z9f/OcYSpwGg24LpkjRoB5/qYLfT0BNVRau570e+amsBZpu6QauH4AO6S nQtH3bqstVsilVXarNznQCFVsi0mm0RCKqn1pfNXeuiCRytP5kzvk8hxzk6MuT8f7hUb QJVXUr4pajxqBXX0enfxQ+PTipnefDft+3qrn1jl0RBVcqA67EkXSKyF491SoKN/vddv zPpRpC0SJ6Gd1BJ7wKjWtB3tbB7ILC2yNdnHx3HJ0PhLGbBdjYCv1qxwoZgahfYT2BcJ 94eA==
X-Gm-Message-State AG10YOT7aSvVLyRCZ/f8kUUQLssNy9w2enIH+4Uv/EkOo4W+p09qUETU9IMX+DeMItepRf21eg8i5zZvcqNi6w==
X-Received by 10.60.144.9 with SMTP id si9mr40715556oeb.81.1456441282671; Thu, 25 Feb 2016 15:01:22 -0800 (PST)
In-Reply-To <20160218094531.GA5510@arxnet.hu>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.21rc2
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:103522

Show key headers only | View raw


On Thu, Feb 18, 2016 at 1:45 AM, Ervin Hegedüs <airween@gmail.com> wrote:
> Hi Adam,
>
> On Thu, Feb 18, 2016 at 09:26:58AM +0000, Adam Funk wrote:
>> I'd like to test (inside a python 3 program) whether the VPN is
>> running or not.  The only thing I can think of so far is to use
>> subprocess to run the 'ifconfig' command, then check its output for
>> 'tun0'.  Is there a better way?
>
> you didn't wrote, which system (OS) you want to use - based on
> the "ifconfig" and "tun0" keywords, possible that's a Linux.
>
> 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.

psutil is probably clean on Linux.

However, using the subprocess module to run ifconfig -a and check for
tun0 / utun0 should get you compatibility with both Linux and Mac.

Note that if I'm running a Linux in a VMware, and it's hosted on a
Mac, and the Mac has one of my VPN's up, then the Linux doesn't have a
tun0, but it can still see stuff only accessible via that VPN.

For that, it might be better to try ping'ing some host that's behind
the VPN.  In a way, that's a better test anyway.

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


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