Skip to content

Instantly share code, notes, and snippets.

@brunomsantiago
Created February 16, 2022 16:03
Show Gist options
  • Save brunomsantiago/578499afa21c2b923e37a0129159e425 to your computer and use it in GitHub Desktop.
Save brunomsantiago/578499afa21c2b923e37a0129159e425 to your computer and use it in GitHub Desktop.
Verify if connected to VPN based on local ip address
import socket
def my_ip():
hostname = socket.gethostname()
return socket.gethostbyname(hostname)
def on_vpn(ip: str, vpn_ip_begin='10.'):
return ip.startswith(vpn_ip_begin)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment