dansguardian(3pm)
π dansguardian β the Perl module that runs your DansGuardian control files π
okay so bestie, quick vibe check: this is dansguardian(3pm), a page from the User Contributed Perl Documentation, and it's literally just a lil Perl module that lets you boss around DansGuardian's control files. no cap. π
πΈ NAME πΈ
Dansguardian β a simple module for administering DansGuardian's control files. periodt. β¨
π¦ SYNOPSIS π¦
here's the whole thing in action, no edits, just vibes:
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";
like, it's giving one file, all the power. obsessed. π₯
π DESCRIPTION π
okay so first, the module itself quotes the whole DansGuardian pitch, and I'm not touching a word of it:
"DansGuardian is an award winning Open Source web content filter which currently runs on Linux, FreeBSD, OpenBSD, NetBSD, Mac OS X, HP-UX, and Solaris. It filters the actual content of pages based on many methods including phrase matching, PICS filtering and URL filtering. It does not purely filter based on a banned list of sites like lesser totally commercial filters."
award winning!! we love to see it. π
and then: the Dansguardian Perl module is a small module for administering DansGuardian's content control files. it lets you add, remove and get information from control files, across methods. that's the whole serve. π
β¨ METHODS β¨
the module hands you some basic methods for administering control files β with them you can add, remove and get information about blocked IPs, denied sites, IP exceptions and other stuff. π«Ά
π new (constructor)
$dg = Dansguardian->new([%attributes])
the constructor makes you an object. it accepts a list of key => value pairs:
dir => 'dansguardian/config/directory'β if you don't set a config directory for DansGuardian, the module will set up the default value:/etc/dansguardiangroup_dir => 'path/to/group_dir/directory'β same situation as thedirhash, and the default value is:/etc/dansguardian/lists
π $dg->group([$group_dir]);
if the group method has no attribute, the function returns an array with DansGuardian's current group directory. you can also change the group directory by setting up the $group_dir variable. slay. πΈ
π $dg->dir([$config_dir]);
if the dir method has no attribute, the function returns an array with DansGuardian's current config directory. and yeah, you can change the group directory by setting up the $group_dir variable. π¦
β $dg->set(%attributes);
the set method must have hash attributes. so it accepts a list of key => value pairs:
file => 'FILE'β theFILEvalue is the file (located inside the current group dir) where you wish to add information. for example, if you want to add a site to the exception list:
$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 the current group directory.
add => 'INFORMATION'β theaddvalue is the information to add in the DansGuardian control file. for example, if you need to add one IP for thebannediplistcontrol file, then assign anIPvalue for theaddhash key.comment => 'OPTIONAL COMMENT'β this key is optional but very useful for reading control files. it adds a comment at the final line, after theaddvalue.
π§ $dg->remove($file)
the remove method must have one hash attribute with these keys:
file => 'FILE'β theFILEvalue is the file (located inside the current group dir) where you wish to remove information.line => 'LINE/IP/SITE/whatever'β the value of thelinehash key is the information to remove in the DansGuardian control file. for example, to remove an IP address from thebannediplistcontrol file you must add anIPas the value of thelinehash key.
Example
$dg->remove(file => 'bannediplist', line => '192.168.24.76');
π $dg->get($file)
the get method returns an array of data with the information inside a 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;
π BUGS π
the package doesn't have any bugs reported. if you find one, notice the author. (ngl, that's the dream.) π
π AUTHOR π
Alejandro Garrido Mota <garridomota@gmail.com>.
π COPYRIGHT AND LICENSE π
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 LICENSE file included with this module.
π LICENSE π
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 LICENSE file included with this module.
and that's the whole page, bestie β documented for perl v5.32.0, dated 2021-01-07. go forth and filter those pages, main character energy only. π
β¨π«Ά
π¦ where this page comes from
- debian bookworm: libdansguardian-perl 0.6-2.1
- ubuntu jammy: libdansguardian-perl 0.6-2.1
- ubuntu noble: libdansguardian-perl 0.6-2.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms