Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: terminalfool/Net-DNS-Dynamic-Adfilter
base: f2b8d26f5d
...
head fork: terminalfool/Net-DNS-Dynamic-Adfilter
compare: 8d32a6d2a8
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
View
3  Changes
@@ -1,5 +1,8 @@
Revision history for Perl module Net::DNS::Dynamic::Adfilter
+0.064 Tue May 8 11:34:20 EDT 2012
+ - accommodate ipv6, ^www and second level domain queries
+
0.063 Sat Apr 28 11:08:35 EDT 2012
- use Net::Address::IP::Local to address ::INET incompatibilities on some systems
View
4 dist.ini
@@ -1,9 +1,8 @@
name = Net-DNS-Dynamic-Adfilter
-version = 0.063
+version = 0.064
author = David Watson <dwatson@cpan.org>
license = Perl_5
copyright_holder = David Watson
-repo = https://github.com/terminalfool/Net-DNS-Dynamic-Adfilter
[GatherDir]
[MetaYAML]
@@ -19,3 +18,4 @@ match = dist.ini
[AutoPrereqs]
[@Git]
[GitHub::Meta]
+repo = https://github.com/terminalfool/Net-DNS-Dynamic-Adfilter
View
34 lib/Net/DNS/Dynamic/adfilter.pm
@@ -1,6 +1,6 @@
package Net::DNS::Dynamic::Adfilter;
-our $VERSION = '0.063';
+our $VERSION = '0.064';
use Moose 2.0403;
use LWP::Simple 6.00;
@@ -20,8 +20,8 @@ override 'run' => sub {
my $localip = Net::Address::IP::Local->public_ipv4;
#--switch dns settings on mac osx, wireless interface
- system("networksetup -setdnsservers \"Wi-Fi\" 127.0.0.1");
- system("networksetup -setsearchdomains \"Wi-Fi\" localhost");
+# system("networksetup -setdnsservers \"Wi-Fi\" 127.0.0.1");
+# system("networksetup -setsearchdomains \"Wi-Fi\" localhost");
#--
$self->log("Nameserver accessible locally @ $localip", 1);
@@ -30,11 +30,11 @@ override 'run' => sub {
};
#--restore dns settings on mac osx, wireless interface
-before 'signal_handler' => sub {
- my ( $self ) = shift;
- system('networksetup -setdnsservers "Wi-Fi" empty');
- system('networksetup -setsearchdomains "Wi-Fi" empty');
-};
+#before 'signal_handler' => sub {
+# my ( $self ) = shift;
+# system('networksetup -setdnsservers "Wi-Fi" empty');
+# system('networksetup -setsearchdomains "Wi-Fi" empty');
+#};
#--
around 'reply_handler' => sub { # query ad listings
@@ -85,16 +85,20 @@ after 'read_config' => sub {
sub query_adfilter {
my ( $self, $qname, $qtype ) = @_;
- $qname =~ s/^.*\.(\w+\.\w+)$/$1/ if ($qtype eq 'A' || $qtype eq 'AAAA');
-
return $self->search_ip_in_adfilter( $qname ) if ($qtype eq 'A' || $qtype eq 'AAAA');
return $self->search_hostname_by_ip( $qname ) if $qtype eq 'PTR';
}
sub search_ip_in_adfilter {
my ( $self, $hostname ) = @_;
-
- return '::1' if (exists $self->adfilter->{$hostname});
+ my $trim = $hostname;
+ my $sld = $hostname;
+ $trim =~ s/^www\.//i;
+ $sld =~ s/^.*\.(\w+\.\w+)$/$1/;
+
+ return '::1' if ( exists $self->adfilter->{$hostname} ||
+ exists $self->adfilter->{$trim} ||
+ exists $self->adfilter->{$sld} );
return;
}
@@ -293,9 +297,9 @@ Specify the port of the remote nameservers. Defaults to the standard port 53.
=head1 CAVEATS
-It will be necessary to manually adjust the host's network dns settings to take advantage
-of the filtering. On Mac hosts, uncommenting the I<networksetup> system calls of Adfilter.pm will
-automate this.
+It will be necessary to manually set the host's network dns settings to 127.0.0.1 in
+order to take advantage of the filtering. On Mac hosts, uncommenting the I<networksetup>
+system calls of Adfilter.pm will automate this.
=head1 AUTHOR
View
7 scripts/adfilter.pl
@@ -5,12 +5,12 @@
use strict;
use warnings;
-use Net::DNS::Dynamic::Adfilter 0.063;
+use Net::DNS::Dynamic::Adfilter 0.064;
use Getopt::Long;
use Pod::Usage;
-our $VERSION = '0.063';
+our $VERSION = '0.064';
my $debug = 0;
my $verbose = 0;
@@ -27,8 +27,7 @@
my $pgl_hosts_url = 'http://pgl.yoyo.org/adservers/serverlist.php?hostformat=nohtml&showintro=0&&mimetype=plaintext';
my $pgl_hosts_path = '/var/named/pglhosts';
my $pgl_hosts_refresh = 7;
-#my $more_hosts_path = undef; #'/var/named/morehosts';
-my $more_hosts_path = '/var/named/morehosts';
+my $more_hosts_path = undef; #'/var/named/morehosts';
GetOptions(
'debug|d' => \$debug,

No commit comments for this range

Something went wrong with that request. Please try again.