Skip to content

Instantly share code, notes, and snippets.

@xorb0ss
Created December 13, 2017 02:28
Show Gist options
  • Save xorb0ss/f41f10dfd7f7bf22c85b88a31fa79909 to your computer and use it in GitHub Desktop.
Save xorb0ss/f41f10dfd7f7bf22c85b88a31fa79909 to your computer and use it in GitHub Desktop.
VPN connection rotator
# 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