Simple module for administer dansguardian's control files.
use Dansguardian; # Make the objet $dg using the contructor new() my $dg = Dansguardian->new(dir => '/etc/dansguardian', group_dir => '/etc/dansguardian/lists'); # Save IP's banned in array my @banned_ips = $dg->get('bannediplist'); print "The IP address $_ is banned!!\n" foreach @banned_ips; # Add exception web site my $site = 'mogaal.com'; $dg->set(file => 'exceptionsitelist', add => $site, comment => "Is not porn site"); # Remove banned IP my $ip_free = '192.168.0.2'; $dg->remove(file => 'bannediplist', line => $ip_free); # list sites banned my @sites_banned = $dg->get('bannedsitelist'); print "The site $_ is banned!!\n" foreach @sites_banned; # list dansguardian's config directory and the current group directory print "Dansguardian's config directory is " . $dg->group() . " and " . $dg->dir() . " is the current group directory\n"; # Change group directory; $dg->group("/etc/dansguardian/chiefs"); print "Dansguardian's config directory is " . $dg->dir() . " and " . $dg->group() . " is the current group directory\n";
\*(L"DansGuardian is an award winning Open Source web content filter which currently runs on Linux, FreeBSD, OpenBSD, NetBSD, Mac \s-1OS\s0 X, HP-UX, and Solaris. It filters the actual content of pages based on many methods including phrase matching, \s-1PICS\s0 filtering and \s-1URL\s0 filtering. It does not purely filter based on a banned list of sites like lesser totally commercial filters.\*(R"
Dansguardian Perl module is small module for administer dansguardian's content control files. It let you add, remove and get information from files control across methods.
Dansguardian perl module provides some basic methods for administer control files, with it you can add, remove and get information about \s-1IP\s0's blocked, sites denies, \s-1IP\s0 exception and other information.
$dg = Dansguardian->new([%attributes])
The constructor will create an object. It accepts a list of key => value pairs:
If you don't set up a config directory for dansguardian the module will set up default value: /etc/dansguardian
Same that dir hash, and the default value is: /etc/dansguardian/lists If group method don't have attribute: the function return array with dansguardian current group directory. Is possible change the group directory setting up $group_dir variable. If dir method don't have attribute: the function return array with dansguardian current config directory. Is possible change the group directory setting up $group_dir variable. set method must have hash attributes. So, it accepts a list of key => value pairs:
The \s-1FILE\s0 value is the file (locate inside current group dir) where you wish add information. For example: If you want add site to exception. $dg->set(file => 'exceptionsitelist', add => $site, comment => "Is not porn site"); This line will add $site to /etc/dansguardian/lists/exceptioniplist assuming that /etc/dansguardian/lists is current group directory
The 'add' value is the information to add in dansguardian control file. For example: If you need add one \s-1IP\s0 for bannediplist control file, then assign '\s-1IP\s0' value for add hash key.
This key is optional but very usefull for reading control files. It add comment at final line, after the 'add' value. remove method must have one hash attribute with keys:
The \s-1FILE\s0 value is the file (locate inside current group dir) where you wish remove information.
The value of hash key line is the information for remove in dansguardian control file. For example: For remove \s-1IP\s0 address from bannediplist control file you must add '\s-1IP\s0' like value of line hash key.
Example
$dg->remove(file => 'bannediplist', line => '192.168.24.76'); Get method return an array data with information inside content control file. The incoming parameter is the control file name. Example:
@ips_banned = $dg->get('bannediplist') print "The IP address $_ is banned!!\n" foreach @banned_ips;
The package don't have been bugs reported. If you find one notice me.
Alejandro Garrido Mota <[email protected]>.
Copyright (c) 2007 Alejandro Garrido Mota. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the \s-1LICENSE\s0 file included with this module.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the \s-1LICENSE\s0 file included with this module.