-
Notifications
You must be signed in to change notification settings - Fork 0
/
arukasQuery.py
47 lines (36 loc) · 1.34 KB
/
arukasQuery.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# coding=utf-8
'''
Arukas will randomly restart the apps that exceed the usage limitations set for free accounts, after which the app's service port and ip will be changed.
This script helps to retrieve arukas app's ip and port, and forward to serverChan(http://sc.ftqq.com/).
Since app.arukas.io is blocked, one might as deploy this in a VPS and use cron or any scheduled tasking mechanism to poll the info.
Fill in the parameters in the header first.
'''
import requests as r
import os
#parameters
apiID='arukas TOKEN'
apikey='arukas SECRET'
portorder=-1
serverchanTOKEN='serverchanTOKEN'
while True:
try:
a=r.get('https://app.arukas.io/api/apps',auth=(apiID,apikey))
c = a.json()['included'][0]['attributes']['port-mappings'][0][portorder]
break
except:
continue
addr='{}{}'.format(c['host'],c['service-port'])
if os.path.exists('/arukas.txt'):
f=open('/arukas.txt','r+')
if f.readline() !=addr:
response = r.get('https://sc.ftqq.com/{}.send'.format(serverchanTOKEN),
{'text': 'ARUKAS ALARM', 'desp': addr})
f.truncate(0)
f.write(addr)
f.close()
else:
f = open('/arukas.txt', 'w')
f.write(addr)
f.close()
response = r.get('https://sc.ftqq.com/{}.send'.format(serverchanTOKEN),
{'text': 'ARUKAS ALARM', 'desp': addr})