summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan-Michael Brummer <jan.brummer@tabos.org>2023-03-12 10:39:51 +0100
committerJan-Michael Brummer <jan.brummer@tabos.org>2023-03-27 16:31:58 +0200
commit0a5e434eaf81dfdd9d4d3895de71a70efa4f5687 (patch)
tree13c8d934475259de9ac090a4ca654556ea3b3c6b
parent8aed359ca37c0fbdc020b144428222bffa7de4ac (diff)
downloadlibproxy-git-0a5e434eaf81dfdd9d4d3895de71a70efa4f5687.tar.gz
Use names in test pac file (#73)
-rw-r--r--tests/data/px-manager-sample.pac19
-rw-r--r--tests/px-manager-test.c1
2 files changed, 15 insertions, 5 deletions
diff --git a/tests/data/px-manager-sample.pac b/tests/data/px-manager-sample.pac
index 335c6b8..d623f22 100644
--- a/tests/data/px-manager-sample.pac
+++ b/tests/data/px-manager-sample.pac
@@ -1,18 +1,27 @@
function FindProxyForURL(url, host)
{
+ var resolved_ip = dnsResolve(host);
var myIP = myIpAddress();
+ var privateIP = /^(0|10|127|192\.168|172\.1[6789]|172\.2[0-9]|172\.3[01]|169\.254|192\.88\.99)\.[0-9.]+$/;
- if(shExpMatch(host,"192.168.10.4"))
+ if (shExpMatch(host, "192.168.10.4"))
return "SOCKS 127.0.0.1:1983"
- if(shExpMatch(host,"192.168.10.5"))
+ if (dnsDomainIs(host, "192.168.10.5"))
return "SOCKS4 127.0.0.1:1983"
- if(shExpMatch(host,"192.168.10.6"))
+ if (dnsDomainIs(host, "192.168.10.6"))
return "SOCKS4A 127.0.0.1:1983"
- if(shExpMatch(host,"192.168.10.7"))
+ if (dnsDomainIs(host, "192.168.10.7"))
return "SOCKS5 127.0.0.1:1983"
- return "PROXY 127.0.0.1:1983"
+ /* Don't send non-FQDN or private IP auths to us */
+ if (isPlainHostName(host) || isInNet(resolved_ip, "192.0.2.0","255.255.255.0") || privateIP.test(resolved_ip))
+ return "DIRECT";
+
+ if (dnsDomainIs(host, "www.example.com"))
+ return "PROXY 127.0.0.1:1983"
+
+ return "PROXY 127.0.0.1:1981"
}
diff --git a/tests/px-manager-test.c b/tests/px-manager-test.c
index c5d0bf3..1b1eb06 100644
--- a/tests/px-manager-test.c
+++ b/tests/px-manager-test.c
@@ -221,3 +221,4 @@ main (int argc,
return g_test_run ();
}
+