real ip headers
This commit is contained in:
parent
412f140d34
commit
2fed274263
@ -1,7 +1,6 @@
|
|||||||
package http
|
package http
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"github.com/TicketsBot/GoPanel/app/http/endpoints/api"
|
"github.com/TicketsBot/GoPanel/app/http/endpoints/api"
|
||||||
api_autoclose "github.com/TicketsBot/GoPanel/app/http/endpoints/api/autoclose"
|
api_autoclose "github.com/TicketsBot/GoPanel/app/http/endpoints/api/autoclose"
|
||||||
api_blacklist "github.com/TicketsBot/GoPanel/app/http/endpoints/api/blacklist"
|
api_blacklist "github.com/TicketsBot/GoPanel/app/http/endpoints/api/blacklist"
|
||||||
@ -32,7 +31,7 @@ func StartServer() {
|
|||||||
|
|
||||||
router := gin.Default()
|
router := gin.Default()
|
||||||
|
|
||||||
router.RemoteIPHeaders = append(router.RemoteIPHeaders, "X-Forwarded-For", "X-Real-IP", "CF-Connecting-IP")
|
router.RemoteIPHeaders = config.Conf.Server.RealIpHeaders
|
||||||
if err := router.SetTrustedProxies(config.Conf.Server.TrustedProxies); err != nil {
|
if err := router.SetTrustedProxies(config.Conf.Server.TrustedProxies); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -48,12 +47,6 @@ func StartServer() {
|
|||||||
|
|
||||||
router.Use(middleware.Cors(config.Conf))
|
router.Use(middleware.Cors(config.Conf))
|
||||||
|
|
||||||
router.Use(func(ctx *gin.Context) {
|
|
||||||
fmt.Println(ctx.Request.Header)
|
|
||||||
fmt.Println(ctx.ClientIP())
|
|
||||||
fmt.Println(ctx.RemoteIP())
|
|
||||||
})
|
|
||||||
|
|
||||||
router.GET("/webchat", root.WebChatWs)
|
router.GET("/webchat", root.WebChatWs)
|
||||||
|
|
||||||
router.POST("/callback", middleware.VerifyXTicketsHeader, root.CallbackHandler)
|
router.POST("/callback", middleware.VerifyXTicketsHeader, root.CallbackHandler)
|
||||||
|
@ -28,6 +28,7 @@ type (
|
|||||||
Ratelimit Ratelimit
|
Ratelimit Ratelimit
|
||||||
Session Session
|
Session Session
|
||||||
Secret string
|
Secret string
|
||||||
|
RealIpHeaders []string
|
||||||
TrustedProxies []string
|
TrustedProxies []string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,6 +140,7 @@ func fromEnvvar() {
|
|||||||
},
|
},
|
||||||
Secret: os.Getenv("JWT_SECRET"),
|
Secret: os.Getenv("JWT_SECRET"),
|
||||||
TrustedProxies: strings.Split(os.Getenv("TRUSTED_PROXIES"), ","),
|
TrustedProxies: strings.Split(os.Getenv("TRUSTED_PROXIES"), ","),
|
||||||
|
RealIpHeaders: strings.Split(os.Getenv("REAL_IP_HEADERS"), ","),
|
||||||
},
|
},
|
||||||
Oauth: Oauth{
|
Oauth: Oauth{
|
||||||
Id: oauthId,
|
Id: oauthId,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user