support different method to get hostaddr
This commit is contained in:
parent
af9d0eb6a5
commit
0cd47265df
BIN
APIServer.exe
BIN
APIServer.exe
Binary file not shown.
13
APIServer.go
13
APIServer.go
@ -345,7 +345,18 @@ func handleSetUutInfo(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
host := strings.Split(r.Host, ":")[0]
|
var err error
|
||||||
|
host := ""
|
||||||
|
if cfg.Settings.HostMode == 0 {
|
||||||
|
host = strings.Split(r.Host, ":")[0]
|
||||||
|
}
|
||||||
|
if cfg.Settings.HostMode == 1 {
|
||||||
|
host, err = os.Hostname()
|
||||||
|
if err != nil {
|
||||||
|
host = "hostname"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
addr := strings.Split(r.RemoteAddr, ":")[0]
|
addr := strings.Split(r.RemoteAddr, ":")[0]
|
||||||
uri := r.RequestURI
|
uri := r.RequestURI
|
||||||
rst := map[string]string{"RESULT": ""}
|
rst := map[string]string{"RESULT": ""}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
Settings:
|
Settings:
|
||||||
ListenPort: 9000
|
ListenPort: 9000
|
||||||
HookScript: APIHOOK
|
HookScript: APIHOOK
|
||||||
|
# AddrMode: 0=IP Address; 1=Hostname
|
||||||
|
AddrMode: 1
|
||||||
ParamCheck: false
|
ParamCheck: false
|
||||||
LogRequest: true
|
LogRequest: true
|
||||||
LogResponse: false
|
LogResponse: false
|
||||||
|
@ -8,6 +8,7 @@ type Cfg struct {
|
|||||||
type Settings struct {
|
type Settings struct {
|
||||||
ListenPort string `yaml:"ListenPort"`
|
ListenPort string `yaml:"ListenPort"`
|
||||||
HookScript string `yaml:"HookScript"`
|
HookScript string `yaml:"HookScript"`
|
||||||
|
HostMode int `yaml:"HostMode"`
|
||||||
ParamCheck bool `yaml:"ParamCheck"`
|
ParamCheck bool `yaml:"ParamCheck"`
|
||||||
LogRequest bool `yaml:"LogRequest"`
|
LogRequest bool `yaml:"LogRequest"`
|
||||||
LogResponse bool `yaml:"LogResponse"`
|
LogResponse bool `yaml:"LogResponse"`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user