diff --git a/APIServer.exe b/APIServer.exe index dc31426..0179c20 100644 Binary files a/APIServer.exe and b/APIServer.exe differ diff --git a/APIServer.go b/APIServer.go index 446f185..ed38468 100644 --- a/APIServer.go +++ b/APIServer.go @@ -345,7 +345,18 @@ func handleSetUutInfo(w http.ResponseWriter, r *http.Request) { 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] uri := r.RequestURI rst := map[string]string{"RESULT": ""} diff --git a/APIServer.yml b/APIServer.yml index 2a2e0ea..a916c22 100644 --- a/APIServer.yml +++ b/APIServer.yml @@ -1,6 +1,8 @@ Settings: ListenPort: 9000 HookScript: APIHOOK +# AddrMode: 0=IP Address; 1=Hostname + AddrMode: 1 ParamCheck: false LogRequest: true LogResponse: false diff --git a/cnf/cnf.go b/cnf/cnf.go index d71b238..0d174aa 100644 --- a/cnf/cnf.go +++ b/cnf/cnf.go @@ -8,6 +8,7 @@ type Cfg struct { type Settings struct { ListenPort string `yaml:"ListenPort"` HookScript string `yaml:"HookScript"` + HostMode int `yaml:"HostMode"` ParamCheck bool `yaml:"ParamCheck"` LogRequest bool `yaml:"LogRequest"` LogResponse bool `yaml:"LogResponse"`