import os, json, subprocess from warehouse import http_get, Vpn_cache if "wg" in subprocess.run(["ip","link"], capture_output=True, text=True).stdout: if not os.path.exists(Vpn_cache) or os.path.getsize(Vpn_cache) == 0: try: ip = http_get("https://icanhazip.com").strip() res = json.loads(http_get(f"https://iplookup.stab.ing/api/v1/lookup?ip={ip}"))["country"] except: res = "NAY!" open(Vpn_cache, "w").write(res) print(f"VPN: {open(Vpn_cache).read()} / ", end="") else: try: os.remove(Vpn_cache) except: pass print("", end="")