Skip to main content

No project description provided

Project description

Netswitch

Network switching. Make sure you're connecting with the priority that you want.

Works on Linux (relies on wpa_supplicant)

Install

pip install netswitch

Usage

Network Switching

import time
import netswitch

netswitch.sync_aps('path/to/aps')

switch = netswitch.NetSwitch([
    {'interface': 'wlan*', 'ssids': 'lifeline'},
    'eth*',  # equivalent to {'interface': 'eth*'}
    'ppp*',
    {'interface': 'wlan*'},  # implied - 'ssids': '*'
])

while True:
    time.sleep(10)
    connected = switch.check()
# or equivalently
switch.run(interval=10)

For example, assume your setup is:

  • ifaces: wlan0 (built-in Pi 4 wifi), wlan1 (usb wifi dongle), ppp0 (cellular)
  • trusted ssids: nyu, nyu-legacy

Procedure - at any point in these steps, if we connect, we're finished:

  • check wlan1 for s0nycL1f3l1ne, if yes, connect
  • check wlan0 for s0nycL1f3l1ne, if yes, connect
  • check for eth0 and internet connected thru interface
  • check for ppp0 and internet connected thru interface
    • should we control wvdial or whatevs in this ???
  • check wlan1 for [nyu, nyu-legacy], if yes, connect
  • check wlan0 for [nyu, nyu-legacy], if yes, connect
  • check if internet is already connected thru any interface

TODO

  • tests - .travis.yml
  • eth0 connection, ppp0 connection
  • /etc/network/interfaces setup? / instructions?
  • restart interface if it's missing / not connected? maybe only 0, or if it showed up once?
  • time since connected - restart after a certain amount of time.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

netswitch-0.0.3.tar.gz (6.8 kB view details)

Uploaded Source

File details

Details for the file netswitch-0.0.3.tar.gz.

File metadata

  • Download URL: netswitch-0.0.3.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/49.2.0.post20200714 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.7

File hashes

Hashes for netswitch-0.0.3.tar.gz
Algorithm Hash digest
SHA256 d8a06c0dafa056c7286be3a57ca7c61b1f8c4406a8e0afb274ca0250702eea2b
MD5 589f59d9b81e17b76ffa0043d1022148
BLAKE2b-256 0daa60e1b1511eb1bd1bb95360db346898278e1198a0e4508d8f3d6a01ce3bb8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page