samuong / alpaca

A local HTTP proxy for command-line tools. Supports PAC scripts and NTLM authentication.
Apache License 2.0
184 stars 31 forks source link

The myIpAddress() function returns an unexpected IP address #122

Closed samuong closed 1 month ago

samuong commented 1 month ago

The current implementation of myIpAddress() iterates over the list of interface addresses from net.InterfaceAddrs(), skipping over any IPv6 addresses, and IPv4 loopback addresses. Otherwise it returns the first IP address that it finds.

For example, a laptop's WiFi adapter might have an IP address of 192.168.1.2, but when connected to my corporate VPN, it will also have a network interface with the address 10.1.2.3. In many cases, Alpaca's implementation of myIpAddress() will pick the first address, which is not the internet-bound address, and not what many PAC scripts expect.

Alpaca is also inconsistent with the approaches taken by other implementations like Chrome and Firefox. We should align on either of these approaches, or at least do something similar.

ziyiwang commented 3 weeks ago

yup, confirmes this is working as expected on ourside, its now picking up the internet bound IP.