support different method to get hostaddr

This commit is contained in:
r0n1n7an 2023-12-11 10:30:43 +08:00
parent af9d0eb6a5
commit 0cd47265df
4 changed files with 15 additions and 1 deletions

Binary file not shown.

View File

@ -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": ""}

View File

@ -1,6 +1,8 @@
Settings:
ListenPort: 9000
HookScript: APIHOOK
# AddrMode: 0=IP Address; 1=Hostname
AddrMode: 1
ParamCheck: false
LogRequest: true
LogResponse: false

View File

@ -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"`