mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 02:39:33 +02:00
Block infohash spammers from tracker
This commit is contained in:
parent
d4bf24df8e
commit
db48de8597
4 changed files with 81 additions and 22 deletions
|
@ -8,7 +8,8 @@ import {
|
|||
USER_PASSWORD_RESET_LIFETIME,
|
||||
USER_PASSWORD_CREATE_LIFETIME,
|
||||
VIDEO_VIEW_LIFETIME,
|
||||
WEBSERVER
|
||||
WEBSERVER,
|
||||
TRACKER_RATE_LIMITS
|
||||
} from '../initializers/constants'
|
||||
import { CONFIG } from '../initializers/config'
|
||||
|
||||
|
@ -121,6 +122,16 @@ class Redis {
|
|||
return this.exists(this.generateViewKey(ip, videoUUID))
|
||||
}
|
||||
|
||||
/* ************ Tracker IP block ************ */
|
||||
|
||||
setTrackerBlockIP (ip: string) {
|
||||
return this.setValue(this.generateTrackerBlockIPKey(ip), '1', TRACKER_RATE_LIMITS.BLOCK_IP_LIFETIME)
|
||||
}
|
||||
|
||||
async doesTrackerBlockIPExist (ip: string) {
|
||||
return this.exists(this.generateTrackerBlockIPKey(ip))
|
||||
}
|
||||
|
||||
/* ************ API cache ************ */
|
||||
|
||||
async getCachedRoute (req: express.Request) {
|
||||
|
@ -213,6 +224,10 @@ class Redis {
|
|||
return `views-${videoUUID}-${ip}`
|
||||
}
|
||||
|
||||
private generateTrackerBlockIPKey (ip: string) {
|
||||
return `tracker-block-ip-${ip}`
|
||||
}
|
||||
|
||||
private generateContactFormKey (ip: string) {
|
||||
return 'contact-form-' + ip
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue