diff options
| author | Handingkang <[email protected]> | 2023-09-28 19:44:01 +0800 |
|---|---|---|
| committer | Handingkang <[email protected]> | 2023-09-28 19:44:01 +0800 |
| commit | 5b26c980df3df3ae1de66a545243d020fdc59679 (patch) | |
| tree | 46881d5f5fa71708562ce022c6c0e4092b50781f | |
| parent | 5b6c26964b264847880e69e0b43992fb574312ae (diff) | |
同步
| -rw-r--r-- | plugin/pkg/http/http.go | 14 | ||||
| -rw-r--r-- | plugin/pkg/prober/proberutil.go | 44 |
2 files changed, 14 insertions, 44 deletions
diff --git a/plugin/pkg/http/http.go b/plugin/pkg/http/http.go index 874b759..9a378c5 100644 --- a/plugin/pkg/http/http.go +++ b/plugin/pkg/http/http.go @@ -1,6 +1,7 @@ package http import ( + "encoding/json" "fmt" "net/http" ) @@ -10,6 +11,8 @@ func ParseRequest(req *http.Request) (map[string][]string, error) { switch req.Method { case http.MethodGet: return getRequest(req) + case http.MethodPost: + return postRequest(req) default: return nil, fmt.Errorf("method not allowed: %s", req.Method) @@ -23,3 +26,14 @@ func getRequest(req *http.Request) (map[string][]string, error) { } return r, nil } + +// 支持json方式处理 +func postRequest(req *http.Request) (map[string][]string, error) { + r := make(map[string][]string) + decoder := json.NewDecoder(req.Body) + err := decoder.Decode(&r) + if err != nil { + return nil, err + } + return r, nil +} diff --git a/plugin/pkg/prober/proberutil.go b/plugin/pkg/prober/proberutil.go index 5378d56..deaa6fb 100644 --- a/plugin/pkg/prober/proberutil.go +++ b/plugin/pkg/prober/proberutil.go @@ -76,47 +76,3 @@ func ip2Eid(ip net.IP) string { } return strings.ReplaceAll(i, ".", "-") } - -//func (p *Prober) startGlobScan(ctx context.Context) { -// -// p.wg.Add(p.worker) -// count := p.worker -// round := 1 -// if p.Loop { -// round = math.MaxInt -// } -// for { -// ipc := GenGlobIPv4() -// for { -// if ip, ok := <-ipc; ok { -// select { -// case <-ctx.Done(): -// // 中途取消 -// return -// default: -// go func() { -// _ = p.Probe(ip) -// p.ScannedAddr += 1 -// p.wg.Done() -// }() -// count -= 1 -// if count == 0 { -// p.wg.Wait() -// // 一批次全部完成,开始下一批次 -// count = p.worker -// p.wg.Add(p.worker) -// } -// } -// } else { -// // 一轮扫描完成 -// round -= 1 -// // 探测轮数归零,退出 -// if round == 0 { -// return -// } -// // 未归零,开始下一轮 -// break -// } -// } -// } -//} |
