监控被墙小鸡释放

你知唔知我系靓仔

监控被墙小鸡释放

狗云的香港BGP优化相当nice,如果使用幸运模式可以达到150元 接近500天的使用时间。

简单脚本监控推送坐牢小鸡释放

更新为同时监控多个被墙小鸡

import time
import json
import requests
from icmplib import ping

def send_notification(qq, msg):
    api_url = "https://qmsg.zendee.cn/send/token"  # send
    params = {"qq": qq, "msg": msg}

    try:
        response = requests.get(api_url, params=params)
        response.raise_for_status()  # 检查是否有错误的响应
        print(f"消息已成功发送: {msg}")
    except requests.exceptions.RequestException as e:
        print(f"发送消息时发生错误: {e}")

def load_ip_records(filename):
    try:
        with open(filename, "r") as file:
            ip_records = json.load(file)
    except FileNotFoundError:
        ip_records = {}
    return ip_records

def save_ip_records(filename, ip_records):
    with open(filename, "w") as file:
        json.dump(ip_records, file, indent=4)

def main():
    qq = "10001"  # 修改为你的QQ号码
    channel = "坐牢小鸡已释放"
    filename = "ips.json"

    # 加载 IP 记录
    ip_records = load_ip_records(filename)

    while ip_records:
        for ip, failed_attempts in list(ip_records.items()):  # 使用 list() 将字典转换为列表,以便在循环中修改字典
            # 发送 ping 请求
            host = ping(ip, count=1)

            if host.is_alive:
                msg = f"{channel}: {ip}"
                send_notification(qq, msg)
                print("成功")

                # 从记录中删除已成功的 IP 地址
                del ip_records[ip]
            else:
                print(f"{ip} Ping失败")
                # 更新失败次数记录
                ip_records[ip] = failed_attempts + 1

        # 保存更新后的 IP 记录
        save_ip_records(filename, ip_records)

        # 每次循环结束后等待10分钟
        time.sleep(600)  # 等待10分钟(10 * 60秒)

    print("所有小鸡都已成功出狱,退出程序")

if __name__ == "__main__":
    main()

ips.json

{
    "206.0.0.83": 2,
    "166.0.0.153": 2,
    "89.0.0.248": 2
}