Add unique addresses to Redis

This commit is contained in:
Jacob Gunther
2022-10-22 18:31:21 -05:00
parent d0c0567b0d
commit 3284922faf
3 changed files with 15 additions and 1 deletions

2
go.mod
View File

@@ -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
)

4
go.sum
View File

@@ -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=

View File

@@ -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 {