update<没啥好推的>

main
赤月未咲 9 months ago
commit 56a03a8b81

6
.gitignore vendored

@ -0,0 +1,6 @@
node_modules
*.spec
config.json
build
dist
@*

@ -0,0 +1,13 @@
# 自己搞的小东西
- 不建议使用,性能极差
- 如果你非要用
- 你可以使用下面的命令进行打包可在所有电脑运行
```python
pyinstaller --onefile main.py
```

@ -0,0 +1,139 @@
import requests
import re
import os
import time
import shutil
from requests.auth import HTTPProxyAuth
import socks
import socket
from requests.adapters import HTTPAdapter
from urllib3.util.retry import Retry
# 配置
url = "https://unpkg.com/"
headers = {'Accept-Language': 'zh-CN,zh;q=0.8',
'Content-Type': 'text/html;Charset=utf-8',
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36"
}
# 如果没有额外参数则输入
if not 'mod' in locals().keys():
mod = input("请输入模块名:")
if not 'version' in locals().keys():
version = input("请输入版本号:")
use_proxy = input("是否使用代理?(输入 'y''n': ").lower()
proxies = None # 初始化代理
if use_proxy == 'y':
# 获取代理设置
default_proxy_host = "10.10.50.114" # 设置默认代理主机
default_proxy_port = 65115 # 设置默认代理端口
proxy_host = input(f"请输入代理主机 (默认为 {default_proxy_host}): ") or default_proxy_host
proxy_port = int(input(f"请输入代理端口 (默认为 {default_proxy_port}): ") or default_proxy_port)
proxy_username = input("请输入代理用户名(如果不需要身份验证,直接回车): ")
proxy_password = input("请输入代理密码(如果不需要身份验证,直接回车): ")
# 设置 SOCKS5 代理
socks.set_default_proxy(socks.SOCKS5, proxy_host, proxy_port, True, proxy_username, proxy_password)
socket.socket = socks.socksocket
proxies = {'http': 'socks5://{}:{}'.format(proxy_host, proxy_port), 'https': 'socks5://{}:{}'.format(proxy_host, proxy_port)}
# 设置重试机制
def requests_retry_session(
retries=3,
backoff_factor=0.3,
status_forcelist=(500, 502, 504),
session=None,
):
session = session or requests.Session()
retry = Retry(
total=retries,
read=retries,
connect=retries,
backoff_factor=backoff_factor,
status_forcelist=status_forcelist,
)
adapter = HTTPAdapter(max_retries=retry)
session.mount('http://', adapter)
session.mount('https://', adapter)
return session
# 获取HTML
def getHTML(url, encoding='utf-8'):
try:
with requests_retry_session().get(url, params=None, headers=headers, proxies=proxies) as rd:
rd.encoding = encoding
rd.raise_for_status()
return rd.text
except requests.exceptions.RequestException as e:
print(f"获取HTML时发生错误: {e}")
return None
# 获取版本
def getVsions(m):
h = getHTML(url + m + '/')
j = re.findall(r'<select name="version"(.*?)</select>', h, re.S)[0]
patt = re.compile(r'<option.+?>(.+?)</option>')
option = patt.findall(j)
return option
# 扫描目录
def getPaths(v, p='/', files=[], folders=[]):
h = getHTML(url + v + p)
t = re.findall(r'<table(.*?)</table>', h, re.S)[0]
href = re.findall('href="(.*?)"', t)
for name in href:
path = p + name
if name in ['../', 'LICENSE'] or path in ['/src/', '/packages/', '/types/', '/dist/docs/', '/docs/',
'/samples/', "/test/", "/locale/"]: # 跳过
continue
print(path)
if name[-1] == '/':
folders.append(path)
getPaths(v, path, files, folders)
else:
files.append(path)
return {"files": files, "folders": folders}
# 创建目录
def makeDirs(dirs, p):
if p is None:
p = './'
for i in dirs:
path = p + i
if not os.path.exists(path):
print("创建目录", path)
os.makedirs(path)
# 下载文件
def download(url, path=None):
try:
with requests_retry_session().get(url, proxies=proxies) as r:
r.raise_for_status()
if not os.path.exists(path):
print("下载:", url)
t = str(time.time()) + '.' + str(os.getpid()) + '.tmp'
open(t, 'wb').write(r.content)
shutil.move(t, path)
else:
print("文件已存在")
except requests.exceptions.RequestException as e:
print(f"下载文件时发生错误: {e}")
# 其余的代码getVsions, getPaths, makeDirs, 等等)
pid = os.getpid()
print(url + mod + '/')
versions = getVsions(mod)
print("所有版本:", versions)
version = mod + '@' + versions[-1]
print("默认版本:", version)
paths = getPaths(version)
makeDirs(paths["folders"], version)
for i in paths["files"]:
u = url + version + i
download(u, version + '/' + i)
print("完成")

@ -0,0 +1,11 @@
# 用于dnspod公共DNS绑定
- 自带拦截规则
- 支持电脑的53端口直接用
- 相应快
- 每月300万次请求/FREE
- 个人用完全足够,但多人就不行了
## 该项目有什么用
本项目通过监听本机IP变动进行主动绑定保持规则可用性

@ -0,0 +1,54 @@
import requests
import time
import json
def get_current_ip():
try:
response = requests.get("https://archive.lolicon.team/api/center/ipsee/")
data = response.json()
print("API响应", data) # 打印完整的API响应
return data["ip"]
except KeyError:
print("API返回的JSON格式不正确未找到'ip'键。")
return None
except Exception as e:
print(f"发生错误:{e}")
return None
def perform_action(ip):
if ip is not None:
# 执行你的操作,访问 https://link.dns.pub/
# 你可以使用 requests.get() 或其他适当的方法
url = "https://link.dns.pub/"
try:
response = requests.get(url)
# 在这里可以添加处理响应的代码,例如检查状态码、打印内容等
print(f"执行操作,访问 {url}当前IP: {ip}")
except Exception as e:
print(f"执行操作时发生错误:{e}")
else:
print("无法获取有效的IP地址跳过执行操作。")
def main():
current_ip = get_current_ip()
# 初始操作
perform_action(current_ip)
while True:
time.sleep(120)
new_ip = get_current_ip()
if new_ip is not None and new_ip != current_ip:
print("IP 已更改,执行操作")
# 执行操作
perform_action(new_ip)
current_ip = new_ip
else:
print("IP 未更改,继续等待")
if __name__ == "__main__":
main()

@ -0,0 +1,49 @@
# 用于监听本机网络波动
- 监测网络波动
- URL传输到服务器数据库中存储日志
- 可本地文件存储
- 仅检测
## 该项目有什么用
方便投诉你的运营商,让其网络保持稳定
## 如何使用
所需环境`ping3`
```python
pip install ping3
```
你需要准备一个`config.json`
```json
{
"target_ips": {
"需要ping的IP": {"location": "位置", "threshold_ms": 设置阈值, "log_method": "触发"},
"需要ping的IP": {"location": "位置", "threshold_ms": 设置阈值, "log_method": "触发"},
"需要ping的IP": {"location": "位置", "threshold_ms": 设置阈值, "log_method": "触发"}
}
}
```
示例
```json
{
"target_ips": {
"10.10.50.1": {"location": "Home", "threshold_ms": 10, "log_method": "url"},
"10.10.51.1": {"location": "Home2", "threshold_ms": 30, "log_method": "url"},
"10.10.92.1": {"location": "Home3", "threshold_ms": 100, "log_method": "url"}
}
}
```
阈值单位为MS请根据你的网络环境进行调整
超出该阈值时则触发条件
log_method`file`,`url`,`console`

@ -0,0 +1,65 @@
import time
from ping3 import ping
import requests
import json
def load_config():
with open("config.json", "r") as config_file:
config_data = json.load(config_file)
return config_data["target_ips"]
def continuous_ping(ip_addresses):
while True:
for ip_address, data in ip_addresses.items():
location = data["location"]
threshold_ms = data["threshold_ms"]
log_method = data["log_method"]
delay = ping(ip_address)
if delay is not None:
print(f'Ping delay to {location} ({ip_address}): {delay * 1000:.2f} ms')
delay = int(delay * 1000)
else:
print(f'Ping to {location} ({ip_address}) failed.')
delay = 0 # 或者设定其他默认值
if delay is not None and delay > threshold_ms:
log_message = f'High latency detected for {location} ({ip_address})! Delay: {delay}ms'
if log_method == "file":
try:
with open(f'{location}_ping_log.txt', 'a') as log_file:
log_file.write(f'{time.strftime("%Y-%m-%d %H:%M:%S")}\t{ip_address}\t{delay}ms\n')
except Exception as e:
print(f'Error writing to file: {e}')
elif log_method == "console":
print(log_message)
elif log_method == "url":
target_url = "https://archive.lolicon.team/api/center/ping-logs/"
payload = {"location": location, "ip_address": ip_address, "delay": delay}
headers = {"Content-Type": "application/json"}
try:
response = requests.post(target_url, data=json.dumps(payload), headers=headers)
if response.status_code == 200:
print(f'Delay information sent to {target_url} successfully.')
else:
print(f'Failed to send delay information to {target_url}. Status code: {response.status_code}')
# 获取返回的 JSON 数据
try:
error_json = response.json()
print(f'Error JSON: {error_json}')
except json.JSONDecodeError:
print('Failed to decode error JSON.')
except Exception as e:
print(f'Error sending delay information to {target_url}: {e}')
else:
pass
time.sleep(1)
if __name__ == "__main__":
target_ips = load_config()
continuous_ping(target_ips)

@ -0,0 +1,144 @@
import requests
from bs4 import BeautifulSoup
import re
import json
import os
import hmac
from hashlib import sha1
print("Start downloading file links...")
# 发送GET请求获取页面内容
url = "https://teamspeak.com/zh-CN/downloads/"
response = requests.get(url)
soup = BeautifulSoup(response.content, "html.parser")
# 找到所有<a>标签并提取链接
links = soup.find_all("a", href=True)
# 匹配包含"https://files.teamspeak-services.com"的链接
file_links = [link["href"] for link in links if re.search(r"https://files.teamspeak-services.com", link["href"])]
# 按版本划分链接
ver3_links = [link for link in file_links if re.search(r"\/3\.\d+\.\d+\/", link)]
ver5_links = [link for link in file_links if re.search(r"\/(?:5\.\d+\.\d+|5\.\d+\.\d+\-\w+)/", link)]
# 设置全局变量
download_file = True
file_updated = False
# 创建版本文件夹并保存链接
def save_links_to_folder(links, folder_name):
folder_path = os.path.join(os.getcwd(), "file", folder_name)
if not os.path.exists(folder_path):
os.makedirs(folder_path)
for link in links:
file_name = link.split("/")[-1]
file_path = os.path.join(folder_path, file_name)
# 检查文件是否需要更新
global download_file
if os.path.exists(file_path):
response = requests.head(link)
remote_file_size = int(response.headers.get('Content-Length', 0))
local_file_size = os.path.getsize(file_path)
if remote_file_size == local_file_size:
download_file = False
print(f"文件 {file_name} 已更新。无需下载。")
else:
download_file = True
os.remove(file_path)
# 如果需要下载文件
if download_file:
with open(file_path, "wb") as file:
response = requests.get(link)
file.write(response.content)
print(f"文件 {file_name} 已下载到 {folder_name}")
# 保存链接到对应版本文件夹中
save_links_to_folder(ver3_links, "Ver3")
save_links_to_folder(ver5_links, "Ver5")
# 将链接存储为JSON文件
data = {"Ver3": ver3_links, "Ver5": ver5_links}
with open("file_links.json", "w") as json_file:
json.dump(data, json_file, indent=4)
print("链接已保存至file_links.json")
def downloadFile():
global file_updated
if download_file:
print("download_file的值为:", download_file)
file_updated = True
else:
print("download_file的值为:", download_file)
file_updated = False
downloadFile()
print("file_updated的最终值为:", file_updated)
# 生成本地文件下载链接
base_download_url = "https://file-teamspeak-download.lolicon.team/file/"
def generate_local_download_links(links, folder_name):
local_download_links = [base_download_url + folder_name + "/" + link.split("/")[-1] for link in links]
return local_download_links
ver3_local_download_links = generate_local_download_links(ver3_links, "Ver3")
ver5_local_download_links = generate_local_download_links(ver5_links, "Ver5")
# 将本地文件下载链接存储为JSON文件
local_download_links_data = {"Ver3": ver3_local_download_links, "Ver5": ver5_local_download_links}
with open("local_download_links.json", "w") as local_json_file:
json.dump(local_download_links_data, local_json_file, indent=4)
print("本地下载链接已保存至local_download_links.json")
# 判断是否有文件更新
if file_updated:
print("文件已更新开始预热CDN...")
# 预热 CDN
def dogecloud_api(api_path, data={}, json_mode=False):
access_key = '' # 请将此处替换为你的多吉云 Access Key
secret_key = '' # 请将此处替换为你的多吉云 Secret Key
body = ''
mime = ''
if json_mode:
body = json.dumps(data)
mime = 'application/json'
else:
body = urllib.parse.urlencode(data)
mime = 'application/x-www-form-urlencoded'
sign_str = api_path + "\n" + body
signed_data = hmac.new(secret_key.encode('utf-8'), sign_str.encode('utf-8'), sha1)
sign = signed_data.digest().hex()
authorization = 'TOKEN ' + access_key + ':' + sign
response = requests.post('https://api.dogecloud.com' + api_path, data=body, headers={
'Authorization': authorization,
'Content-Type': mime
})
return response.json()
api_path = '/cdn/refresh/add.json'
data = {
'rtype': 'prefetch',
'urls': json.dumps(all_local_links)
}
response = dogecloud_api(api_path, data, json_mode=True)
print(response)
data = {
'rtype': 'path',
'urls': 'https://file-teamspeak-download.lolicon.team/file/'
}
response = dogecloud_api(api_path, data, json_mode=True)
print(response)
else:
print("文件未更新无需预热CDN。")
Loading…
Cancel
Save