MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / resolveRemoteIP

Function resolveRemoteIP

internal/api/redis_queue_protocol.go:343–379  ·  view source on GitHub ↗
(addr net.Addr)

Source from the content-addressed store, hash-verified

341}
342
343func resolveRemoteIP(addr net.Addr) (ip string, localClient bool) {
344 if addr == nil {
345 return "", false
346 }
347
348 var host string
349 switch a := addr.(type) {
350 case *net.TCPAddr:
351 if a != nil && a.IP != nil {
352 if ip4 := a.IP.To4(); ip4 != nil {
353 host = ip4.String()
354 } else {
355 host = a.IP.String()
356 }
357 }
358 default:
359 host = addr.String()
360 if h, _, errSplit := net.SplitHostPort(host); errSplit == nil {
361 host = h
362 }
363 host = strings.TrimSpace(host)
364 if raw, _, ok := strings.Cut(host, "%"); ok {
365 host = raw
366 }
367 if parsed := net.ParseIP(host); parsed != nil {
368 if ip4 := parsed.To4(); ip4 != nil {
369 host = ip4.String()
370 } else {
371 host = parsed.String()
372 }
373 }
374 }
375
376 host = strings.TrimSpace(host)
377 localClient = host == "127.0.0.1" || host == "::1"
378 return host, localClient
379}
380
381func parseAuthPassword(args []string) (string, bool) {
382 switch len(args) {

Callers 1

handleRedisConnectionMethod · 0.85

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected