Current time: 12-18-2017, 06:47 PM Hello There, Guest! (LoginRegister)

Post Reply 
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Ability to set a Proxy in a script
05-17-2014, 07:59 AM
Post: #1
Ability to set a Proxy in a script
Is there anyways I can simply say use the following proxy for all http or https traffic. Much in the same way that modern browsers typically provide the proxy functionality?

I am thinking something to the effect of :
{code}
firefoxPref network.proxy.http 192.168.22.27
firefoxPref network.proxy.http_port 80
firefoxPref network.proxy.no_proxies_on localhost, 127.0.0.1
navigate http://www.google.com
{code}

Please note the above script does not work but just provided to give an idea of what I want to achieve whether it is IE, FF or Chrome

Is this possible?
Find all posts by this user
Quote this message in a reply
05-21-2014, 07:35 AM
Post: #2
RE: Ability to set a Proxy in a script
More specifically please see below in Chrome this is actually possible

https://code.google.com/p/chromium/codes...e=cs&l=793


For example: "MAP * 127.0.0.1" --> Forces all hostnames to be mapped to 127.0.0.1
"MAP *.google.com proxy" --> Forces all google.com subdomains to be resolved to "proxy".
"MAP test.com [::1]:77 --> Forces "test.com" to resolve to IPv6 loopback. Will also force the port of the resulting socket address to be 77.
"MAP * baz, EXCLUDE http://www.google.com" --> Remaps everything to "baz", except for "www.google.com".
These mappings apply to the endpoint host in a net::URLRequest (the TCP connect and host resolver in a direct connection, and the CONNECT in an http proxy connection, and the endpoint host in a SOCKS proxy connection)
Find all posts by this user
Quote this message in a reply
05-23-2014, 12:29 AM
Post: #3
RE: Ability to set a Proxy in a script
For Chrome you can just specify whatever you want on the command-line (in the chrome tab of the advanced settings). You can either use the direct mappings or you can specify the proxy.

If you specify a proxy, you should use a PAC script that doesn't proxy localhost traffic, otherwise the testing itself will fail (and you'll probably need to host the pac file somewhere).

Here's a PAC script that I've used before:

Code:
function FindProxyForURL(url, host) {
  var lhost = host.toLowerCase();
  host = lhost;

  if ((host == "localhost") ||
      (shExpMatch(host, "localhost.*")) ||
      (host == "127.0.0.1")) {
    return "DIRECT";
  }

  if (url.substring(0,5) == "http:") {
    return "PROXY proxy.example.com:80";
  }

  return "DIRECT";
}
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)