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
|
||||
}
|
||||
|
||||
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": ""}
|
||||
|
@ -1,6 +1,8 @@
|
||||
Settings:
|
||||
ListenPort: 9000
|
||||
HookScript: APIHOOK
|
||||
# AddrMode: 0=IP Address; 1=Hostname
|
||||
AddrMode: 1
|
||||
ParamCheck: false
|
||||
LogRequest: true
|
||||
LogResponse: false
|
||||
|
@ -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"`
|
||||
|
Loading…
x
Reference in New Issue
Block a user