|
|
Make Little Snitch and GlimmerBlocker work together
#!/usr/bin/perl
###############################################################################
# #
# Automatic Proxy Configuration (.pac file) server #
# #
# A horribly simple and simply horrible CGI script to configure #
# some applications to use a proxy, and all others to not use a proxy, #
# thereby solving GlimmerBlocker vs LittleSnitch conflicts. #
# #
# Based on a hint by macosxhints.com user 'emale' and ensuing discussion #
# http://www.macosxhints.com/article.php?story=20091228114759199 #
# #
# Published as is, without any guarantees, YMMV, etc. etc. #
# Comments and suggestions: see macosxhints discussion above #
###############################################################################
use strict;
my $VERSION = 0.1;
my ($proxy, $reply, $usingproxy, $pac);
###### configurable bits ######
# response to use a proxy. 'PROXY 127.0.0.1:8228' is GlimmerBlocker's default
$proxy = 'PROXY 127.0.0.1:8228';
# default response. 'DIRECT' means no proxy
$reply = 'DIRECT';
# list of user agents which should use the proxy, separated by |
# Apps matching $usingproxy receive the $proxy reply, all others the default $reply.
$usingproxy = 'OmniWeb|Safari';
###### no configurable bits below ######
# build reply. This is the interesting part.
$reply = $proxy if $ENV{HTTP_USER_AGENT} =~ m/$usingproxy/;
$pac = "Content-type: application/x-ns-proxy-autoconfig\n\nfunction FindProxyForURL(url, host) { return '$reply'; }";
# write to log
open FH, '>>/private/tmp/pacserver.log' or warn "pacserver could not open log\n";
print FH scalar localtime() . " '$reply' for $ENV{HTTP_USER_AGENT}\n";
close FH;
# send reply
if ($ENV{PATH_INFO} eq '/status' ) {
print "Content-type: text/html; charset=utf-8\n\n
Make Little Snitch and GlimmerBlocker work together
Sorry for a dumb question - can you explain, where i need to put this perl *.pac file?
Make Little Snitch and GlimmerBlocker work together
Sorry, my bad, I was just responding to the request to donate the Perl code.
The script is a CGI script, which means you need a webserver running, same as for the original hint.
Put it wherever you keep CGI scripts for your webserver. On Mac OS X, that would be /Library/WebServer/CGI-Executables by default, and make it executable by changing to that folder and:
chmod 755 pacserverTest the script by pointing your browser to http://127.0.0.1/cgi-bin/pacserver/status That should give a response like
Content-type: application/x-ns-proxy-autoconfig
function FindProxyForURL(url, host) { return 'PROXY 127.0.0.1:8228'; }
If that works, enter http://127.0.0.1/cgi-bin/pacserver as the Proxy Configuration File in System Preferences (as per the original hint).
|
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysNo new commentsLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.06 seconds |
|