hi
I’m looking for information to add a page to the menu to configure unbound. I found the information to add a menu unbound it’s displayed well.
I’d like to open a page with the possibility to display a field to create files and then for edit.
ty
Could you please specify more clearly, what you want to do?
If you want to configure unbound further ( with options or features not handled by IPFire so far ), be sure not to violate the standard behaviour ‘config by WebGUI → save/write config files → restart service’.
Your best option is to look through the perl code of dns.cgi
This file is located in the IPFire git repo
https://git.ipfire.org/?p=ipfire-2.x.git;a=blob;f=html/cgi-bin/dns.cgi;h=f3dd5c7a915e38bc6089129121ad51bef76e5427;hb=refs/heads/next
or in your IPFire system at
/srv/web/ipfire/cgi-bin/dns.cgi
That code already opens a new page for adding additional DNS Servers to the list.
You should be able to use that code as a form of template to create a new page for doing what you describe.
hi
i test this page
the page is displayed well but I do not find how to display the 2 conf files in the respective 2 frames.
frames 1: /etc/unbound/local.d/file conf1
frames 2: /etc/unbound/local.d/file conf 2
the files are in /etc/unbound/local.d/
frames 3
display files rpz
frames 4 select files rpz
the files are in /etc/unbound/zone
if you can help me ty
There is a URL filter page now.
Assuming this works by a different mechanism.
Than it should have a unique name.
Like URL block list?
Looks interesting for sure.
the titles and comments are not yet adapted to unbound
I’m leeing with the code to do all right
ty
from what I know about unbound, I think unbound only need domains and subdomains, and not URLs.
A URL is something like and I dont believe this will work with unbound:
https://bad.evil.example.com
# -or-
https://bad.evil.example.com?name1234567890
And I think unbound only needs something like this:
bad.evil.example.com
# -and/or-
*.bad.evil.example.com
I don’t get well what you say, but if I understand the domains will be managed by unbound and the syntax as well
ty
@jon,
your right!
unbound is a ‘DNS server’. Its purpose is to translate names into IPs.
An URL is the request to talk in a certain protocol ( HTTP e.g. ) to a device somewhere in the internet. Transport is based on IPs, so we have to look up the IP to send the packet.
hi
i have isolate part of the code to make the page but I don’t understand some of the pieces of the code if you can explain to me
#!/usr/bin/perl
# use strict;
# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
use File::Copy;
use IO::Socket;
require '/var/ipfire/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
my %besettings=();
my %checked=();
my %selected=();
# File which stores the configured unbound settings.
my $unboundsetting = "${General::swroot}/etc/unbound/local.d/setting.conf";
# File which stores the configured rpz settings.
my $rpzsetting = "${General::swroot}/etc/unbound/local.d/filtres.conf";
# Config file which stores the unbound rpz rule.
my $zonedir = "${General::swroot}/etc/unbound/zonefiles";
&Header::getcgihash(\%besettings);
if ($besettings{'ACTION'} eq $Lang::tr{'urlfilter blacklist editor'}) { $besettings{'BEMODE'} = 'on'; }
if ($besettings{'MODE'} eq 'BLACKLIST_EDITOR')
{
undef $besettings{'BE_DOMAINS'};
{
s/^\s+//g; s/\s+$//g;
if ($_) { $besettings{'BE_DOMAINS'} .= $_."\n"; }
}
chomp($besettings{'BE_DOMAINS'});
}
if (-e "$zonedir/$besettings{'BE_NAME'}/domains")
{
open(FILE, "$zonedir/$besettings{'BE_NAME'}/domains");
while (<FILE>) { unless ($_ eq '\n') { $besettings{'BE_DOMAINS'} .= $_ } };
close FILE;
chomp($besettings{'BE_DOMAINS'});
}
ERROR:
$checked{'ENABLE_CUSTOM_BLACKLIST'}{'off'} = '';
$checked{'ENABLE_CUSTOM_BLACKLIST'}{'on'} = '';
$checked{'ENABLE_CUSTOM_BLACKLIST'}{$filtersettings{'ENABLE_CUSTOM_BLACKLIST'}} = "checked='checked'";
$selected{'BE_BLACKLIST'}{$besettings{'BE_BLACKLIST'}} = "selected='selected'";
&Header::showhttpheaders();
&Header::openpage($Lang::tr{'urlfilter configuration'}, 1, '');
&Header::openbigbox('100%', 'left', '', $errormessage);
if ($errormessage) {
&Header::openbox('100%', 'left', $Lang::tr{'error messages'});
print "<font class='base'>$errormessage </font>\n";
&Header::closebox();
}
#==========================================================
#
# Section: Main Configuration
#
#==========================================================
print "<form method='post' action='$ENV{'SCRIPT_NAME'}' enctype='multipart/form-data'>\n";
&Header::openbox('100%', 'left', "$Lang::tr{'urlfilter filter settings'}");
print <<END
</table>
<hr size='1'>
<table width='100%'>
<tr>
<td><b>$Lang::tr{'urlfilter custom blacklist'}</b></td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan='2'>$Lang::tr{'urlfilter blocked domains'}</td>
<td colspan='2'>$Lang::tr{'urlfilter blocked urls'}</td>
</tr>
<tr>
<td colspan='2'>$Lang::tr{'urlfilter example'}</td>
<td colspan='2'>$Lang::tr{'urlfilter example ads'}</td>
</tr>
<td colspan='2' width='50%'><textarea name='CUSTOM_BLACK_DOMAINS' cols='32' rows='6' wrap='off'>
END
;
print $unboundsetting{'CUSTOM_BLACK_DOMAINS'};
print <<END
</textarea></td>
<td colspan='2' width='50%'><textarea name='CUSTOM_BLACK_URLS' cols='32' rows='6' wrap='off'>
END
;
print $rpzsetting{'CUSTOM_BLACK_URLS'};
print <<END
</textarea></td>
</tr>
</table>
<table width='100%'>
<tr>
<td class='base' width='25%'>$Lang::tr{'urlfilter enable custom blacklist'}:</td>
<td><input type='checkbox' name='ENABLE_CUSTOM_BLACKLIST' $checked{'ENABLE_CUSTOM_BLACKLIST'}{'on'} /></td>
<td> </td>
<td> </td>
</tr>
</table>
<table width='100%'>
<tr>
<hr size='1'>
<td> </td>
<td align='center'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
<td align='center'><input type='submit' name='ACTION' value='$Lang::tr{'urlfilter save and restart'}' /></td>
<td> </td>
</tr>
</table>
END
;
&Header::closebox();
#==========================================================
#
# Section: Blacklist editor
#
#==========================================================
print "<form method='post' action='$ENV{'SCRIPT_NAME'}' enctype='multipart/form-data'>\n";
&Header::openbox('100%', 'left', $Lang::tr{'urlfilter urlfilter blacklist editor'}.':');
print <<END
<table width='100%'>
<tr>
<td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
</tr>
<tr>
<td class='base'><b>$Lang::tr{'urlfilter blacklist name'}</b></td>
</tr>
<tr>
<td class='base'>$Lang::tr{'urlfilter blacklist category name'}: <img src='/blob.gif' alt='*' /></td>
<td><input type='text' name='BE_NAME' value='$besettings{'BE_NAME'}' size='12' /></td>
</tr>
</table>
<hr size='1'>
<table width='100%'>
<tr>
<td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='20%'></td>
</tr>
<tr>
<td class='base' colspan='4'><b>$Lang::tr{'urlfilter edit domains urls expressions'}</b> <img src='/blob.gif' alt='*' /></td>
</tr>
<tr>
<td colspan='2'>$Lang::tr{'urlfilter domains'}</td>
</tr>
<tr>
<td colspan='2'><textarea name='BE_DOMAINS' cols='38' rows='10' wrap='off'>
END
;
print $besettings{'BE_DOMAINS'};
print <<END
</textarea></td>
</tr>
</table>
<hr size='1'>
<table width='100%'>
<tr>
<td class='base' colspan='4'><b>$Lang::tr{'urlfilter load blacklist'}</b></td>
</tr>
<tr>
<td width='25%' class='base'>$Lang::tr{'urlfilter select blacklist'}:</td>
<td width='20%' class='base'>
<select name='BE_BLACKLIST'>
END
;
{
print "<option value='$_' $selected{'BE_BLACKLIST'}{$_}>$_</option>\n";
}
print <<END
</select>
</td>
<td> </td>
<td> </td>
<tr>
<td colpsan='4'><input type='submit' name='ACTION' value='$Lang::tr{'urlfilter load blacklist'}' /></td>
</tr>
</tr>
</table>
<hr size='1'>
<table width='100%'>
</tr>
</table>
</tr>
</table>
<table width='100%'>
<tr>
<td> </td>
<td align='center'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
<td align='center'><input type='submit' name='ACTION' value='$Lang::tr{'urlfilter save and restart'}' /></td>
<td> </td>
</tr>
</table>
END
;
&Header::closebox();
print "</form>\n";
&Header::closebigbox();
&Header::closepage();
# -------------------------------------------------------------------
sub readcustomlists
{
if (-e "$zonedir/") {
open(FILE,"$zonedir/");
while (<FILE>) { $zonedir{'CUSTOM_BLACK_DOMAINS'} .= $_ };
close(FILE);
}
}
# -------------------------------------------------------------------
a what’s this part?
my %besettings=();
ty
%besettings is the hash which gets the call parameters ( cgi parameters ), see
&Header::getcgihash(\%besettings);
They are generated by the click (re)opening the page.
ty
if I understand this variable is indispensible to reload the page with the variable
my %besettings=();
if I want to display the file setting.conf
my $unboundsetting = "${General::swroot}/etc/unbound/local.d/setting.conf";
in
<td colspan='2' width='50%'><textarea name='CUSTOM_BLACK_DOMAINS' cols='32' rows='6' wrap='off'>
How to proceed ?
ty