in reply to :Problem with Parsing the Proxy Auto Configure File
proxy.pac
And the script that I came up with:function FindProxyForURL(url,host) { // loopback if ( host == "127.0.0.1" || host == "localhost" ) return "DIRECT"; if ( dnsDomainIs(host, "intra.example.com") ) return "PROXY proxy.example.jp:8080; DIRECT"; if ( isInNet(host, "192.168.108.0","255.255.255.0") ) return "DIRECT proxy.example.jp:8080"; return "PROXY"; }
proxy_pac.pl
#!/usr/bin/perl use strict; use warnings; use HTTP::ProxyPAC; use LWP::UserAgent; use Data::Dumper::Perltidy; my $accessor = '/root/Desktop/proxy.pac'; my $ua = LWP::UserAgent->new(timeout => 30); undef $ua; my $pac = HTTP::ProxyPAC->new($accessor); print Dumper( my $res = $pac->find_proxy( 'http://www.intra.example.com/') );
|
|---|