Created
February 16, 2022 16:03
-
-
Save brunomsantiago/578499afa21c2b923e37a0129159e425 to your computer and use it in GitHub Desktop.
Verify if connected to VPN based on local ip address
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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