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

Function GetIPAddress

internal/util/ssh_helper.go:99–113  ·  view source on GitHub ↗

GetIPAddress attempts to find the best-available IP address. It first tries to get the public IP address, and if that fails, it falls back to getting the local outbound IP address. Returns: - string: The determined IP address (preferring public IPv4)

()

Source from the content-addressed store, hash-verified

97// Returns:
98// - string: The determined IP address (preferring public IPv4)
99func GetIPAddress() string {
100 publicIP, err := getPublicIP()
101 if err == nil {
102 log.Debugf("Public IP detected: %s", publicIP)
103 return publicIP
104 }
105 log.Warnf("Failed to get public IP, falling back to outbound IP: %v", err)
106 outboundIP, err := getOutboundIP()
107 if err == nil {
108 log.Debugf("Outbound IP detected: %s", outboundIP)
109 return outboundIP
110 }
111 log.Errorf("Failed to get any IP address: %v", err)
112 return "127.0.0.1" // Fallback
113}
114
115// PrintSSHTunnelInstructions detects the IP address and prints SSH tunnel instructions
116// for the user to connect to the local OAuth callback server from a remote machine.

Callers 1

Calls 2

getPublicIPFunction · 0.85
getOutboundIPFunction · 0.85

Tested by

no test coverage detected