4 ms·
The latter. You can always set your /etc/hosts or equivalent to map "localhost" to some random IP that is not loopback. Or a proxy could proxy that hostname,
by bzbarsky 6y ago
The latter. You can always set your /etc/hosts or equivalent to map "localhost" to some random IP that is not loopback. Or a proxy could proxy that hostname, etc.
In the new setup proxies can't proxy localhost unless you set a pref to explicitly let them do that, and for "localhost" and hostnames ending in ".localhost" Firefox won't even ask the DNS stack for the IP, assuming loopback instead.
- cesarb 6y ago> Firefox won't even ask the DNS stack for the IP, assuming loopback instead. Which loopback, 127.0.0.1, ::1, or both?
- arp242 6y agoYou have all of 127.0.0.0/8 as a loopback; I hope it doesn't hard-code 127.0.0.1 as I use some other addresses as well.
- bzbarsky 6y ago"localhost" is hardcoded to resolve to "127.0.0.1" (ignoring IPv6 for now). The "is secure context" state applies to 127.0.0.0/8 (again ignoring IPv6). See NetAddr::IsLoopBackAddressWithoutIPv6Mapping in https://searchfox.org/mozilla-central/source/netwerk/dns/DNS.cpp https://searchfox.org/mozilla-central/source/netwerk/dns/DNS... I'm pretty sure all of this is clearly specified at this point, so browsers should end up all aligning on a common behavior here at some point, if they haven't yet.
- bzbarsky 6y agoLooking at the code in the DNS service in Firefox, it kinda looks like this for localhost: 1) If IPv6 disabled in prefs or caller explicitly requested IPv4 only, 127.0.0.1. 2) If localhost explicitly listed in the IPv4-only domains list in prefs, 127.0.0.1. 3) If caller explicitly requested IPv6 only, ::1. 4) Otherwise both 127.0.0.1 and ::1. See nsHostResolver::InitLoopbackRecord in https://searchfox.org/mozilla-central/source/netwerk/dns/nsHostResolver.cpp https://searchfox.org/mozilla-central/source/netwerk/dns/nsH... and nsDNSService::GetAFForLookup in https://searchfox.org/mozilla-central/source/netwerk/dns/nsDNSService2.cpp https://searchfox.org/mozilla-central/source/netwerk/dns/nsD... for the key.af calculation that goes into that, as far as I can tell.
- deleted 6y ago[deleted]
- Konohamaru 6y agoIt is amazing to behold a comment written in wizard-tongue like the above.