mirror of
https://github.com/tobychui/zoraxy.git
synced 2025-06-01 13:17:21 +02:00
Fixed #629
- Added $remote_ip to remote port number from remote address
This commit is contained in:
parent
ca7cd0476c
commit
b863a9720f
@ -2,6 +2,7 @@ package rewrite
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
@ -14,6 +15,11 @@ func GetHeaderVariableValuesFromRequest(r *http.Request) map[string]string {
|
|||||||
// Request-specific variables
|
// Request-specific variables
|
||||||
vars["$host"] = r.Host
|
vars["$host"] = r.Host
|
||||||
vars["$remote_addr"] = r.RemoteAddr
|
vars["$remote_addr"] = r.RemoteAddr
|
||||||
|
remoteIP, _, err := net.SplitHostPort(r.RemoteAddr)
|
||||||
|
if err != nil {
|
||||||
|
remoteIP = r.RemoteAddr // Fallback to the full RemoteAddr if parsing fails
|
||||||
|
}
|
||||||
|
vars["$remote_ip"] = remoteIP
|
||||||
vars["$request_uri"] = r.RequestURI
|
vars["$request_uri"] = r.RequestURI
|
||||||
vars["$request_method"] = r.Method
|
vars["$request_method"] = r.Method
|
||||||
vars["$content_length"] = fmt.Sprintf("%d", r.ContentLength)
|
vars["$content_length"] = fmt.Sprintf("%d", r.ContentLength)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user