From fd384ff33e27262f21dedda8a409764b2039e730 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor?= Date: Fri, 6 Aug 2021 19:53:16 -0300 Subject: [PATCH] Add support for redis authentication (#420) * Add support for redis authentication (Update redpool dependency) - Add configuration option `redisPassword` * Reference `redisPassword` in nitter.conf --- nitter.conf | 1 + nitter.nimble | 2 +- src/config.nim | 1 + src/redis_cache.nim | 2 +- src/types.nim | 1 + 5 files changed, 5 insertions(+), 2 deletions(-) diff --git a/nitter.conf b/nitter.conf index 2cca7f9..aa27a65 100644 --- a/nitter.conf +++ b/nitter.conf @@ -14,6 +14,7 @@ redisHost = "localhost" redisPort = 6379 redisConnections = 20 # connection pool size redisMaxConnections = 30 +redisPassword = "" # max, new connections are opened when none are available, but if the pool size # goes above this, they're closed when released. don't worry about this unless # you receive tons of requests per second diff --git a/nitter.nimble b/nitter.nimble index 12ff025..1fc9c6e 100644 --- a/nitter.nimble +++ b/nitter.nimble @@ -19,7 +19,7 @@ requires "nimcrypto >= 0.4.11" requires "markdown#abdbe5e" requires "packedjson#7198cc8" requires "supersnappy#1.1.5" -requires "redpool#57aeb25" +requires "redpool#f880f49" requires "https://github.com/zedeus/redis#94bcbf1" requires "https://github.com/disruptek/frosty#0.3.1" diff --git a/src/config.nim b/src/config.nim index a1e4ab2..9a04e41 100644 --- a/src/config.nim +++ b/src/config.nim @@ -33,6 +33,7 @@ proc getConfig*(path: string): (Config, parseCfg.Config) = redisPort: cfg.get("Cache", "redisPort", 6379), redisConns: cfg.get("Cache", "redisConnections", 20), redisMaxConns: cfg.get("Cache", "redisMaxConnections", 30), + redisPassword: cfg.get("Cache", "redisPassword", ""), replaceYouTube: cfg.get("Preferences", "replaceYouTube", "piped.kavin.rocks") ) diff --git a/src/redis_cache.nim b/src/redis_cache.nim index 10fe6d7..1cb3bed 100644 --- a/src/redis_cache.nim +++ b/src/redis_cache.nim @@ -30,7 +30,7 @@ proc migrate*(key, match: string) {.async.} = proc initRedisPool*(cfg: Config) {.async.} = try: pool = await newRedisPool(cfg.redisConns, maxConns=cfg.redisMaxConns, - host=cfg.redisHost, port=cfg.redisPort) + host=cfg.redisHost, port=cfg.redisPort, password=cfg.redisPassword) await migrate("snappyRss", "rss:*") await migrate("oldFrosty", "*") diff --git a/src/types.nim b/src/types.nim index 6be9c52..d405e26 100644 --- a/src/types.nim +++ b/src/types.nim @@ -220,6 +220,7 @@ type redisPort*: int redisConns*: int redisMaxConns*: int + redisPassword*: string replaceYouTube*: string