From d2e309b6997d90b7648760a0d96cffb889fc2058 Mon Sep 17 00:00:00 2001 From: Daniel Mason Date: Sun, 28 Mar 2021 22:07:11 +1300 Subject: [PATCH] fix X-Forwarded-For --- cmd/go-scrobble/main.go | 2 +- docs/config.md | 2 ++ go.mod | 2 +- internal/goscrobble/utils.go | 3 ++- web/src/Components/Pages/Home.js | 4 ++-- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/cmd/go-scrobble/main.go b/cmd/go-scrobble/main.go index 252ce049..f88e131f 100644 --- a/cmd/go-scrobble/main.go +++ b/cmd/go-scrobble/main.go @@ -8,8 +8,8 @@ import ( "strings" "time" - "git.m2.nz/go-scrobble/internal/goscrobble" "github.com/joho/godotenv" + "gitlab.com/idanoo/go-scrobble/internal/goscrobble" ) func main() { diff --git a/docs/config.md b/docs/config.md index 02c7d2c3..00672e1b 100644 --- a/docs/config.md +++ b/docs/config.md @@ -16,6 +16,8 @@ These are stored in `web/.env.production` and `web/.env.development` REDIS_PREFIX="gs:" // Redis key prefix REDIS_AUTH="" // Redis password + TIMEZONE= // Used for MySQL connection + JWT_SECRET= // 32+ Char JWT secret JWT_EXPIRY=86400 // JWT expiry diff --git a/go.mod b/go.mod index 79216131..0effb27f 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module git.m2.nz/go-scrobble +module gitlab.com/idanoo/go-scrobble go 1.16 diff --git a/internal/goscrobble/utils.go b/internal/goscrobble/utils.go index 0078368f..b24ddb3e 100644 --- a/internal/goscrobble/utils.go +++ b/internal/goscrobble/utils.go @@ -45,10 +45,11 @@ func getUserIp(r *http.Request) net.IP { var ip net.IP host, _, _ := net.SplitHostPort(r.RemoteAddr) if contains(ReverseProxies, host) { - forwardedFor := r.Header.Get("X-FOWARDED-FOR") + forwardedFor := r.Header.Get("X-Forwarded-For") if forwardedFor != "" { host = forwardedFor } + // realIp := r.Header.Get("X-Real-IP") } ip = net.ParseIP(host) diff --git a/web/src/Components/Pages/Home.js b/web/src/Components/Pages/Home.js index 08274b01..0556345a 100644 --- a/web/src/Components/Pages/Home.js +++ b/web/src/Components/Pages/Home.js @@ -10,11 +10,11 @@ function Home() {

- git.m2.nz/idanoo/go-scrobble + gitlab.com/idanoo/go-scrobble );