mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-07-01 12:32:09 +00:00
11 / getRemoteIp - priorityHeader
11 / getRemoteIp - priorityHeader from env
This commit is contained in:
parent
7a8a2a1388
commit
f3b7e3cc6d
3 changed files with 17 additions and 2 deletions
|
@ -9,4 +9,5 @@ XUI_VLESS_SNI=""
|
||||||
#XUI_SUB_SUPPORT_URL=""
|
#XUI_SUB_SUPPORT_URL=""
|
||||||
#XUI_SUB_PROFILE_WEB_PAGE_URL=""
|
#XUI_SUB_PROFILE_WEB_PAGE_URL=""
|
||||||
#XUI_DEBUG="false"
|
#XUI_DEBUG="false"
|
||||||
#XUI_LOG_LEVEL="info"
|
#XUI_LOG_LEVEL="info"
|
||||||
|
#XUI_GETREMOTEIP_PRIORITY_HEADER=""
|
|
@ -51,6 +51,7 @@ services:
|
||||||
XUI_SUB_PROFILE_TITLE: "${XUI_SUB_PROFILE_TITLE:-}"
|
XUI_SUB_PROFILE_TITLE: "${XUI_SUB_PROFILE_TITLE:-}"
|
||||||
XUI_SUB_SUPPORT_URL: "${XUI_SUB_SUPPORT_URL:-}"
|
XUI_SUB_SUPPORT_URL: "${XUI_SUB_SUPPORT_URL:-}"
|
||||||
XUI_SUB_PROFILE_WEB_PAGE_URL: "${XUI_SUB_PROFILE_WEB_PAGE_URL:-}"
|
XUI_SUB_PROFILE_WEB_PAGE_URL: "${XUI_SUB_PROFILE_WEB_PAGE_URL:-}"
|
||||||
|
XUI_GETREMOTEIP_PRIORITY_HEADER: "${XUI_GETREMOTEIP_PRIORITY_HEADER:-}"
|
||||||
XUI_DEBUG: "${XUI_DEBUG:-false}"
|
XUI_DEBUG: "${XUI_DEBUG:-false}"
|
||||||
XUI_LOG_LEVEL: "${XUI_LOG_LEVEL:-info}"
|
XUI_LOG_LEVEL: "${XUI_LOG_LEVEL:-info}"
|
||||||
tty: true
|
tty: true
|
||||||
|
|
|
@ -3,6 +3,7 @@ package controller
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"x-ui/config"
|
"x-ui/config"
|
||||||
|
@ -13,7 +14,19 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func getRemoteIp(c *gin.Context) string {
|
func getRemoteIp(c *gin.Context) string {
|
||||||
value := c.GetHeader("X-Real-IP")
|
var value string
|
||||||
|
priorityHeader := os.Getenv("XUI_GETREMOTEIP_PRIORITY_HEADER")
|
||||||
|
if priorityHeader != "" {
|
||||||
|
value = c.GetHeader(priorityHeader)
|
||||||
|
if strings.Contains(value, ",") {
|
||||||
|
ips := strings.Split(value, ",")
|
||||||
|
value = ips[0]
|
||||||
|
}
|
||||||
|
if value != "" {
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
value = c.GetHeader("X-Real-IP")
|
||||||
if value != "" {
|
if value != "" {
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue