MCPcopy
hub / github.com/cloudflare/cloudflared / GetByIP

Method GetByIP

cfapi/ip_route.go:197–213  ·  view source on GitHub ↗

GetByIP checks which route will proxy a given IP.

(params GetRouteByIpParams)

Source from the content-addressed store, hash-verified

195
196// GetByIP checks which route will proxy a given IP.
197func (r *RESTClient) GetByIP(params GetRouteByIpParams) (DetailedRoute, error) {
198 endpoint := r.baseEndpoints.accountRoutes
199 endpoint.Path = path.Join(endpoint.Path, "ip", url.PathEscape(params.Ip.String()))
200 setVnetParam(&endpoint, params.VNetID)
201
202 resp, err := r.sendRequest("GET", endpoint, nil)
203 if err != nil {
204 return DetailedRoute{}, errors.Wrap(err, "REST request failed")
205 }
206 defer resp.Body.Close()
207
208 if resp.StatusCode == http.StatusOK {
209 return parseDetailedRoute(resp.Body)
210 }
211
212 return DetailedRoute{}, r.statusCodeToError("get route by IP", resp)
213}
214
215func parseRoute(body io.ReadCloser) (Route, error) {
216 var route Route

Callers

nothing calls this directly

Calls 6

sendRequestMethod · 0.95
statusCodeToErrorMethod · 0.95
setVnetParamFunction · 0.85
parseDetailedRouteFunction · 0.85
StringMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected