Created
December 13, 2017 02:28
-
-
Save xorb0ss/f41f10dfd7f7bf22c85b88a31fa79909 to your computer and use it in GitHub Desktop.
VPN connection rotator
This file contains hidden or 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
# requirements: python-gobject | |
# this hacky little code rotates your VPN connection using openvpn every 3 hours. | |
# its nasty but does the job | |
import time, random, requests | |
from json import loads | |
from subprocess import Popen | |
from gi.repository import Notify | |
Notify.init("VPN rotate") | |
summary = "Rotating VPN connection..." | |
# vpn config files | |
vpn_conns = ["first.ovpn", "second.ovpn", "..."] | |
while 1: | |
randvpn = vpn_conns[random.randrange(0, len(vpn_conns))] | |
cmd = "sudo openvpn " + randvpn | |
p = Popen(cmd, shell = True) | |
time.sleep(20) | |
host = loads(requests.get("http://ifconfig.co/json").content) | |
body = "Country: " + str(host['country']) + " | IP: " + str(host['ip']) | |
notification = Notify.Notification.new(summary, body) | |
notification.show() | |
time.sleep(10800) | |
p.kill() | |
time.sleep(5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment