(action string, listType IPListType, item *pb.IPItem)
| 48 | } |
| 49 | |
| 50 | func (this *HTTPAPIAction) runAction(action string, listType IPListType, item *pb.IPItem) error { |
| 51 | if item == nil { |
| 52 | return nil |
| 53 | } |
| 54 | |
| 55 | // TODO 增加节点ID等信息 |
| 56 | m := maps.Map{ |
| 57 | "action": action, |
| 58 | "listType": listType, |
| 59 | "item": maps.Map{ |
| 60 | "type": item.Type, |
| 61 | "ipFrom": item.IpFrom, |
| 62 | "ipTo": item.IpTo, |
| 63 | "expiredAt": item.ExpiredAt, |
| 64 | }, |
| 65 | } |
| 66 | mJSON, err := json.Marshal(m) |
| 67 | if err != nil { |
| 68 | return err |
| 69 | } |
| 70 | req, err := http.NewRequest(http.MethodPost, this.config.URL, bytes.NewReader(mJSON)) |
| 71 | if err != nil { |
| 72 | return err |
| 73 | } |
| 74 | req.Header.Set("User-Agent", teaconst.GlobalProductName+"-Node/"+teaconst.Version) |
| 75 | resp, err := httpAPIClient.Do(req) |
| 76 | if err != nil { |
| 77 | return err |
| 78 | } |
| 79 | _ = resp.Body.Close() |
| 80 | return nil |
| 81 | } |
no test coverage detected