diff options
author | lassulus <git@lassul.us> | 2024-08-20 20:27:19 +0200 |
---|---|---|
committer | lassulus <git@lassul.us> | 2024-08-20 20:27:19 +0200 |
commit | c833fb8c1b44840e3bd806fe42501473e90fc334 (patch) | |
tree | 0fb77840992572acfe1f21d1b8872b4a209bf00f /krebs/3modules/go.nix | |
parent | fe1979c9d16d9cc70e9617fcb7defe102bd41ae5 (diff) |
go: use sha hashes & redis sockets
Diffstat (limited to 'krebs/3modules/go.nix')
-rw-r--r-- | krebs/3modules/go.nix | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/krebs/3modules/go.nix b/krebs/3modules/go.nix index 0c3f42f1c..f52394dbc 100644 --- a/krebs/3modules/go.nix +++ b/krebs/3modules/go.nix @@ -21,6 +21,7 @@ let imp = { services.redis.servers.go.enable = true; + users.users.htgen-go.extraGroups = [ "redis-go" ]; krebs.htgen.go = { port = cfg.port; @@ -29,7 +30,7 @@ let case "$Method $Request_URI" in "GET /"*) - if item=$(${pkgs.redis}/bin/redis-cli --raw get "''${Request_URI#/}"); then + if item=$(${pkgs.redis}/bin/redis-cli -s /run/redis-go/redis.sock --raw get "''${Request_URI#/}"); then printf 'HTTP/1.1 302 Found\r\n' printf 'Content-Type: text/plain\r\n' printf 'Connection: closed\r\n' @@ -54,11 +55,10 @@ let ) sha256=$(echo "$uri" | sha256sum -b | cut -d\ -f1) - base32=$(${pkgs.nixStable}/bin/nix-hash --to-base32 --type sha256 "$sha256") - base32short=$(echo "$base32" | cut -c48-52) - ${pkgs.redis}/bin/redis-cli set "$base32short" "$uri" >/dev/null + short=$(echo "$sha256" | cut -c1-8) + ${pkgs.redis}/bin/redis-cli -s /run/redis-go/redis.sock set "$short" "$uri" >/dev/null - ref="http://$req_host/$base32short" + ref="http://$req_host/$short" printf 'HTTP/1.1 200 OK\r\n' printf 'Content-Type: text/plain; charset=UTF-8\r\n' |