MCPcopy
hub / github.com/dgraph-io/dgraph / AttachRemoteIP

Function AttachRemoteIP

x/x.go:541–553  ·  view source on GitHub ↗

AttachRemoteIP adds any incoming IP data into the grpc context metadata

(ctx context.Context, r *http.Request)

Source from the content-addressed store, hash-verified

539
540// AttachRemoteIP adds any incoming IP data into the grpc context metadata
541func AttachRemoteIP(ctx context.Context, r *http.Request) context.Context {
542 if ip, port, err := net.SplitHostPort(r.RemoteAddr); err == nil {
543 if intPort, convErr := strconv.Atoi(port); convErr == nil {
544 ctx = peer.NewContext(ctx, &peer.Peer{
545 Addr: &net.TCPAddr{
546 IP: net.ParseIP(ip),
547 Port: intPort,
548 },
549 })
550 }
551 }
552 return ctx
553}
554
555// isIpWhitelisted checks if the given ipString is within the whitelisted ip range
556func isIpWhitelisted(ipString string) bool {

Callers 5

loginHandlerFunction · 0.92
queryHandlerFunction · 0.92
alterHandlerFunction · 0.92
resolveWithAdminServerFunction · 0.92
ServeHTTPMethod · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected