Skip to content

Commit

Permalink
Improve & Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Simple-Tracker committed Jan 16, 2024
1 parent 650fcab commit e625ff7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
| interval | 2 秒 | 屏蔽循环间隔. 每个循环间隔会从 qBittorrent API 获取相关信息用于判断及屏蔽, 短间隔有助于降低封禁所需时间但可能造成 qBittorrent 卡顿, 长间隔有助于降低 CPU 资源占用 |
| cleanInterval | 3600 秒 (1 小时) | 屏蔽清理间隔. 短间隔会使过期 Peer 在达到屏蔽持续时间后更快被解除屏蔽, 长间隔有助于合并清理过期 Peer 日志 |
| banTime | 86400 秒 (1 天) | 屏蔽持续时间. 短间隔会使 Peer 更快被解除屏蔽 |
| sleepTime | 100 毫秒 | 查询每个 Torrent Peers 的等待时间. 短间隔可使屏蔽 Peer 更快但可能造成 qBittorrent 卡顿, 长间隔有助于平均 CPU 资源占用 |
| sleepTime | 20 毫秒 | 查询每个 Torrent Peers 的等待时间. 短间隔可使屏蔽 Peer 更快但可能造成 qBittorrent 卡顿, 长间隔有助于平均 CPU 资源占用 |
| timeout | 6 秒 | 请求超时. 过短间隔可能会造成无法正确屏蔽 Peer, 过长间隔会使超时请求影响屏蔽其它 Peer 的性能 |
| BanByProgressUploaded | 禁用 | 增强自动屏蔽 (根据进度及上传量屏蔽 Peer, 未经测试验证), 在满足下列增强自动屏蔽条件后, 会自动屏蔽 Peer |
| BanByPUStartMB | 5 MB | 增强自动屏蔽/起始大小. 若客户端上传达到起始大小, 则允许屏蔽 Peer |
| BanByPUStartMB | 10 MB | 增强自动屏蔽/起始大小. 若客户端上传达到起始大小, 则允许屏蔽 Peer |
| BanByPUStartPrecent | 2% | 增强自动屏蔽/起始进度. 若客户端上传达到起始进度, 则允许屏蔽 Peer |
| BanByPUAntiErrorRatio | 5X | 增强自动屏蔽/滞后防误判倍率. 若 Peer 报告下载进度与倍率之乘积得到之下载量 比 客户端上传量 还低, 则允许屏蔽 Peer |
| longConnection | 启用 | 长连接. 启用可降低资源消耗 |
| logToFile | 启用 | 记录日志到文件. 启用后可用于分析及统计用途 |
| logToFile | 启用 | 记录日志到文件. 启用后可用于分析及统计用途, 但不会记录调试模式的信息 |
| qBURL | http://127.0.0.1:990 | qBittorrent Web UI 地址. 正确填入是使用客户端屏蔽器的前提条件 |
| qBUsername || qBittorrent Web UI 账号. 若启用 qBittorrent 内 "跳过本机客户端认证" 可默认留空 |
| qBPassword || qBittorrent Web UI 密码. 若启用 qBittorrent 内 "跳过本机客户端认证" 可默认留空 |
Expand Down
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"interval": 2,
"cleanInterval": 3600,
"banTime": 86400,
"sleepTime": 100,
"sleepTime": 20,
"timeout": 6,
"longConnection": true,
"logToFile": true,
Expand Down
12 changes: 6 additions & 6 deletions console.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ var httpTransport = &http.Transport {
MaxIdleConnsPerHost: 32,
}
var httpClient = http.Client {
Timeout: 30 * time.Second,
Timeout: 6 * time.Second,
Jar: cookieJar,
Transport: httpTransport,
}
Expand All @@ -80,10 +80,10 @@ var config = ConfigStruct {
Interval: 2,
CleanInterval: 3600,
BanTime: 86400,
SleepTime: 100,
Timeout: 30,
SleepTime: 20,
Timeout: 6,
BanByProgressUploaded: false,
BanByPUStartMB: 2,
BanByPUStartMB: 10,
BanByPUStartPrecent: 2,
BanByPUAntiErrorRatio: 5,
LongConnection: true,
Expand Down Expand Up @@ -176,7 +176,7 @@ func LoadConfig() bool {
Timeout: time.Duration(config.Timeout) * time.Second,
Jar: cookieJar,
}
} else if config.Timeout != 30 {
} else if config.Timeout != 6 {
httpClient = http.Client {
Timeout: time.Duration(config.Timeout) * time.Second,
Jar: cookieJar,
Expand Down Expand Up @@ -234,7 +234,7 @@ func IsProgressNotMatchUploaded(torrentTotalSize int64, clientProgress float64,
*/
startUploaded := (float64(torrentTotalSize) * float64(config.BanByPUStartPrecent / 100))
peerReportDownloaded := (float64(torrentTotalSize) * clientProgress);
if (clientUploaded / 1024 / 1024) >= config.BanByPUStartMB && float64(clientUploaded) >= startUploaded && (peerReportDownloaded * float64(config.BanByPUAntiErrorRatio)) < float64(clientUploaded) {
if (clientUploaded / 1024 / 1024) >= int64(config.BanByPUStartMB) && float64(clientUploaded) >= startUploaded && (peerReportDownloaded * float64(config.BanByPUAntiErrorRatio)) < float64(clientUploaded) {
return true
}
}
Expand Down

0 comments on commit e625ff7

Please sign in to comment.