Update sijapi.15s.py
This commit is contained in:
parent
ef43ebf37b
commit
a1e699b252
1 changed files with 5 additions and 2 deletions
|
@ -40,6 +40,8 @@ for old_script in glob.glob(os.path.join(temp_dir, 'swiftbar_vpn_*.sh')):
|
||||||
with open(config_yaml, 'r') as stream:
|
with open(config_yaml, 'r') as stream:
|
||||||
config = yaml.safe_load(stream)
|
config = yaml.safe_load(stream)
|
||||||
servers = config['POOL']
|
servers = config['POOL']
|
||||||
|
api_url = config['URL']
|
||||||
|
api_key = config['KEYS'][0]
|
||||||
|
|
||||||
def run_ssh_command(server, command):
|
def run_ssh_command(server, command):
|
||||||
ssh = paramiko.SSHClient()
|
ssh = paramiko.SSHClient()
|
||||||
|
@ -99,7 +101,7 @@ def check_postgres(ip, port, dbname, user, password):
|
||||||
|
|
||||||
def get_sij_id():
|
def get_sij_id():
|
||||||
try:
|
try:
|
||||||
response = requests.get("https://api.sij.ai/id?api_key=sk-NhrtQwCHNdK5sRZC", timeout=4)
|
response = requests.get(f"{api_url}/id?api_key={api_key}", timeout=4)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
return response.text.strip().strip('"')
|
return response.text.strip().strip('"')
|
||||||
except requests.exceptions.RequestException as e:
|
except requests.exceptions.RequestException as e:
|
||||||
|
@ -107,12 +109,13 @@ def get_sij_id():
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return "Unexpected Error"
|
return "Unexpected Error"
|
||||||
|
|
||||||
|
|
||||||
def flag_emoji(country_code):
|
def flag_emoji(country_code):
|
||||||
if country_code:
|
if country_code:
|
||||||
offset = 127397
|
offset = 127397
|
||||||
flag = ''.join([chr(ord(char) + offset) for char in country_code.upper()])
|
flag = ''.join([chr(ord(char) + offset) for char in country_code.upper()])
|
||||||
return flag
|
return flag
|
||||||
return flag_emoji('us') # American flag for no VPN
|
return flag_emoji('us')
|
||||||
|
|
||||||
def gather_remote_info(server):
|
def gather_remote_info(server):
|
||||||
vitals_output = run_ssh_command(server, f"bash -l -c '{server['vitals']}'")
|
vitals_output = run_ssh_command(server, f"bash -l -c '{server['vitals']}'")
|
||||||
|
|
Loading…
Reference in a new issue