-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
96 lines (80 loc) · 2.77 KB
/
main.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# -*- coding: utf-8 -*-
import socket
import time
import datetime
import requests
# 邮箱
email = f'[email protected]'
# 密码
password = f'password'
# 使用了LeCDN的网站的url
url_website = f'https://cdn.kkccc.com'
# 你使用ddns的域名
domain = f'test1.haha44444.top'
# 端口
port = f'25565'
# 权重
weight = f'15'
# 更改转发列表中第x行的转发
# 0代表1,1代表2,以此类推,如果你只有一个转发保持默认即可
forward_list_row_x = f'0'
def get_token():
url = f'{url_website}/prod-api/login'
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0'
}
data = {
"email": email,
"password": password
}
session = requests.session()
res = session.post(url, data=data, headers=headers)
token = res.json()
return token['data']['access_token']
def get_stream_id():
url = f'{url_website}/prod-api/stream?listen_port=&cname=&stream_id=&status=¤t_page=1&total=0&page_size=10'
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0',
'Authorization': f'Bearer {get_token()}'
}
session = requests.session()
res = session.get(url, headers=headers)
stream_id = res.json()['data']['data'][int(forward_list_row_x)]['id']
return stream_id
def get_id():
url = f'{url_website}/prod-api/stream_source?stream_id={get_stream_id()}'
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0',
'Authorization': f'Bearer {get_token()}'
}
session = requests.session()
res = session.get(url, headers=headers)
id = res.json()['data'][0]['id']
return id
def change_ip(ip):
url_put = f'{url_website}/prod-api/stream_source/{get_id()}'
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0',
'Authorization': f'Bearer {get_token()}'
}
data = {
'stream_id': get_stream_id(),
'content': ip,
'port': port,
'weight': weight,
'id': get_id()
}
session = requests.session()
res = session.put(url_put, headers=headers, data=data)
print(res)
def get_ipAddresses(domain):
ipAddresses = [0]
while True:
time.sleep(2)
ip = socket.gethostbyname(domain)
if ip != ipAddresses[-1]:
ipAddresses.append(ip)
print(str(datetime.datetime.now())[:19] + '===>' + ip)
change_ip(ip)
if __name__ == "__main__":
get_ipAddresses(domain)