fix X-Forwarded-For

This commit is contained in:
Daniel Mason 2021-03-28 22:07:11 +13:00
parent 16531f9fa1
commit d2e309b699
5 changed files with 8 additions and 5 deletions

View File

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

View File

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

2
go.mod
View File

@ -1,4 +1,4 @@
module git.m2.nz/go-scrobble
module gitlab.com/idanoo/go-scrobble
go 1.16

View File

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

View File

@ -10,11 +10,11 @@ function Home() {
</p>
<a
className="App-link"
href="https://git.m2.nz/idanoo/go-scrobble"
href="https://gitlab.com/idanoo/go-scrobble"
target="_blank"
rel="noopener noreferrer"
>
git.m2.nz/idanoo/go-scrobble
gitlab.com/idanoo/go-scrobble
</a>
</div>
);