diff --git a/APIServer.exe b/APIServer.exe index 6c64e64..b4e6f31 100644 Binary files a/APIServer.exe and b/APIServer.exe differ diff --git a/APIServer.go b/APIServer.go index 9b166c3..2a2674e 100644 --- a/APIServer.go +++ b/APIServer.go @@ -228,10 +228,13 @@ func handleRequest(w http.ResponseWriter, r *http.Request) { if r.RequestURI == "/favicon.ico" { return } - if r.Method != http.MethodPost { - w.WriteHeader(http.StatusMethodNotAllowed) - fmt.Fprintf(w, "MethodNotAllowed: %v\r\n", http.StatusMethodNotAllowed) - return + + if cfg.Settings.MustPost { + if r.Method != http.MethodPost { + w.WriteHeader(http.StatusMethodNotAllowed) + fmt.Fprintf(w, "MethodNotAllowed: %v\r\n", http.StatusMethodNotAllowed) + return + } } reqID := uuid.NewV4().String() @@ -351,8 +354,7 @@ func handleSetUutInfo(w http.ResponseWriter, r *http.Request) { host := "" if cfg.Settings.HostMode == 0 { host = strings.Split(r.Host, ":")[0] - } - if cfg.Settings.HostMode == 1 { + } else { host, err = os.Hostname() if err != nil { host = "hostname" diff --git a/APIServer.yml b/APIServer.yml index 117d1af..3fa740a 100644 --- a/APIServer.yml +++ b/APIServer.yml @@ -3,6 +3,7 @@ Settings: HookScript: APIHOOK # HostMode: 0=IP Address; 1=Hostname HostMode: 1 + MustPost: false ParamCheck: false LogRequest: false LogResponse: false diff --git a/cnf/cnf.go b/cnf/cnf.go index eb4a269..80fdd57 100644 --- a/cnf/cnf.go +++ b/cnf/cnf.go @@ -9,6 +9,7 @@ type Settings struct { ListenPort string `yaml:"ListenPort"` HookScript string `yaml:"HookScript"` HostMode int `yaml:"HostMode"` + MustPost bool `yaml:"MustPost"` ParamCheck bool `yaml:"ParamCheck"` LogRequest bool `yaml:"LogRequest"` LogResponse bool `yaml:"LogResponse"`