Closed
Bug 304822
Opened 19 years ago
Closed 12 years ago
PAC: myIpAddress() returns 127.0.0.1 on linux (works on windows)
Categories
(Core :: Networking, defect)
Tracking
()
RESOLVED
DUPLICATE
of bug 347307
People
(Reporter: matteo.valsasna, Unassigned)
References
Details
Attachments
(1 file)
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.10) Gecko/20050720 Fedora/1.0.6-1.1.fc3 Firefox/1.0.6 Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.10) Gecko/20050720 Fedora/1.0.6-1.1.fc3 Firefox/1.0.6 there have been various reports about the myIpAddress() function in proxy.pac scripts non behaving correctly, see https://bugzilla.mozilla.org/show_bug.cgi?id=246872, https://bugzilla.mozilla.org/show_bug.cgi?id=299414. the problem doesn't really look fixed. we found that on linux this function consistently returns the loopback address instead a valid interface address. the following proxy.pac, script demonstrates this: function FindProxyForURL(url, host) { alert("I think my IP address is " + myIpAddress()); } in the contest of the proxy.pac script interpretation, the alert() function prints a message in the javascript console thanks to Gabriele Colombo for the script. Reproducible: Always Steps to Reproduce: 1. put the above script on a web server, configure the appropriate mime type (see http://wp.netscape.com/eng/mozilla/2.0/relnotes/demo/proxy-live.html) 2. configure an automatic proxy configuration url pointing to the above script 3. fire up the javascript console 4. load any web page Actual Results: messages in javascript console: PAC-alert: I think my IP address is 127.0.0.1 Expected Results: messages in javascript console: PAC-alert: I think my IP address is <ip address of the physical interface> tested under linux FC3, mozilla 1.0.6 and 1.0.0, with the same actual results the same test under windows XP, mozilla 1.0.0, gives the expected result (IP of the ethernet interface), so the problem should be linux specific the value of myIpAddress is computed in: /usr/lib/firefox-1.0.6/components/nsProxyAutoConfig.js by this function: // wrapper for getting local IP address called by PAC file function myIpAddress() { try { return dns.resolve(dns.myHostName, 0).getNextAddrAsString(); } catch (e) { return '127.0.0.1'; } } the same function is used under windows (where it works)...
Reporter | ||
Comment 1•19 years ago
|
||
Updated•19 years ago
|
Assignee: nobody → darin
Component: General → Networking
Product: Firefox → Core
QA Contact: general → benc
Version: unspecified → 1.7 Branch
Reporter | ||
Comment 2•19 years ago
|
||
I tried adding some debugging code to /usr/lib/firefox-1.0.6/components/nsProxyAutoConfig.js: // wrapper for getting local IP address called by PAC file function myIpAddress() { try { proxyAlert("nsProxyAutoconfig.js:myIpAddress()"); proxyAlert("nsProxyAutoconfig.js:myIpAddress() dns.myHostName: " + dns.myHostName); proxyAlert("nsProxyAutoconfig.js:myIpAddress() returning" + dns.resolve(dns.myHostName, 0).getNextAddrAsString()); return dns.resolve(dns.myHostName, 0).getNextAddrAsString(); } catch (e) { proxyAlert("nsProxyAutoconfig.js:myIpAddress() dns failed"); return '127.0.0.1'; } } the resulting messages in the javascript console were: PAC-alert: nsProxyAutoconfig.js:myIpAddress() PAC-alert: nsProxyAutoconfig.js:myIpAddress() dns.myHostName: muccalla PAC-alert: nsProxyAutoconfig.js:myIpAddress() dns failed dns.myHostName returns an unqualified domain name, this name isn't resolved by dns, and the query fails. the name wasn't resolved because it was registered in a domain that wasn't in the dns search path. adding this domain to the dns search path in resolv.conf resulted in the unqualified domain name being resolved, and in the script working: PAC-alert: nsProxyAutoconfig.js:myIpAddress() dns.myHostName: muccalla PAC-alert: nsProxyAutoconfig.js:myIpAddress() returning <real client IP> PAC-alert: I think my IP address is <real client IP> then, if you want the IpmyIpAddress() to work correctly, the following conditions must be met: * the client's hostname must be in DNS, and this registration must always be correct (so if the client is using DHCP, it must also do DDNS) * the domain in which the client hostname is registered must be in its dns domain search list (and if the client is configured by DHCP, you can only pass a default domain to the client, and this default domain must be the one where its domain name is registered by DDNS). these conditions are very strict, expecially for mobile clients, who can connect from anywhere, and you cannot control if and how their name gets registered in dns. I think the myIpAddress logic should really be changed, looking at interface address instead of DNS registrations. Can this be done in javascript?
Comment 3•19 years ago
|
||
it's enough if the hostname is in /etc/hosts... I doubt looking at interface addresses can be done in JS. And how do you decide which interface to use?
Reporter | ||
Comment 4•19 years ago
|
||
> it's enough if the hostname is in /etc/hosts...
right, but how do you set if the client population isn't under your administration?
remember that the IP can be dynamic, so /etc/hosts should be updated every time
the IP address changes.
probably some distribution already do that in the network init scripts (?)
as to which interface, in other bugs on the same topic someone suggested "the
interface used to reach the default route". should be the right thing, at least
most of the times.
I also have this problem, however, the reason is different. For some reason the following returns "undefined" var dns = Components.classes["@mozilla.org/network/dns-service;1"]; alert(dns.myHostName); But the following returns the correct hostname/ip address. alert(java.net.InetAddress.getLocalHost()) My /etc/hosts does contain the entry for my machine.
Comment 6•19 years ago
|
||
(In reply to comment #5) > var dns = Components.classes["@mozilla.org/network/dns-service;1"]; missing .getService(Components.interfaces.nsIDNSService)
Updated•18 years ago
|
Assignee: darin → nobody
QA Contact: benc → networking
Version: 1.7 Branch → Trunk
Updated•12 years ago
|
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•