@@ -10,6 +10,7 @@ import (
10
10
11
11
type BlockPeerInfoStruct struct {
12
12
Timestamp int64
13
+ Module string
13
14
Reason string
14
15
Port map [int ]bool
15
16
InfoHash string
@@ -24,7 +25,7 @@ var lastCleanTimestamp int64 = 0
24
25
var blockPeerMap = make (map [string ]BlockPeerInfoStruct )
25
26
var blockCIDRMap = make (map [string ]BlockCIDRInfoStruct )
26
27
27
- func AddBlockPeer (reason string , peerIP string , peerPort int , torrentInfoHash string ) {
28
+ func AddBlockPeer (module string , reason string , peerIP string , peerPort int , torrentInfoHash string ) {
28
29
var blockPeerPortMap map [int ]bool
29
30
if blockPeer , exist := blockPeerMap [peerIP ]; ! exist {
30
31
blockPeerPortMap = make (map [int ]bool )
@@ -33,7 +34,7 @@ func AddBlockPeer(reason string, peerIP string, peerPort int, torrentInfoHash st
33
34
}
34
35
35
36
blockPeerPortMap [peerPort ] = true
36
- blockPeerMap [peerIP ] = BlockPeerInfoStruct {Timestamp : currentTimestamp , Reason : reason , Port : blockPeerPortMap , InfoHash : torrentInfoHash }
37
+ blockPeerMap [peerIP ] = BlockPeerInfoStruct {Timestamp : currentTimestamp , Module : module , Reason : reason , Port : blockPeerPortMap , InfoHash : torrentInfoHash }
37
38
38
39
AddBlockCIDR (peerIP , ParseIPCIDRByConfig (peerIP ))
39
40
@@ -194,7 +195,7 @@ func CheckPeer(peerIP string, peerPort int, peerID, peerClient string, peerDlSpe
194
195
blockListCompiled .Range (func (key , val any ) bool {
195
196
if MatchBlockList (val .(* regexp2.Regexp ), peerIP , peerPort , peerID , peerClient ) {
196
197
Log ("CheckPeer_AddBlockPeer (Bad-Client_Normal)" , "%s:%d %s|%s (TorrentInfoHash: %s)" , true , peerIP , peerPort , strconv .QuoteToASCII (peerID ), strconv .QuoteToASCII (peerClient ), torrentInfoHash )
197
- AddBlockPeer ("Bad-Client_Normal" , peerIP , peerPort , torrentInfoHash )
198
+ AddBlockPeer ("CheckPeer" , " Bad-Client_Normal" , peerIP , peerPort , torrentInfoHash )
198
199
earlyStop = true
199
200
return false
200
201
}
@@ -209,7 +210,7 @@ func CheckPeer(peerIP string, peerPort int, peerID, peerClient string, peerDlSpe
209
210
for port := range config .PortBlockList {
210
211
if port == peerPort {
211
212
Log ("CheckPeer_AddBlockPeer (Bad-Port)" , "%s:%d %s|%s (TorrentInfoHash: %s)" , true , peerIP , peerPort , strconv .QuoteToASCII (peerID ), strconv .QuoteToASCII (peerClient ), torrentInfoHash )
212
- AddBlockPeer ("Bad-Port" , peerIP , peerPort , torrentInfoHash )
213
+ AddBlockPeer ("CheckPeer" , " Bad-Port" , peerIP , peerPort , torrentInfoHash )
213
214
return 1 , peerNet
214
215
}
215
216
}
@@ -230,7 +231,7 @@ func CheckPeer(peerIP string, peerPort int, peerID, peerClient string, peerDlSpe
230
231
}
231
232
if ipNet .Contains (ip ) {
232
233
Log ("CheckPeer_AddBlockPeer (Bad-IP_Normal)" , "%s:%d %s|%s (TorrentInfoHash: %s)" , true , peerIP , - 1 , strconv .QuoteToASCII (peerID ), strconv .QuoteToASCII (peerClient ), torrentInfoHash )
233
- AddBlockPeer ("Bad-IP_Normal" , peerIP , - 1 , torrentInfoHash )
234
+ AddBlockPeer ("CheckPeer" , " Bad-IP_Normal" , peerIP , - 1 , torrentInfoHash )
234
235
earlyStop = true
235
236
return false
236
237
}
@@ -247,15 +248,15 @@ func CheckPeer(peerIP string, peerPort int, peerID, peerClient string, peerDlSpe
247
248
}
248
249
if v .Contains (ip ) {
249
250
Log ("CheckPeer_AddBlockPeer (Bad-IP_FromSyncServer)" , "%s:%d %s|%s (TorrentInfoHash: %s)" , true , peerIP , - 1 , strconv .QuoteToASCII (peerID ), strconv .QuoteToASCII (peerClient ), torrentInfoHash )
250
- AddBlockPeer ("Bad-IP_FromSyncServer" , peerIP , - 1 , torrentInfoHash )
251
+ AddBlockPeer ("CheckPeer" , " Bad-IP_FromSyncServer" , peerIP , - 1 , torrentInfoHash )
251
252
return 3 , peerNet
252
253
}
253
254
}
254
255
}
255
256
256
257
if IsMatchCIDR (peerNet ) {
257
258
Log ("CheckPeer_AddBlockPeer (Bad-CIDR)" , "%s:%d %s|%s (TorrentInfoHash: %s, PeerNet: %s)" , true , peerIP , peerPort , strconv .QuoteToASCII (peerID ), strconv .QuoteToASCII (peerClient ), torrentInfoHash , peerNet .String ())
258
- AddBlockPeer ("Bad-CIDR" , peerIP , peerPort , torrentInfoHash )
259
+ AddBlockPeer ("CheckPeer" , " Bad-CIDR" , peerIP , peerPort , torrentInfoHash )
259
260
return 1 , peerNet
260
261
}
261
262
@@ -271,7 +272,7 @@ func CheckPeer(peerIP string, peerPort int, peerID, peerClient string, peerDlSpe
271
272
}
272
273
if ! ignoreByDownloaded && IsProgressNotMatchUploaded (torrentTotalSize , peerProgress , peerUploaded ) {
273
274
Log ("CheckPeer_AddBlockPeer (Bad-Progress_Uploaded)" , "%s:%d %s|%s (TorrentInfoHash: %s, TorrentTotalSize: %.2f MB, PeerDlSpeed: %.2f MB/s, PeerUpSpeed: %.2f MB/s, Progress: %.2f%%, Downloaded: %.2f MB, Uploaded: %.2f MB)" , true , peerIP , peerPort , strconv .QuoteToASCII (peerID ), strconv .QuoteToASCII (peerClient ), torrentInfoHash , (float64 (torrentTotalSize ) / 1024 / 1024 ), (float64 (peerDlSpeed ) / 1024 / 1024 ), (float64 (peerUpSpeed ) / 1024 / 1024 ), (peerProgress * 100 ), (float64 (peerDownloaded ) / 1024 / 1024 ), (float64 (peerUploaded ) / 1024 / 1024 ))
274
- AddBlockPeer ("Bad-Progress_Uploaded" , peerIP , peerPort , torrentInfoHash )
275
+ AddBlockPeer ("CheckPeer" , " Bad-Progress_Uploaded" , peerIP , peerPort , torrentInfoHash )
275
276
return 1 , peerNet
276
277
}
277
278
}
0 commit comments