Simple-Tracker / qBittorrent-ClientBlocker

一款适用于 qBittorrent/Transmission (Beta)/BitComet (Beta, Partial) 的客户端屏蔽器, 默认屏蔽包括但不限于迅雷等客户端. A client blocker compatible with qBittorrent/Transmission (Beta)/BitComet (Beta, Partial) which is prohibited to include but not limited to clients such as Xunlei.
MIT License
1.02k stars 26 forks source link

读取配置文件失败或不完整,黑名单没有生效 #20

Closed LightmoonXD closed 8 months ago

LightmoonXD commented 8 months ago

截屏2024-02-23 03 47 43

系统是ARM的macOS Sonoma

Simple-Tracker commented 8 months ago

感谢反馈!

请检查自身配置文件是否有误/有权限. 请注意: 程序不支持部分高级正则表达式语法, 如前后向断言.

另附多个 JSON 在线校验工具: https://www.json.cn / https://www.bejson.com / https://www.sojson.com

sh-3.2$ date
2024年 2月24日 星期六 02时54分21秒 CST
sh-3.2$ cat config.json
{
    "debug": true,
    "interval": 6,
    "cleanInterval": 3600,
    "banTime": 86400,
    "sleepTime": 20,
    "timeout": 6,
    "longConnection": true,
    "logPath": "logs",
    "logToFile": true,
    "logDebug": false,
    "qBURL": "",
    "qBUsername": "",
    "qBPassword": "",
    "skipCertVerification": false,
    "blockList": ["-(XL|SD|XF|QD|BN|DL)(\\d+)-", "((^(xunlei?).?\\d+.\\d+.\\d+.\\d+)|cacao_torrent)", "-(UW\\w{4}|SP(([0-2]\\d{3})|(3[0-5]\\d{2})))-", "StellarPlayer", "dandanplay", "anacrolix[ /]torrent v?([0-1]\\.(([0-9]|[0-4][0-9]|[0-5][0-2])\\.[0-9]+|(53\\.[0-2]( |$)))|unknown)", "Test1"]
}
sh-3.2$ ./qBittorrent-ClientBlocker 
[2024-02-24 02:54:25][ShowVersion] qBittorrent-ClientBlocker 2.7 (darwin, arm64).
[2024-02-24 02:54:25][LoadConfig] 读取配置文件成功.
[2024-02-24 02:54:25][LoadConfig-Current] Debug: true.
[2024-02-24 02:54:25][LoadConfig-Current] Debug_CheckTorrent: false.
[2024-02-24 02:54:25][LoadConfig-Current] Debug_CheckPeer: false.
[2024-02-24 02:54:25][LoadConfig-Current] Interval: 6.
[2024-02-24 02:54:25][LoadConfig-Current] CleanInterval: 3600.
[2024-02-24 02:54:25][LoadConfig-Current] PeerMapCleanInterval: 60.
[2024-02-24 02:54:25][LoadConfig-Current] BanTime: 86400.
[2024-02-24 02:54:25][LoadConfig-Current] BanAllPort: false.
[2024-02-24 02:54:25][LoadConfig-Current] StartDelay: 0.
[2024-02-24 02:54:25][LoadConfig-Current] SleepTime: 20.
[2024-02-24 02:54:25][LoadConfig-Current] Timeout: 6.
[2024-02-24 02:54:25][LoadConfig-Current] IPUploadedCheck: false.
[2024-02-24 02:54:25][LoadConfig-Current] IPUpCheckInterval: 3600.
[2024-02-24 02:54:25][LoadConfig-Current] IPUpCheckIncrementMB: 180000.
[2024-02-24 02:54:25][LoadConfig-Current] MaxIPPortCount: 0.
[2024-02-24 02:54:25][LoadConfig-Current] BanByProgressUploaded: false.
[2024-02-24 02:54:25][LoadConfig-Current] BanByPUStartMB: 10.
[2024-02-24 02:54:25][LoadConfig-Current] BanByPUStartPrecent: 2.
[2024-02-24 02:54:25][LoadConfig-Current] BanByPUAntiErrorRatio: 5.
[2024-02-24 02:54:25][LoadConfig-Current] BanByRelativeProgressUploaded: false.
[2024-02-24 02:54:25][LoadConfig-Current] BanByRelativePUStartMB: 10.
[2024-02-24 02:54:25][LoadConfig-Current] BanByRelativePUStartPrecent: 2.
[2024-02-24 02:54:25][LoadConfig-Current] BanByRelativePUAntiErrorRatio: 5.
[2024-02-24 02:54:25][LoadConfig-Current] LongConnection: true.
[2024-02-24 02:54:25][LoadConfig-Current] LogPath: logs.
[2024-02-24 02:54:25][LoadConfig-Current] LogToFile: true.
[2024-02-24 02:54:25][LoadConfig-Current] LogDebug: false.
[2024-02-24 02:54:25][LoadConfig-Current] QBURL: .
[2024-02-24 02:54:25][LoadConfig-Current] QBUsername: .
[2024-02-24 02:54:25][LoadConfig-Current] QBPassword: .
[2024-02-24 02:54:25][LoadConfig-Current] BlockList: [-(XL|SD|XF|QD|BN|DL)(\d+)- ((^(xunlei?).?\d+.\d+.\d+.\d+)|cacao_torrent) -(UW\w{4}|SP(([0-2]\d{3})|(3[0-5]\d{2})))- StellarPlayer dandanplay anacrolix[ /]torrent v?([0-1]\.(([0-9]|[0-4][0-9]|[0-5][0-2])\.[0-9]+|(53\.[0-2]( |$)))|unknown) Test1].
[2024-02-24 02:54:25][LoadConfig-Current] SkipCertVerification: false.
[2024-02-24 02:54:25][Debug-LoadConfig-CompileBlockList] -(XL|SD|XF|QD|BN|DL)(\d+)-.
[2024-02-24 02:54:25][Debug-LoadConfig-CompileBlockList] ((^(xunlei?).?\d+.\d+.\d+.\d+)|cacao_torrent).
[2024-02-24 02:54:25][Debug-LoadConfig-CompileBlockList] -(UW\w{4}|SP(([0-2]\d{3})|(3[0-5]\d{2})))-.
[2024-02-24 02:54:25][Debug-LoadConfig-CompileBlockList] StellarPlayer.
[2024-02-24 02:54:25][Debug-LoadConfig-CompileBlockList] dandanplay.
[2024-02-24 02:54:25][Debug-LoadConfig-CompileBlockList] anacrolix[ /]torrent v?([0-1]\.(([0-9]|[0-4][0-9]|[0-5][0-2])\.[0-9]+|(53\.[0-2]( |$)))|unknown).
[2024-02-24 02:54:25][Debug-LoadConfig-CompileBlockList] Test1.
[2024-02-24 02:54:25][GetConfigFromQB] 使用 qBittorrent 配置文件: /Users/example/.config/qBittorrent/qBittorrent.ini.
[2024-02-24 02:54:25][SetQBURLFromQB] 读取 qBittorrent 配置文件成功 (qBWebUIEnabled: true, qBURL: http://127.0.0.1:9900, qBUsername: admin).
[2024-02-24 02:54:25][Login] 登录成功.
[2024-02-24 02:54:25][RunConsole] 程序已启动.
[2024-02-24 02:54:31][Debug-Task_IgnoreEmptyHashCount] 0.
[2024-02-24 02:54:31][Debug-Task_IgnoreNoLeechersCount] 11.
[2024-02-24 02:54:31][Debug-Task_IgnoreBadTorrentInfoCount] 0.
[2024-02-24 02:54:31][Debug-Task_IgnoreBadPeersCount] 0.
^C
sh-3.2$ uname -a
Darwin MacBook-Pro.local 23.4.0 Darwin Kernel Version 23.4.0: Tue Feb 13 23:56:08 PST 2024; root:xnu-10063.101.14~5/RELEASE_ARM64_T6000 arm64
sh-3.2$ sw_vers
ProductName:        macOS
ProductVersion:     14.4
BuildVersion:       23E5205c
sh-3.2$ 
LightmoonXD commented 8 months ago

您好,感谢回复。我不太懂我的方法是不是有问题,macOS需要放在什么特定的文件夹吗? 我将下载下来的文件夹放到Applications里,然后不修改config.json(因为不开本机qbit的认证) 我在Finder里看到json和程序都已经设置成读与写了,log文件生成在/Applications/logs文件夹下面,不知道对不对。 MiniMe:Applications root# sudo chmod -R 777 /Applications/qBittorrent-ClientBlocker-2.8p3-darwin-arm64 MiniMe:Applications root# sudo /Applications/qBittorrent-ClientBlocker-2.8p3-darwin-arm64/qBittorrent-ClientBlocker [2024-02-24 12:32:16][Login] 登录成功. [2024-02-24 12:32:16][RunConsole] 程序已启动. [2024-02-24 12:32:16][RunConsole] 读取配置文件失败或不完整. [2024-02-24 12:32:16][LoadConfig-Current] Debug: false. [2024-02-24 12:32:16][LoadConfig-Current] Debug_CheckTorrent: false. [2024-02-24 12:32:16][LoadConfig-Current] Debug_CheckPeer: false. [2024-02-24 12:32:16][LoadConfig-Current] Interval: 6. [2024-02-24 12:32:16][LoadConfig-Current] CleanInterval: 3600. [2024-02-24 12:32:16][LoadConfig-Current] PeerMapCleanInterval: 60. [2024-02-24 12:32:16][LoadConfig-Current] BanTime: 86400. [2024-02-24 12:32:16][LoadConfig-Current] BanAllPort: false. [2024-02-24 12:32:16][LoadConfig-Current] StartDelay: 0. [2024-02-24 12:32:16][LoadConfig-Current] SleepTime: 20. [2024-02-24 12:32:16][LoadConfig-Current] Timeout: 6. [2024-02-24 12:32:16][LoadConfig-Current] IPUploadedCheck: false. [2024-02-24 12:32:16][LoadConfig-Current] IPUpCheckInterval: 3600. [2024-02-24 12:32:16][LoadConfig-Current] IPUpCheckIncrementMB: 180000. [2024-02-24 12:32:16][LoadConfig-Current] MaxIPPortCount: 0. [2024-02-24 12:32:16][LoadConfig-Current] BanByProgressUploaded: false. [2024-02-24 12:32:16][LoadConfig-Current] BanByPUStartMB: 10. [2024-02-24 12:32:16][LoadConfig-Current] BanByPUStartPrecent: 2. [2024-02-24 12:32:16][LoadConfig-Current] BanByPUAntiErrorRatio: 5. [2024-02-24 12:32:16][LoadConfig-Current] BanByRelativeProgressUploaded: false. [2024-02-24 12:32:16][LoadConfig-Current] BanByRelativePUStartMB: 10. [2024-02-24 12:32:16][LoadConfig-Current] BanByRelativePUStartPrecent: 2. [2024-02-24 12:32:16][LoadConfig-Current] BanByRelativePUAntiErrorRatio: 5. [2024-02-24 12:32:16][LoadConfig-Current] LongConnection: true. [2024-02-24 12:32:16][LoadConfig-Current] LogPath: logs. [2024-02-24 12:32:16][LoadConfig-Current] LogToFile: true. [2024-02-24 12:32:16][LoadConfig-Current] LogDebug: false. [2024-02-24 12:32:16][LoadConfig-Current] QBURL: http://127.0.0.1:8080. [2024-02-24 12:32:16][LoadConfig-Current] QBUsername: admin. [2024-02-24 12:32:16][LoadConfig-Current] QBPassword: . [2024-02-24 12:32:16][LoadConfig-Current] UseBasicAuth: false. [2024-02-24 12:32:16][LoadConfig-Current] SkipCertVerification: false. [2024-02-24 12:32:16][LoadConfig-Current] BlockList: []. [2024-02-24 12:32:16][LoadConfig-Current] IPBlockList: [].

好像程序并没有读取同目录下的那个json文件,因为我把debug改成true了,运行的时候还是回报上面的false。而且那个json文件也没有IPBlockList的数组。

JSON文件的内容如下:

{ "debug": true, "interval": 6, "cleanInterval": 3600, "banTime": 86400, "sleepTime": 20, "timeout": 6, "longConnection": true, "logPath": "logs", "logToFile": true, "logDebug": false, "qBURL": "", "qBUsername": "", "qBPassword": "", "skipCertVerification": false, "blockList": ["-(XL|SD|XF|QD|BN|DL)(\d+)-", "((^(xunlei?).?\d+.\d+.\d+.\d+)|cacao_torrent)", "-(UW\w{4}|SP(([0-2]\d{3})|(3[0-5]\d{2})))-", "StellarPlayer", "dandanplay", "anacrolix[ /]torrent v?([0-1]\.(([0-9]|[0-4][0-9]|[0-5][0-2])\.[0-9]+|(53\.0-2))|unknown)"] }

我也进系统设置给了程序完全磁盘访问权限。

Simple-Tracker commented 8 months ago

您好,感谢回复。我不太懂我的方法是不是有问题,macOS需要放在什么特定的文件夹吗? 我将下载下来的文件夹放到Applications里,然后不修改config.json(因为不开本机qbit的认证) 我在Finder里看到json和程序都已经设置成读与写了,log文件生成在/Applications/logs文件夹下面,不知道对不对。 MiniMe:Applications root# sudo chmod -R 777 /Applications/qBittorrent-ClientBlocker-2.8p3-darwin-arm64 MiniMe:Applications root# sudo /Applications/qBittorrent-ClientBlocker-2.8p3-darwin-arm64/qBittorrent-ClientBlocker [2024-02-24 12:32:16][Login] 登录成功. [2024-02-24 12:32:16][RunConsole] 程序已启动. [2024-02-24 12:32:16][RunConsole] 读取配置文件失败或不完整. [2024-02-24 12:32:16][LoadConfig-Current] Debug: false. [2024-02-24 12:32:16][LoadConfig-Current] Debug_CheckTorrent: false. [2024-02-24 12:32:16][LoadConfig-Current] Debug_CheckPeer: false. [2024-02-24 12:32:16][LoadConfig-Current] Interval: 6. [2024-02-24 12:32:16][LoadConfig-Current] CleanInterval: 3600. [2024-02-24 12:32:16][LoadConfig-Current] PeerMapCleanInterval: 60. [2024-02-24 12:32:16][LoadConfig-Current] BanTime: 86400. [2024-02-24 12:32:16][LoadConfig-Current] BanAllPort: false. [2024-02-24 12:32:16][LoadConfig-Current] StartDelay: 0. [2024-02-24 12:32:16][LoadConfig-Current] SleepTime: 20. [2024-02-24 12:32:16][LoadConfig-Current] Timeout: 6. [2024-02-24 12:32:16][LoadConfig-Current] IPUploadedCheck: false. [2024-02-24 12:32:16][LoadConfig-Current] IPUpCheckInterval: 3600. [2024-02-24 12:32:16][LoadConfig-Current] IPUpCheckIncrementMB: 180000. [2024-02-24 12:32:16][LoadConfig-Current] MaxIPPortCount: 0. [2024-02-24 12:32:16][LoadConfig-Current] BanByProgressUploaded: false. [2024-02-24 12:32:16][LoadConfig-Current] BanByPUStartMB: 10. [2024-02-24 12:32:16][LoadConfig-Current] BanByPUStartPrecent: 2. [2024-02-24 12:32:16][LoadConfig-Current] BanByPUAntiErrorRatio: 5. [2024-02-24 12:32:16][LoadConfig-Current] BanByRelativeProgressUploaded: false. [2024-02-24 12:32:16][LoadConfig-Current] BanByRelativePUStartMB: 10. [2024-02-24 12:32:16][LoadConfig-Current] BanByRelativePUStartPrecent: 2. [2024-02-24 12:32:16][LoadConfig-Current] BanByRelativePUAntiErrorRatio: 5. [2024-02-24 12:32:16][LoadConfig-Current] LongConnection: true. [2024-02-24 12:32:16][LoadConfig-Current] LogPath: logs. [2024-02-24 12:32:16][LoadConfig-Current] LogToFile: true. [2024-02-24 12:32:16][LoadConfig-Current] LogDebug: false. [2024-02-24 12:32:16][LoadConfig-Current] QBURL: http://127.0.0.1:8080. [2024-02-24 12:32:16][LoadConfig-Current] QBUsername: admin. [2024-02-24 12:32:16][LoadConfig-Current] QBPassword: . [2024-02-24 12:32:16][LoadConfig-Current] UseBasicAuth: false. [2024-02-24 12:32:16][LoadConfig-Current] SkipCertVerification: false. [2024-02-24 12:32:16][LoadConfig-Current] BlockList: []. [2024-02-24 12:32:16][LoadConfig-Current] IPBlockList: [].

好像程序并没有读取同目录下的那个json文件,因为我把debug改成true了,运行的时候还是回报上面的false。而且那个json文件也没有IPBlockList的数组。

JSON文件的内容如下:

{ "debug": true, "interval": 6, "cleanInterval": 3600, "banTime": 86400, "sleepTime": 20, "timeout": 6, "longConnection": true, "logPath": "logs", "logToFile": true, "logDebug": false, "qBURL": "", "qBUsername": "", "qBPassword": "", "skipCertVerification": false, "blockList": ["-(XL|SD|XF|QD|BN|DL)(\d+)-", "((^(xunlei?).?\d+.\d+.\d+.\d+)|cacao_torrent)", "-(UW\w{4}|SP(([0-2]\d{3})|(3[0-5]\d{2})))-", "StellarPlayer", "dandanplay", "anacrolix[ /]torrent v?([0-1].(([0-9]|[0-4][0-9]|[0-5][0-2]).[0-9]+|(53.0-2))|unknown)"] }

我也进系统设置给了程序完全磁盘访问权限。

未指定 --config Flag 的情况下, 以工作目录为准, 即: root 目录, 这是一个较难意想到的问题. 因此建议切换工作目录后再运行, 或是使用 --config 指定配置文件所处目录 (但不影响日志, 日志可通过配置文件路径另行指定. (另: 不建议将二进制文件放在 /Application 下, 可参见新的 macOS LaunchAgent 用户代理)

Simple-Tracker commented 8 months ago

(另: 2.9b1 已优化此问题.)

Simple-Tracker commented 8 months ago

若仍有相同/相似问题请再度于 Issue 反馈, 会继续跟进.