75 lines
2.1 KiB
Python
75 lines
2.1 KiB
Python
import random
|
|
import threading
|
|
import time
|
|
|
|
from loguru import logger
|
|
from curl_cffi import requests
|
|
|
|
from models.tg_phone_devices import TgPhoneDevices
|
|
|
|
headers = {
|
|
'accept': 'application/json, text/plain, */*',
|
|
'accept-language': 'zh-HK,zh;q=0.9',
|
|
'cache-control': 'no-cache',
|
|
'content-type': 'application/json',
|
|
'origin': 'https://micro-node.alliancegames.xyz',
|
|
'pragma': 'no-cache',
|
|
'priority': 'u=1, i',
|
|
'referer': 'https://micro-node.alliancegames.xyz/',
|
|
'sec-ch-ua': '"Chromium";v="130", "Google Chrome";v="130", "Not?A_Brand";v="99"',
|
|
'sec-ch-ua-mobile': '?0',
|
|
'sec-ch-ua-platform': '"Windows"',
|
|
'sec-fetch-dest': 'empty',
|
|
'sec-fetch-mode': 'cors',
|
|
'sec-fetch-site': 'same-site',
|
|
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36',
|
|
}
|
|
|
|
|
|
def main(port):
|
|
proxies = {
|
|
"http": f"http://192.168.11.30:{port}",
|
|
"https": f"http://192.168.11.30:{port}",
|
|
}
|
|
|
|
# try:
|
|
# ip_text = requests.get('https://httpbin.org/ip', headers=headers, proxies=proxies).json()["origin"]
|
|
# except:
|
|
# return
|
|
|
|
tg_phone_infos = TgPhoneDevices.select().where(
|
|
TgPhoneDevices.is_valid_session.is_null(False)
|
|
)
|
|
|
|
if tg_phone_infos:
|
|
for tg_phone in tg_phone_infos:
|
|
tg_phone.proxy_type = "http"
|
|
tg_phone.addr = "192.168.11.30"
|
|
tg_phone.port = port
|
|
tg_phone.user = None
|
|
tg_phone.pwd = None
|
|
|
|
tg_phone.save()
|
|
logger.info(f"{tg_phone},修改代理成功!!!")
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
# for i in range(20001, 25000):
|
|
# threading.Thread(target=main, args=(i,)).start()
|
|
# time.sleep(0.1)
|
|
|
|
tg_phone_infos = TgPhoneDevices.select().where(
|
|
TgPhoneDevices.is_valid_session == 4
|
|
)
|
|
|
|
for tg_phone in tg_phone_infos:
|
|
tg_phone.proxy_type = "http"
|
|
tg_phone.addr = "192.168.11.30"
|
|
tg_phone.port = random.randint(20001, 25000)
|
|
tg_phone.user = None
|
|
tg_phone.pwd = None
|
|
|
|
tg_phone.save()
|
|
logger.info(f"{tg_phone},修改代理成功!!!")
|