Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Make Little Snitch and GlimmerBlocker work together' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Make Little Snitch and GlimmerBlocker work together
Authored by: superp on Jan 04, '10 03:11:18PM

Both work fine indeed, in the sense that no network traffic is stopped. Including the traffic you blocked in Little Snitch before.

A big thank you to the original poster, this is exactly what I was looking for. As I am no PHP expert, I rewrote the whole thing in Perl and made it write all requests and replies to a log file. Now I can configure on a client-by-client basis which clients go through Glimmer's ad filters (Omniweb, Safari) and which ones go to LSnitch where they are either blocked or allowed to pass. Beautiful.

Note that most apps pick up the proxy configuration once, when they start.



[ Reply to This | # ]
Make Little Snitch and GlimmerBlocker work together
Authored by: kaz219 on Jan 05, '10 01:50:25AM

could you post your perl version? Thanks.



[ Reply to This | # ]
Make Little Snitch and GlimmerBlocker work together
Authored by: superp on Jan 05, '10 06:38:53AM
#!/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
"; # yes, I know. Bite me.
}

print $pac;


[ Reply to This | # ]
Make Little Snitch and GlimmerBlocker work together
Authored by: VMatas on Jan 05, '10 11:36:57PM

Sorry for a dumb question - can you explain, where i need to put this perl *.pac file?



[ Reply to This | # ]
Make Little Snitch and GlimmerBlocker work together
Authored by: superp on Jan 07, '10 04:23:35AM
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 pacserver
Test 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).

[ Reply to This | # ]