Closed Bug 299414 Opened 19 years ago Closed 12 years ago

myIpAddress() doesn't work in PAC file. Javascript console returns myIpAddress is not defined

Categories

(Core :: Networking, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED INCOMPLETE

People

(Reporter: drson, Unassigned)

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4

i have folowing PAC file:

function FindProxyForURL(url,host)
{
    if ((myIpAddress() == "10.12.17.70") && (host == "google.com"))
    {
        return "DIRECT";
    }
    return "PROXY 10.12.17.65:3128";
}

It always returns PROXY, instead of DIRECT. When i delete myIpAddress part, it
returns DIRECT.
When i write myIpAddress() to Javascript Console, it says "myIpAddress is not
defined"

Reproducible: Always

Steps to Reproduce:
1. put proxy.pac file to a web server and set it up in Connection settings.
2. Navigate to page, where you'll see your IP address.
3. You'll see IP address of computer running proxy, not yours.

Actual Results:  
IP of machine running proxy appeared

Expected Results:  
According to PAC file, it should return DIRECT, instead of PROXY and use direct
connection, so IP of my computer would be shown, instead of proxy IP.

This bug was filed previously and has been considered as fixed
(https://bugzilla.mozilla.org/show_bug.cgi?id=246872).
Assignee: nobody → darin
Component: General → Networking
Product: Firefox → Core
QA Contact: general → benc
Version: unspecified → 1.0 Branch
This is because the PAC file namespace is separate. This function is defined in
nsProxyAutoConfig.js file in mozilla installation. To achive the same effect, try the following in the JS console.

var dns = Components.classes["@mozilla.org/network/dns-service;1"]; alert((dns.getService(Components.interfaces.nsIDNSService).resolve(dns.myHostName, 0)).getNextAddrAsString());
I don't really understand the part described in the steps. Can you give more details?

You are using this PAC as your browser PAC.
You are using the proxy to access what page?
(In reply to comment #2)
> I don't really understand the part described in the steps. Can you give more
> details?
> 
> You are using this PAC as your browser PAC.
> You are using the proxy to access what page?
> 

I use router at home to acces outer world with proxy and wpad (PAC file is at http://wpad.internal.domain.tld/wpad.dat). It's connected to wireless community network (using private IP space, so it's hardly reproducable in same state as i use it) and i use proxy to access outer world (internal network and internet). But there's a server in internal network which i'd like to access directly instead of using proxy. So i tried to write a PAC file that would detect my ip address and target host and returned direct access (i'm not only person using this proxy, but only one who wants access target server directly). When i tried script described above (with internal addres of target server instead of "google.com") IP of my router running proxy appears on the page instead of IP of my computer. This situation could be reproducable in Internet when you write your own PAC file and try to access page that shows your IP address (for example http://www.ipv6tf.org/meet/history.php) and your proxy has different IP address than your computer (from server view). You can try to use some open proxy (which had definitely other IP adress than your computer with direct connection).
Put an an "alert()" satement in your PAC file, it will send the text to javascript console.

You will find that the returned IP address is either 127.0.0.1 or some other unacceptable number. There are various bugs open on this problem already.
Assignee: darin → nobody
QA Contact: benc → networking
Version: 1.0 Branch → Trunk
incomplete - this is very likely a bug of the 127.0.0.1 bug
Status: UNCONFIRMED → RESOLVED
Closed: 12 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.