diff --git a/README.MD b/README.MD index df9c4c6..a28135b 100644 --- a/README.MD +++ b/README.MD @@ -17,6 +17,8 @@ import ( ## 配置 ```yaml +#global: +# enableauth: true # 开启鉴权(默认开启) httpauth: onsubaddr: http://localhost:9091/subauth onpubaddr: http://localhost:9091/pubauth diff --git a/auth.go b/auth.go index 44a868f..833177a 100644 --- a/auth.go +++ b/auth.go @@ -32,10 +32,12 @@ func (p *HttpAuthConfig) checkAPIOK(addr string, buf []byte) bool { return true } else { if resp, err := http.Post(addr, "application/json", bytes.NewBuffer(buf)); err == nil { - plugin.Info("Auth", zap.String("addr", addr), zap.Int("http_code", resp.StatusCode)) + plugin.Info("auth resp", zap.String("addr", addr), zap.Int("http_code", resp.StatusCode)) if resp.StatusCode == http.StatusOK { return true } + } else { + plugin.Error("auth req fail", zap.Error(err)) } } return false diff --git a/main.go b/main.go index 102cd38..55ce943 100644 --- a/main.go +++ b/main.go @@ -20,12 +20,13 @@ type HttpAuthConfig struct { } func (p *HttpAuthConfig) OnEvent(event any) { - switch event.(type) { + switch e := event.(type) { case FirstConfig: //插件初始化逻辑 plugin.Info("Config", zap.String("OnSubAddr", p.OnSubAddr)) plugin.Info("Config", zap.String("OnPubAddr", p.OnPubAddr)) p.changeAuthHook() case config.Config: //插件热更新逻辑 + e.Unmarshal(p) } }