From 3284922fafc0e43f7315e1a1c1439c6c8990e1b7 Mon Sep 17 00:00:00 2001 From: Jacob Gunther Date: Sat, 22 Oct 2022 18:31:21 -0500 Subject: [PATCH] Add unique addresses to Redis --- go.mod | 2 +- go.sum | 4 ++++ src/routes.go | 10 ++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index ca2060d..7a64f06 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/gofiber/fiber/v2 v2.37.0 - github.com/mcstatus-io/shared v0.0.0-20220831020858-f06e905d3d58 + github.com/mcstatus-io/shared v0.0.0-20221022211501-c2159792b379 gopkg.in/yaml.v3 v3.0.1 ) diff --git a/go.sum b/go.sum index e80a72a..2f6a776 100644 --- a/go.sum +++ b/go.sum @@ -20,6 +20,10 @@ github.com/mcstatus-io/shared v0.0.0-20220831020724-45f9930045d4 h1:EuTkZOKU7dKd github.com/mcstatus-io/shared v0.0.0-20220831020724-45f9930045d4/go.mod h1:0CPc1P/GzYKF3mS7CkRP3Mo/uOjU4fmZVkm0AF1c6D8= github.com/mcstatus-io/shared v0.0.0-20220831020858-f06e905d3d58 h1:QLE9LMv75l9R880ZfVfHBwD9t3wpcxwfNVNTaoH06aY= github.com/mcstatus-io/shared v0.0.0-20220831020858-f06e905d3d58/go.mod h1:0CPc1P/GzYKF3mS7CkRP3Mo/uOjU4fmZVkm0AF1c6D8= +github.com/mcstatus-io/shared v0.0.0-20221022211244-6945f6f4202e h1:IQcYQuxOLlurhBxYH1PhKGnFJlSMJThd7vvVCFMOLDE= +github.com/mcstatus-io/shared v0.0.0-20221022211244-6945f6f4202e/go.mod h1:0CPc1P/GzYKF3mS7CkRP3Mo/uOjU4fmZVkm0AF1c6D8= +github.com/mcstatus-io/shared v0.0.0-20221022211501-c2159792b379 h1:CpddEJRMAvbc0kUedMk3A2VMl4SAb6u3HKMn66eThuA= +github.com/mcstatus-io/shared v0.0.0-20221022211501-c2159792b379/go.mod h1:0CPc1P/GzYKF3mS7CkRP3Mo/uOjU4fmZVkm0AF1c6D8= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE= diff --git a/src/routes.go b/src/routes.go index 5ba2342..8e75d98 100644 --- a/src/routes.go +++ b/src/routes.go @@ -1,8 +1,10 @@ package main import ( + "fmt" "net/http" "strconv" + "time" "github.com/gofiber/fiber/v2" "github.com/mcstatus-io/shared/status" @@ -29,6 +31,10 @@ func JavaStatusHandler(ctx *fiber.Ctx) error { return ctx.Status(http.StatusBadRequest).SendString("Invalid address value") } + if err = r.Set(fmt.Sprintf("unique:%s-%d", host, port), time.Now(), 0); err != nil { + return err + } + response, expiresAt, err := status.GetJavaStatus(r, host, port, config.Cache.JavaCacheDuration) if err != nil { @@ -49,6 +55,10 @@ func BedrockStatusHandler(ctx *fiber.Ctx) error { return ctx.Status(http.StatusBadRequest).SendString("Invalid address value") } + if err = r.Set(fmt.Sprintf("unique:%s-%d", host, port), time.Now(), 0); err != nil { + return err + } + response, expiresAt, err := status.GetBedrockStatus(r, host, port, config.Cache.BedrockCacheDuration) if err != nil {