Skip to content

Commit

Permalink
Update result.csv and fd.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
laityts committed Jan 18, 2025
1 parent 62f3b8e commit 6b95491
Show file tree
Hide file tree
Showing 7 changed files with 1,235 additions and 1,114 deletions.
13 changes: 12 additions & 1 deletion autoddnsfd.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,25 @@ def add_dns_records_bulk(ip_data):
}
# 记录已经删除过哪些前缀
deleted_prefixes = set()
# 记录每个前缀已经添加的记录数量
prefix_counters = {}

for ip, location in ip_data:
domain = LOCATION_TO_DOMAIN.get(location)
if domain:
# 提取前缀(例如 "proxy.us.616049.xyz" 的前缀是 "proxy")
prefix = domain.split(".")[0]
# 如果该前缀没有被删除过,则删除该前缀的所有 DNS 记录
# 如果该前缀没有被删除过,则删除该前缀的所有 DNS 记录(保留最后一条)
if prefix not in deleted_prefixes:
delete_dns_records_with_prefix(prefix)
deleted_prefixes.add(prefix) # 标记该前缀已删除
prefix_counters[prefix] = 1 # 初始化计数器(因为删除后至少保留一条)

# 如果该前缀的记录数量已经达到 5 条,则跳过
if prefix_counters.get(prefix, 0) >= 5:
logging.info(f"前缀 {prefix} 的记录数量已达到 5 条,跳过添加: {domain} -> {ip}")
continue

data = {
"type": "A",
"name": domain,
Expand All @@ -175,6 +185,7 @@ def add_dns_records_bulk(ip_data):
response = requests.post(url, headers=headers, json=data)
if response.status_code == 200:
logging.info(f"添加成功: {domain} -> {ip}")
prefix_counters[prefix] = prefix_counters.get(prefix, 0) + 1 # 增加计数器
elif response.status_code == 409:
logging.info(f"记录已存在: {domain} -> {ip}")
else:
Expand Down
36 changes: 19 additions & 17 deletions cfip/fd.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
158.178.238.239#SIN
47.57.13.107#Proxy
47.243.171.8#HKG
8.218.202.1#HKG
8.217.156.218#HKG
8.217.150.87#HKG
8.219.83.38#SIN
8.222.169.168#SIN
8.219.78.57#SIN
8.222.179.219#SIN
8.222.128.219#SIN
8.222.165.104#SIN
152.69.227.245#SIN
47.57.245.232#Proxy
47.57.14.118#SJC
129.146.168.102#LAX
129.153.223.37#LAX
129.146.46.164#LAX
129.146.240.62#LAX
129.146.7.98#Proxy
47.89.244.253#SJC
129.150.51.134#SIN
103.137.63.2#KHH
141.148.187.195#LAX
132.226.114.74#LAX
132.226.31.178#LAX
168.138.165.174#SJC
8.219.15.214#SIN
8.219.112.192#SIN
8.219.71.207#SIN
8.219.71.161#SIN
8.219.72.167#SIN
8.219.87.77#SIN
8.222.138.169#SIN
8.219.117.75#SIN
8.219.64.255#SIN
8.219.55.57#SIN
21 changes: 20 additions & 1 deletion cfstfd.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
port_txt = "port/fdport.txt"
log_file = "log/fdlog.txt"
output_cf_txt = "speed/fd.txt"
proxy = "proxy.txt"
proxy_txt = "cfip/proxy.txt"
iplog_file = "log/fdlog.txt"
commit_message = "Update result.csv and fd.txt"
Expand Down Expand Up @@ -118,6 +119,24 @@ def get_colo(ip_address):
# 主程序逻辑
# ------------------------------

# 删除 proxy.txt 文件(如果存在)
remove_file(proxy)

# 从指定 URL 下载 proxy.txt 文件
proxy_url = "https://ipdb.api.030101.xyz/?type=proxy&down=true"
try:
response = requests.get(proxy_url, timeout=10)
if response.status_code == 200:
with open(proxy, "wb") as file:
file.write(response.content)
print(f"已成功下载 {proxy} 文件。")
else:
print(f"下载 {proxy} 文件失败,状态码: {response.status_code}")
sys.exit(1)
except requests.exceptions.RequestException as e:
print(f"下载 {proxy} 文件时发生错误: {e}")
sys.exit(1)

# 检查 cfst 文件是否存在
if not os.path.exists(cfst_path):
print(f"文件 {cfst_path} 不存在,正在执行安装和测试命令...")
Expand Down Expand Up @@ -149,7 +168,7 @@ def get_colo(ip_address):
remove_file(log_file)

# 执行 cfst 命令,使用变量传递 cfcolo 和随机端口
subprocess.run(["./cfst", "-f", "proxy.txt", "-o", "csv/resultfd.csv", "-httping", "-cfcolo", cfcolo, "-tl", "300", "-tll", "20", "-tp", "443", "-dn", "50"], check=True)
subprocess.run(["./cfst", "-f", proxy, "-o", "csv/resultfd.csv", "-httping", "-cfcolo", cfcolo, "-tl", "300", "-tll", "20", "-tp", "443", "-dn", "50"], check=True)

# 提取 IP 地址和下载速度,并保存到 fd.txt 和 fdport.txt
ip_addresses = []
Expand Down
68 changes: 50 additions & 18 deletions csv/resultfd.csv
Original file line number Diff line number Diff line change
@@ -1,19 +1,51 @@
IP 地址,已发送,已接收,丢包率,平均延迟,下载速度 (MB/s)
158.178.238.239,4,4,0.00,105.81,4.17
47.57.13.107,4,4,0.00,63.74,0.00
8.222.165.104,4,4,0.00,92.78,0.00
152.69.227.245,4,4,0.00,162.12,0.00
47.57.245.232,4,4,0.00,200.00,0.00
47.57.14.118,4,4,0.00,209.56,0.00
129.146.168.102,4,4,0.00,220.53,0.00
129.153.223.37,4,4,0.00,221.86,0.00
129.146.46.164,4,4,0.00,222.54,0.00
129.146.240.62,4,4,0.00,223.52,0.00
129.146.7.98,4,4,0.00,224.06,0.00
47.89.244.253,4,4,0.00,228.50,0.00
129.150.51.134,4,4,0.00,230.39,0.00
103.137.63.2,4,4,0.00,230.82,0.00
141.148.187.195,4,4,0.00,231.78,0.00
132.226.114.74,4,4,0.00,231.97,0.00
132.226.31.178,4,4,0.00,233.13,0.00
168.138.165.174,4,4,0.00,270.42,0.00
47.243.171.8,4,4,0.00,58.57,0.00
8.218.202.1,4,4,0.00,60.93,0.00
8.217.156.218,4,4,0.00,62.94,0.00
8.217.150.87,4,4,0.00,64.61,0.00
8.219.83.38,4,4,0.00,83.63,0.00
8.222.169.168,4,4,0.00,84.43,0.00
8.219.78.57,4,4,0.00,84.87,0.00
8.222.179.219,4,4,0.00,86.84,0.00
8.222.128.219,4,4,0.00,86.87,0.00
8.222.165.104,4,4,0.00,87.00,0.00
8.219.15.214,4,4,0.00,87.52,0.00
8.219.112.192,4,4,0.00,88.48,0.00
8.219.71.207,4,4,0.00,88.68,0.00
8.219.71.161,4,4,0.00,88.71,0.00
8.219.72.167,4,4,0.00,88.84,0.00
8.219.87.77,4,4,0.00,89.68,0.00
8.222.138.169,4,4,0.00,90.43,0.00
8.219.117.75,4,4,0.00,90.57,0.00
8.219.64.255,4,4,0.00,91.42,0.00
8.219.55.57,4,4,0.00,91.93,0.00
8.222.144.236,4,4,0.00,92.00,0.00
8.219.8.14,4,4,0.00,92.13,0.00
8.219.113.255,4,4,0.00,92.50,0.00
8.222.140.176,4,4,0.00,92.77,0.00
8.222.223.138,4,4,0.00,93.29,0.00
8.219.62.42,4,4,0.00,93.39,0.00
8.219.9.166,4,4,0.00,93.60,0.00
8.219.114.222,4,4,0.00,93.72,0.00
8.222.134.222,4,4,0.00,94.76,0.00
8.219.0.202,4,4,0.00,94.78,0.00
8.219.74.127,4,4,0.00,94.83,0.00
8.222.171.112,4,4,0.00,95.61,0.00
8.219.107.137,4,4,0.00,96.45,0.00
8.222.151.252,4,4,0.00,97.94,0.00
8.222.140.75,4,4,0.00,99.22,0.00
8.219.70.152,4,4,0.00,100.43,0.00
168.138.190.109,4,4,0.00,102.23,0.00
8.222.162.116,4,4,0.00,102.49,0.00
8.219.54.99,4,4,0.00,105.33,0.00
8.219.116.74,4,4,0.00,106.35,0.00
8.219.62.47,4,4,0.00,106.76,0.00
8.219.3.102,4,4,0.00,112.66,0.00
8.219.203.95,4,4,0.00,121.10,0.00
8.219.59.71,4,4,0.00,121.75,0.00
8.219.174.187,4,4,0.00,122.26,0.00
8.219.194.167,4,4,0.00,122.77,0.00
8.219.172.35,4,4,0.00,125.65,0.00
8.219.148.176,4,4,0.00,125.67,0.00
8.219.203.47,4,4,0.00,125.73,0.00
8.219.175.178,4,4,0.00,126.38,0.00
Loading

0 comments on commit 6b95491

Please sign in to comment.