diff options
-rwxr-xr-x | bin/drakguard | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/bin/drakguard b/bin/drakguard index 847a8d8..89db0fc 100755 --- a/bin/drakguard +++ b/bin/drakguard @@ -52,12 +52,14 @@ my @url_lists = ( list_title => N("Forbidden addresses"), remove_text => N("Remove from blacklist"), file => $blacklist_url_file, + apply => \&apply_blacklist, }, { tab_title => N("Whitelist"), list_title => N("Allowed addresses"), remove_text => N("Remove from whitelist"), file => $whitelist_url_file, + apply => \&apply_whitelist, } ); @@ -203,8 +205,7 @@ sub save() { $in->do_pkgs->ensure_is_installed('dansguardian', '/usr/sbin/dansguardian') or quit_gui(); - apply_blacklist(); - apply_whitelist(); + $_->{apply}(map { $_->[0] } @{$_->{list}{data}}) foreach @url_lists; write_dansguardian(); enable_transparent_proxy($proxy_port); services::set_status($_, $enable) foreach qw(squid dansguardian); @@ -260,8 +261,6 @@ sub include_guardian_file { if (!member($to_add, @all)) { output_p($guardian_file, @all, $to_add); } - output_p($external_file, if_($o_category, qq(#listcategory: "$o_category"\n))) - unless -f $external_file; } sub read_url_list { @@ -269,13 +268,18 @@ sub read_url_list { grep { $_ && !/^\s*#/ } chomp_(cat_($file)); } -sub apply_blacklist() { +sub apply_blacklist { + my @addr = @_; my $blacklist_top = "/etc/dansguardian/lists/bannedsitelist"; my $blacklist_category = "blocked by Mandriva parental control tool"; + output_p($blacklist_url_file, map { $_ . "\n" } + qq(#listcategory: "$blacklist_category"), @addr); include_guardian_file($blacklist_top, $blacklist_url_file, $blacklist_category); } -sub apply_whitelist() { +sub apply_whitelist { + my @addr = @_; my $whitelist_top = "/etc/dansguardian/lists/exceptionurllist"; + output_p($whitelist_url_file, map { $_ . "\n" } @addr); include_guardian_file($whitelist_top, $whitelist_url_file); } |