trusted proxies
This commit is contained in:
parent
33429f2a20
commit
274481bc77
@ -13,6 +13,7 @@ import (
|
|||||||
|
|
||||||
func MultiPanelDelete(ctx *gin.Context) {
|
func MultiPanelDelete(ctx *gin.Context) {
|
||||||
guildId := ctx.Keys["guildid"].(uint64)
|
guildId := ctx.Keys["guildid"].(uint64)
|
||||||
|
ctx.ClientIP()
|
||||||
|
|
||||||
multiPanelId, err := strconv.Atoi(ctx.Param("panelid"))
|
multiPanelId, err := strconv.Atoi(ctx.Param("panelid"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -31,6 +31,11 @@ func StartServer() {
|
|||||||
|
|
||||||
router := gin.Default()
|
router := gin.Default()
|
||||||
|
|
||||||
|
router.RemoteIPHeaders = append(router.RemoteIPHeaders, "CF-Connecting-IP")
|
||||||
|
if err := router.SetTrustedProxies(config.Conf.Server.TrustedProxies); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
// Sessions
|
// Sessions
|
||||||
session.Store = session.NewRedisStore()
|
session.Store = session.NewRedisStore()
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ type (
|
|||||||
Ratelimit Ratelimit
|
Ratelimit Ratelimit
|
||||||
Session Session
|
Session Session
|
||||||
Secret string
|
Secret string
|
||||||
|
TrustedProxies []string
|
||||||
}
|
}
|
||||||
|
|
||||||
Ratelimit struct {
|
Ratelimit struct {
|
||||||
@ -137,6 +138,7 @@ func fromEnvvar() {
|
|||||||
Secret: os.Getenv("SESSION_SECRET"),
|
Secret: os.Getenv("SESSION_SECRET"),
|
||||||
},
|
},
|
||||||
Secret: os.Getenv("JWT_SECRET"),
|
Secret: os.Getenv("JWT_SECRET"),
|
||||||
|
TrustedProxies: strings.Split(os.Getenv("TRUSTED_PROXIES"), ","),
|
||||||
},
|
},
|
||||||
Oauth: Oauth{
|
Oauth: Oauth{
|
||||||
Id: oauthId,
|
Id: oauthId,
|
||||||
|
@ -32,3 +32,4 @@
|
|||||||
- REDIS_PASSWORD
|
- REDIS_PASSWORD
|
||||||
- REDIS_THREADS
|
- REDIS_THREADS
|
||||||
- CACHE_URI
|
- CACHE_URI
|
||||||
|
- TRUSTED_PROXIES
|
||||||
|
2
go.mod
2
go.mod
@ -12,7 +12,7 @@ require (
|
|||||||
github.com/boj/redistore v0.0.0-20180917114910-cd5dcc76aeff // indirect
|
github.com/boj/redistore v0.0.0-20180917114910-cd5dcc76aeff // indirect
|
||||||
github.com/gin-contrib/static v0.0.0-20191128031702-f81c604d8ac2
|
github.com/gin-contrib/static v0.0.0-20191128031702-f81c604d8ac2
|
||||||
github.com/gin-gonic/contrib v0.0.0-20191209060500-d6e26eeaa607
|
github.com/gin-gonic/contrib v0.0.0-20191209060500-d6e26eeaa607
|
||||||
github.com/gin-gonic/gin v1.7.1
|
github.com/gin-gonic/gin v1.7.2-0.20210726235953-11aa11a65618
|
||||||
github.com/go-redis/redis v6.15.9+incompatible
|
github.com/go-redis/redis v6.15.9+incompatible
|
||||||
github.com/golang-jwt/jwt v3.2.1+incompatible
|
github.com/golang-jwt/jwt v3.2.1+incompatible
|
||||||
github.com/gorilla/sessions v1.2.0 // indirect
|
github.com/gorilla/sessions v1.2.0 // indirect
|
||||||
|
Loading…
x
Reference in New Issue
Block a user