mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-10 12:30:25 +08:00
增加${serverAddr}变量
This commit is contained in:
@@ -854,6 +854,18 @@ func (this *HTTPRequest) Format(source string) string {
|
|||||||
return this.requestHeadersString()
|
return this.requestHeadersString()
|
||||||
case "serverName":
|
case "serverName":
|
||||||
return this.ServerName
|
return this.ServerName
|
||||||
|
case "serverAddr":
|
||||||
|
var requestConn = this.RawReq.Context().Value(HTTPConnContextKey)
|
||||||
|
if requestConn != nil {
|
||||||
|
conn, ok := requestConn.(net.Conn)
|
||||||
|
if ok {
|
||||||
|
host, _, _ := net.SplitHostPort(conn.LocalAddr().String())
|
||||||
|
if len(host) > 0 {
|
||||||
|
return host
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""
|
||||||
case "serverPort":
|
case "serverPort":
|
||||||
return strconv.Itoa(this.requestServerPort())
|
return strconv.Itoa(this.requestServerPort())
|
||||||
case "hostname":
|
case "hostname":
|
||||||
|
|||||||
Reference in New Issue
Block a user