aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/redis.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/redis.ts')
-rw-r--r--server/lib/redis.ts17
1 files changed, 16 insertions, 1 deletions
diff --git a/server/lib/redis.ts b/server/lib/redis.ts
index b4cd6f8e7..5313c4685 100644
--- a/server/lib/redis.ts
+++ b/server/lib/redis.ts
@@ -8,7 +8,8 @@ import {
8 USER_PASSWORD_RESET_LIFETIME, 8 USER_PASSWORD_RESET_LIFETIME,
9 USER_PASSWORD_CREATE_LIFETIME, 9 USER_PASSWORD_CREATE_LIFETIME,
10 VIDEO_VIEW_LIFETIME, 10 VIDEO_VIEW_LIFETIME,
11 WEBSERVER 11 WEBSERVER,
12 TRACKER_RATE_LIMITS
12} from '../initializers/constants' 13} from '../initializers/constants'
13import { CONFIG } from '../initializers/config' 14import { CONFIG } from '../initializers/config'
14 15
@@ -121,6 +122,16 @@ class Redis {
121 return this.exists(this.generateViewKey(ip, videoUUID)) 122 return this.exists(this.generateViewKey(ip, videoUUID))
122 } 123 }
123 124
125 /* ************ Tracker IP block ************ */
126
127 setTrackerBlockIP (ip: string) {
128 return this.setValue(this.generateTrackerBlockIPKey(ip), '1', TRACKER_RATE_LIMITS.BLOCK_IP_LIFETIME)
129 }
130
131 async doesTrackerBlockIPExist (ip: string) {
132 return this.exists(this.generateTrackerBlockIPKey(ip))
133 }
134
124 /* ************ API cache ************ */ 135 /* ************ API cache ************ */
125 136
126 async getCachedRoute (req: express.Request) { 137 async getCachedRoute (req: express.Request) {
@@ -213,6 +224,10 @@ class Redis {
213 return `views-${videoUUID}-${ip}` 224 return `views-${videoUUID}-${ip}`
214 } 225 }
215 226
227 private generateTrackerBlockIPKey (ip: string) {
228 return `tracker-block-ip-${ip}`
229 }
230
216 private generateContactFormKey (ip: string) { 231 private generateContactFormKey (ip: string) {
217 return 'contact-form-' + ip 232 return 'contact-form-' + ip
218 } 233 }