File:
[ELWIX - Embedded LightWeight unIX -] /
embedaddon /
dnsmasq /
contrib /
webmin /
dnsmasq.wbm
Revision
1.1.1.1 (vendor branch):
download - view:
text,
annotated -
select for diffs -
revision graph
Mon Jul 29 19:37:40 2013 UTC (11 years, 5 months ago) by
misho
Branches:
elwix,
dnsmasq,
MAIN
CVS tags:
v8_2p1,
v2_84,
v2_76p1,
v2_71,
v2_66p0,
v2_66,
HEAD
dnsmasq
dnsmasq/ 0000755 0000000 0000000 00000000000 10512645440 011223 5 ustar root root dnsmasq/config.info 0000644 0000000 0000000 00000000132 10505663743 013351 0 ustar root root config_file=Full path to DNSmasq config file,0
restart=Shell script to re-start DNSmasq,0
dnsmasq/config 0000644 0000000 0000000 00000000061 10505663767 012426 0 ustar root root config_file=/etc/dnsmasq.conf
restart=restart.sh
dnsmasq/images/ 0000755 0000000 0000000 00000000000 10506375201 012466 5 ustar root root dnsmasq/images/icon.gif 0000644 0000000 0000000 00000000616 10505632635 014116 0 ustar root root GIF89a0 0 ccc , 0 0 I8k;`xqBY~b
vq*W^9\HCG!ŏD ?+ -p P j:@o1~9~mz{~}m y|D-@VQb,P'VOr^Vjxz;[f^zøȰ ܞħL}1O`By{{H@0E1F,D)~dH!%̑rґYm_61ɓgw4+3&,;\ZTEL{Z
5jS?Έ ; dnsmasq/images/template.gif 0000644 0000000 0000000 00000003560 06771443034 015005 0 ustar root root GIF89a0 UUU 999rrr!Made with GIMP , 0 8AZdiӠhksh߶L|G,rY̥q0 Ԓ0-]%6AkX=Q}~T{M oa-W~~x,vuc&$xa4e Syu`g$bͽ~ʣ `lˁj\QԸꪀ>"{9ۗFḃYWͳ?QdƌJf)hcv'w+ #1|XgO-ahB(`DZڄU.EbP FKD[B <
[Ŝ "JÞi0*a-VI@
\(I
/*!0@*>Lhp20:v6V.᧲.Ԛa&9M$bE\
d"uKw;_a_J]6㰣'yDt3WA3i6In:&Q,~tj'-W{!ϵ 71w^w P 8hY
2T\mS|FG]څGEvM1%!U.#pGDeV+.ע>>Y68duZ&8\GM}gMY{U.٢XX&#)kpKL(XF1M\J h#Ma&qrYF*]AhF9hT)L\]1lfj`\㩝pyV*M֪|8tY.$>\)(vJ:(܆N۬n/{'^yySU洦gj5ۃ-,䮳%K5;[~,|ӌJ:uzAd^8)W1ʩz)nj. zÇ9scm%Z[=Sy\ So]5E_]K[+uO5Sn3
bM Ēܶэ5rmBN!-?58Ŕ
hOk~
}3^Q8Yκi{=8'r;+pڛͻz*r4[0k&<#/$q;֜ tŅ" C
Mtv0_+PI 7 >$*F,N|H}t>YxT7s=X!ZÓJsؿd;v尋F`%-xG#6..O8xdH! D춨XjXϢV>q7c @<2_V1X^F p\2)Ѹ'OEf'$Gce˲eҐٛD/rI4ڥ@,+'6dlTT(7!@*:!,&ɴ< } h&iRUiџηibkCfPM~O('%Sfxy:5v*_I6m=Hn$z4Z(Q\e>5
DnRۘj4W百5%&Gi:fXJQ-IXq":xFS|`Hɔj-- {
DGjRv-[rzhhGKҚiWֺ6{lgKڢ ͭnwk\
pEr=ߒ:}t+R5.K ; dnsmasq/images/up.gif 0000644 0000000 0000000 00000000147 10506373750 013612 0 ustar root root GIF89a rrr !Made with GIMP !
, &
|'Io|b%eRG;Ssf ; dnsmasq/images/down.gif 0000644 0000000 0000000 00000000154 10506373750 014133 0 ustar root root GIF89a rrr !Made with GIMP !
, +@"IUieJbAIm.dN ; dnsmasq/images/gap.gif 0000644 0000000 0000000 00000000111 10506375201 013715 0 ustar root root GIF89a !Made with GIMP !
, ڋ> ; dnsmasq/module.info 0000644 0000000 0000000 00000000142 10501433425 013356 0 ustar root root name=DNSMasq
desc=DNSMasq integrated DNS & DHCP servers
os_support=
depends=0.77
category=servers
dnsmasq/index.cgi 0000755 0000000 0000000 00000007531 10512641067 013030 0 ustar root root #!/usr/bin/perl
#
# DNSMasq Webmin Module - index.cgi; basic DNS config
# Copyright (C) 2006 by Neil Fisher
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This module inherited from the Webmin Module Template 0.79.1 by tn
do '../web-lib.pl';
do '../ui-lib.pl';
do 'dnsmasq-lib.pl';
$|=1;
&init_config("DNSMasq");
%access=&get_module_acl;
## put in ACL checks here if needed
## sanity checks
&header($text{'index_title'}, "", "intro", 1, 1, undef,
"Written by Neil Fisher<BR><A HREF=mailto:neil\@magnecor.com.au>Author</A><BR><A HREF=http://www.authorpage.invalid>Home://page</A>");
# uses the index_title entry from ./lang/en or appropriate
## Insert Output code here
# read config file
$config_file = &read_file_lines( $config{config_file} );
# pass into data structure
# output as web page
&header( "DNSMasq settings", "" );
&parse_config_file( \%config, \$config_file );
print "<hr>\n";
if( $config{errors} > 0 )
{
print "<h3>WARNING: found ";
print $config{errors};
print "errors in config file!</h3><br>\n";
}
print &ui_form_start( 'basic_apply.cgi', "post" );
print "<br>\n";
print "<h2>$text{'DNS_settings'}</h2>";
print "<br><br>\n";
print $text{'local_domain'};
print &ui_textbox( "local_domain", $config{domain}{domain}, 32 );
print "<br><br>\n";
print $text{'domain_needed'};
print &ui_yesno_radio( "domain_needed", ($config{domain_needed}{used})?1:0 );
print "<br><br>\n";
print $text{'expand_hosts'};
print &ui_yesno_radio( "expand_hosts", ($config{expand_hosts}{used})?1:0 );
print "<br><br>\n";
print $text{'bogus_priv'};
print &ui_yesno_radio( "bogus_priv", ($config{bogus_priv}{used})?0:1 );
print "<br><br>\n";
print $text{'filterwin2k'};
print &ui_yesno_radio( "filterwin2k", ($config{filterwin2k}{used})?1:0 );
print "<br><br>\n";
print $text{'hosts'};
print &ui_yesno_radio( "hosts", ($config{no_hosts}{used}?0:1) );
print "<br>\n";
print $text{'xhosts'};
print &ui_yesno_radio( "xhosts", ($config{addn_hosts}{used}?1:0) );
print "<br>\n";
print $text{'xhostsfile'};
print &ui_textbox( "addn_hosts", $config{addn_hosts}{file}, 40 );
print "<br><br>\n";
print $text{'neg_cache'};
print &ui_yesno_radio( "neg_cache", ($config{neg_cache}{used}?0:1) );
print "<br><br>\n";
print $text{'cache_size'};
print &ui_yesno_radio( "cache_size", ($config{cache_size}{used}?1:0) );
print "<br>\n";
print $text{'cust_cache_size'};
print &ui_textbox( "cust_cache_size", $config{cache_size}{size}, 40 );
print "<br><br>\n";
print $text{'log_queries'};
print &ui_yesno_radio( "log_queries", ($config{log_queries}{used}?1:0) );
print "<br><br>\n";
print $text{'local_ttl'};
print &ui_yesno_radio( "local_ttl", ($config{local_ttl}{used}?1:0) );
print "<br>\n";
print $text{'ttl'};
print &ui_textbox( "ttl", $config{local_ttl}{ttl}, 40 );
print "<br><br>\n";
print &ui_submit( $text{'save_button'} );
print &ui_form_end( );
print "<hr>";
print "<a href=\"servers.cgi\">";
print $text{'servers_config'};
print "</a><br>";
print "<a href=\"iface.cgi\">";
print $text{'iface_config'};
print "</a><br>";
print "<a href=\"alias.cgi\">";
print $text{'alias_config'};
print "</a><br>";
print "<hr>";
print "<a href=\"dhcp.cgi\">";
print $text{'DHCP_config'};
print "</a><br>";
print "<hr>";
print "<a href=\"restart.cgi\">";
print $text{'restart'};
print "</a><br>";
&footer("/", $text{'index'});
# uses the index entry in /lang/en
## if subroutines are not in an extra file put them here
### END of index.cgi ###.
dnsmasq/acl_security.pl 0000644 0000000 0000000 00000000561 07000420647 014246 0 ustar root root
# acl_security_form(&options)
# Output HTML for editing security options for the apache module
sub acl_security_form
{
## Here you have to fill in the code for output
}
# acl_security_save(&options)
# Parse the form for security options for the apache module
sub acl_security_save
{
## here you have to fill in the handling code for the saving the ACL
}
### END. dnsmasq/lang/ 0000755 0000000 0000000 00000000000 10512641175 012145 5 ustar root root dnsmasq/lang/en 0000644 0000000 0000000 00000007666 10512637344 012514 0 ustar root root
lang=en
author=Neil Fisher
module_author=Neil Fisher
homepage=www.nonexistent.invalid
copyright=(C) 2006 by Neil Fisher <neil@magnecor.com.au>
license=GPL
index_title=DNSMasq - integrated DNS and DHCP servers
DNS_settings=Basic DNS settings
DHCP_settings=DHCP settings
DNS_servers=DNS Upstream Servers Configuration
iface_settings=Network Interface Settings
alias_settings=Alias / Redirect Settings
local_domain=Local domain name
domain_needed=Only forward names with a domain part
expand_hosts=Add local domain name to DHCP leases & hosts in /etc/hosts
bogus_priv=Allow unresolved reverse lookups on local network to propogate out
filterwin2k=Prevent windows SOA & SRV requests propogating out
resolv=Read /etc/resolv.conf
poll=poll resolv.conf file
resolv_file_explicit=Use non-standard resolv.conf file
resolv_file=non-standard resolv.conf file to use
strict_order=Always use nameservers in order provided
hosts=Read /etc/hosts file
xhosts=Use additional hosts file
xhostsfile=File to use for additional hosts
neg_cache=Cache negative responses
log_queries=Log each DNS lookup
cache_size=Use custom cache size
cust_cache_size=Custom cache size to use
local_ttl=Use specified local Time-To-Live
ttl=Local TTL
dynamic=Defined in resolv.conf file
domain=For domain
address=IP address
in_use=In use
used=In Use
not_used=Defined only (not used)
in_file=Defined in config file
new_dns_serv=Add new upstream server to config file
save_button=Save
servers_config=Configure upstream DNS Servers
alias_config=Configure Forced Domains and Alias responses
iface_config=Configure network interfaces
DHCP_config=Configure DHCP
restart=Restart DNSmasq
restarting=Trying to restart DNSmasq. Script messages are:
srv_edit=Edit upstream DNS server
srv_named=For specific domain
srv_name=Specific domain
srv_addr=Server address
delet=Delete
iface=Interface
xiface=Except Interface
listen=Listen on
new_iface=Add new interface
iface_listen=Interface to listen on
xiface_listen=Except interfaces
listen_addr=Listen Address
new_addr=Add new address
edit_iface=Edit interface
iface_name=Interface name
edit_xiface=Edit except interface
listen_name=Listen address
edit_listen=Edit listen address
xiface_name=Except interface name
bind_iface=Bind to individual interfaces instead of wildcard address
forced=Forced domain responses
nx=Forced NXDOMAIN IP addresses
alias=Aliased IP addresses
forced_domain=Domain name
forced_ip=To IP address
forced_from=From IP address
forced_mask=Netmask
forced_mask_used=Use a netmask
forced_add=Add new forced domain
alias_add=Add new alias
nx_add=Add new forced NXDOMAIN
forced_edit=Edit forced domain reponse
alias_edit=Edit IP address alias
nx_edit=Edit Forced NXDOMAIN response
net_id=Network/Client ID
timed=Use a lease time
leasetime=Lease time
dhcp_range=DHCP IP address ranges
range_edit=Edit DHCP range
range_add=Add new DHCP range
ided=Network ID
id=Network ID to use
hosts=Specific Hosts
host_add=Add a new host specification
vendor_classes=Vendor Class Specification
user_classes=User Class Specification
vendor=Vendor
user=User
class=Class
vend_add=Add new vendor class
user_add=Add new user class
read_ethers=Read /etc/ethers for lease info
misc=Miscellaneous DHCP options
dhcp_options=Non-standard DHCP options
dhcp_option=Option
dhcp_add=Add new option
edit_host=Edit DHCP host specification
edit_opt=Edit DHCP options
opt_spec=DHCP option specification
use_bootp=Use BOOTP (network boot)
bootp_host=Hostname
bootp_file=File
bootp_address=IP Address
max_leases=Maximum number of leases to grant
leasefile=Use a nonstandard lease file
lfikletouse=Nonstandard leasefile to use
error_heading=Warning - ERROR!!!!
err_line=Error in line:
err_type=Type of error is:
err_help=Try going back and retyping the offending information
err_notip=Not a valid IP address
err_notmask=Not a valid netmask
err_nottime=not a valid time
err_configbad=Configuration file has an error
err_filebad=Bad file name
err_hostbad=Bad host name
err_numbbad=Bad number
err_domainbad=Bad domain
err_namebad=Bad name
dnsmasq/lang/en~ 0000644 0000000 0000000 00000000344 07076651262 012702 0 ustar root root
lang=en
author=Name of language file author here
module_author=Writers name here
homepage=modules homepage url here
copyright=(C) YYYY by author <email@author.any>
license=GPL
your_message=here you have to write your messages
dnsmasq/.index.cgi.swp 0000644 0000000 0000000 00000030000 10475225557 013710 0 ustar root root b0VIM 6.3 R+DB # staff upstairs.localnet ~staff/template/index.cgi 3210#"! U tp I ad $ \ I V U
R
Q
=
7
] B A 5 4
~
z
w
u
t
_
E
C
x w v \ ### END of### END of index.cgi ###. ## if subroutines are not in an extra file put them here # uses the index entry in /lang/en &footer("/", $text{'index'}); &header( "DNSmasq configuration", "" ); } print "$key = $config{$key}<br>"; { foreach my $key (%config) # output as web page } } } $config{"$line"}=1; { else } $config{"$1"}=$2; { if ($line =~ /(.*)\=(.*)/) next if( $line =~ /^\#/ ); { if (defined ($line)) { foreach my $line (@$config_file) my %config; # pass into data structure $config_file = &read_file_lines( "/etc/dnsmasq.conf" ); # read config file ## Insert Output code here # uses the index_title entry from ./lang/en or appropriate "Written by Neil Fisher<BR><A HREF=mailto:neil\@magnecor.com.au>Author</A><BR><A HREF=http://www.authorpage.invalid>Home://page</A>"); &header($text{'index_title'}, "", "intro", 1, 1, undef, ## sanity checks ## put in ACL checks here if needed %access=&get_module_acl; &init_config("MODULENAME"); $|=1; do '../web-lib.pl'; # This module inherited from the Webmin Module Template 0.79.1 by tn # # GNU General Public License for more details. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # but WITHOUT ANY WARRANTY; without even the implied warranty of # This program is distributed in the hope that it will be useful, # # (at your option) any later version. # the Free Software Foundation; either version 2 of the License, or # it under the terms of the GNU General Public License as published by # This program is free software; you can redistribute it and/or modify # # Copyright (C) 2006 by Neil Fisher # DNSMasq Webmin Module # #!/usr/bin/perl dnsmasq/srv_edit.cgi 0000755 0000000 0000000 00000004503 10512323643 013531 0 ustar root root #!/usr/bin/perl
#
# DNSMasq Webmin Module - dns_edit.cgi; upstream server edit
# Copyright (C) 2006 by Neil Fisher
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This module inherited from the Webmin Module Template 0.79.1 by tn
do '../web-lib.pl';
do '../ui-lib.pl';
do 'dnsmasq-lib.pl';
$|=1;
&init_config("DNSMasq");
%access=&get_module_acl;
## put in ACL checks here if needed
## sanity checks
## Insert Output code here
# read config file
$config_file = &read_file_lines( $config{config_file} );
# pass into data structure
&parse_config_file( \%config, \$config_file );
# read posted data
&ReadParse();
# check for errors in read config
if( $config{errors} > 0 )
{
&header( "DNSMasq settings", "" );
print "<hr><h2>";
print $text{warn_errors};
print $config{errors};
print $text{didnt_apply};
print "</h3><hr>\n";
&footer( "/", $text{'index'});
exit;
}
# adjust everything to what we got
#
&header( "DNSMasq settings", "" );
print "<h2>".$text{srv_edit}."</h2>";
print &ui_form_start( "srv_edit_apply.cgi", "post" );
print &ui_hidden( "idx", $in{idx} );
print "<br>".$text{in_use}.&ui_yesno_radio( "used",
($config{servers}[$in{idx}]{used})?1:0 );
print "<br>".$text{srv_named}.&ui_yesno_radio( "named",
($config{servers}[$in{idx}]{domain_used})?1:0 );
print "<br>".$text{srv_name};
print &ui_textbox( "name", $config{servers}[$in{idx}]{domain}, 50 );
print "<br>".$text{srv_addr};
print &ui_textbox( "addr", $config{servers}[$in{idx}]{address}, 18 );
print "<br><br>" . &ui_submit( $text{'save_button'} )."<br>";
print &ui_form_end();
print "<a href=delete.cgi?idx=".$in{idx}."&what=servers&where=servers.cgi".
">".$text{delet}."</a>";
#print "<a href=dns_del.cgi?idx=".$in{idx}.">".$text{delet}."</a>";
print "<br><a href=servers.cgi>".$text{servers_config}."</a>";
&footer( "/", $text{'index'});
#
#
# sub-routines
#
### END of dns_edit.cgi ###.
dnsmasq/dnsmasq-lib.pl 0000755 0000000 0000000 00000033547 10512631060 014002 0 ustar root root #
# dnsmasq-lib.pl
#
# dnsmasq webmin module library module
#
#
# the config hash holds the parsed config file
#
my %config = {
errors => 0,
mx_host => { used => 0, line => 0, host => "" },
mx_target => { used => 0, line => 0, host => "" },
selfmx => { used => 0, line => 0 },
localmx => { used => 0, line => 0 },
domain_needed => { line => 0, used => 0 },
bogus_priv => { line =>0, used => 0 },
filterwin2k => { line => 0, used => 0 },
resolv_file => { line => 0, used => 0,
filename => "/etc/hosts"
},
strict_order => { line => 0, used => 0 },
no_resolv => { line => 0, used => 0 },
no_poll => { line => 0, used => 0 },
servers => [],
locals => [],
forced => [],
bogus => [],
user => { used => 0, user =>"" },
group => { used => 0, group => "" },
interface => [],
ex_interface => [],
listen_on => [],
alias => [],
bind_interfaces => { used => 0, line => 0 },
no_hosts => { used => 0, line => 0 },
addn_hosts => { used => 0, line => 0, file => "" },
expand_hosts => { used => 0, line => 0 },
domain => { used => 0, line => 0, domain => "" },
cache_size => { used => 0, line =>0, size => 0 },
neg_cache => { used => 0, line => 0 },
local_ttl => { used => 0, line => 0, ttl => 0 },
log_queries => { used => 0, line => 0 },
dhcp_range => [],
dhcp_host => [],
vendor_class => [],
user_class => [],
dhcp_option => [],
dhcp_boot => { used => 0, line => 0, file => "",
host => "", address => "" },
dhcp_leasemax => { used => 0, line => 0, max => 0 },
dhcp_leasefile => { used => 0, line => 0, file => "" },
dhcp_ethers => { used => 0, line => 0 }
};
#
# parse the configuration file and populate the %config structure
#
sub parse_config_file
{
my $lineno;
my $config = shift;
my $config_file = shift;
$IPADDR = "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}";
$NAME = "[a-zA-Z\_\.][0-9a-zA-Z\_\.]*";
$TIME = "[0-9}+[h|m]*";
$FILE = "[0-9a-zA-Z\_\-\.\/]+";
$NUMBER="[0-9]+";
$lineno=-1;
foreach my $line (@$$config_file)
{
my $subline;
my %temp;
$lineno++;
if (defined ($line))
{
#
# we always use regexp starting with
# ^[\#]*[\s]*
# because that allows for a commented out line with
# possibly space(s) between the comment marker and keyword
# while rejecting any comments that carry our keyword
#
# reject lines blank at start!
next if ($line !~ /^[0-9a-zA-Z\_\-\#]/);
# MX records server?
if ( $line =~ /(^[\#]*[\s]*mx-host)\=([0-9a-zA-Z\.\-]*)/ )
{
}
elsif ($line =~ /(^[\#]*[\s]*mx-target)\=([0-9a-zA-Z\.\-]*)/ )
{
}
elsif ($line =~ /^[\#]*[\s]*selfmx/ )
{
$$config{selfmx}{line}=$lineno;
$$config{selfmx}{used}=($line !~ /^\#/);
}
elsif ($line =~ /^[\#]*[\s]*localmx/ )
{
$$config{localmx}{line}=$lineno;
$$config{localmx}{used}=($line !~ /^\#/);
}
# forward names witout a domain?
elsif ($line =~ /^[\#]*[\s]*domain-needed/ )
{
$$config{domain_needed}{used}=($line!~/^\#/);
$$config{domain_needed}{line}=$lineno;
}
#forward names in nonrouted address space?
elsif ($line =~ /^[\#]*[\s]*bogus-priv/ )
{
$$config{bogus_priv}{used}=($line!~/^\#/);
$$config{bogus_priv}{line}=$lineno;
}
# filter windows wierdo names?
elsif ($line =~ /^[\#]*[\s]*filterwin2k/ )
{
$$config{filterwin2k}{used}=($line!~/^\#/);
$$config{filterwin2k}{line}=$lineno;
}
# resolv.conf file
elsif ($line =~ /(^[\#]*[\s]*resolv-file\=)([0-9a-zA-Z\/\.\-]*)/ )
{
$$config{resolv_file}{filename}=$2;
$$config{resolv_file}{line}=$lineno;
$$config{resolv_file}{used}=($line!~/^\#/);
}
# any resolv.conf file at all?
elsif ($line =~ /^[\#]*[\s]*no-resolv/ )
{
$$config{no_resolv}{used}=($line!~/^\#/);
$$config{no_resolv}{line}=$lineno;
}
# upstream servers in order?
elsif ($line =~ /^[\#]*[\s]*strict-order/ )
{
$$config{strict_order}{used}=($line!~/^\#/);
$$config{strict_order}{line}=$lineno;
}
# check resolv. conf regularly?
elsif ($line =~ /^[\#]*[\s]*no-poll/ )
{
$$config{no_poll}{used}=($line!~/^\#/);
$$config{no_poll}{line}=$lineno;
}
# extra name servers?
elsif ($line =~ /(^[\#]*[\s]*server\=)([0-9a-zA-Z\.\-\/]*)/ )
{
$subline=$2;
%temp = {};
if( $subline =~ /\/($NAME)\/($IPADDR)/ )
{
$temp{domain}=$1;
$temp{domain_used}=1;
$temp{address}=$2;
$temp{line}=$lineno;
$temp{used}= ($line !~ /^\#/);
push @{ $$config{servers} }, { %temp };
}
elsif( $subline =~ /($IPADDR)/ )
{
$temp{domain}="";
$temp{domain_used}=0;
$temp{address}=$1;
$temp{line}=$lineno;
$temp{used}= ($line !~ /^\#/);
push @{ $$config{servers} }, { %temp };
}
else
{
print "Error in line $lineno!";
$$config{errors}++;
}
}
# local-only domains
elsif ($line =~ /(^[\#]*[\s]*local\=)([0-9a-zA-Z\.\-\/]*)/ )
{
$subline=$2;
%temp={};
if( $subline =~ /\/($NAME)\// )
{
$temp{domain}=$1;
$temp{lineno}=$lineno;
$temp{used}=($line !~ /^\#/);
push @{ $$config{locals} }, { %temp };
}
else
{
print "Error in line $lineno!";
$$config{errors}++;
}
}
# force lookups to addresses
elsif ($line =~ /(^[\#]*[\s]*address\=)([0-9a-zA-Z\.\-\/]*)/ )
{
$subline=$2;
%temp = {};
if( $subline =~ /\/($NAME)\/($IPADDR)/ )
{
$temp{line}=$lineno;
$temp{domain}=$1;
$temp{addr}=$2;
$temp{used}=($line !~ /^\#/);
push @{ $$config{forced} }, { %temp };
}
else
{
print "Error in line $lineno!";
$$config{errors}++;
}
}
# deprecated /etc/ppp/resolv.conf permissions
elsif ($line =~ /(^[\#]*[\s]*user\=)([0-9a-zA-Z\.\-\/]*)/ )
{
}
elsif ($line =~ /(^[\#]*[\s]*group\=)([0-9a-zA-Z\.\-\/]*)/ )
{
}
# where and how do we listen?
elsif ($line =~ /(^[\#]*[\s]*listen-address\=)([0-9\.]*)/ )
{
$subline=$2;
%temp = {};
if( $subline =~ /($IPADDR)/ )
{
$temp{line}=$lineno;
$temp{address}=$1;
$temp{used}= ($line !~ /^\#/);
push @{ $$config{listen_on} }, { %temp };
}
else
{
print "Error in line $lineno!";
$$config{errors}++;
}
}
elsif ($line =~ /(^[\#]*[\s]*except-interface\=)([0-9a-zA-Z\.\-\/]*)/ )
{
$subline=$2;
%temp = {};
if( $subline =~ /($NAME)/ )
{
$temp{line}=$lineno;
$temp{iface}=$1;
$temp{used}= ($line !~ /^\#/);
push @{ $$config{ex_interface} }, { %temp };
}
else
{
print "Error in line $lineno!";
$$config{errors}++;
}
}
elsif ($line =~ /(^[\#]*[\s]*interface\=)([0-9a-zA-Z\.\-\/]*)/ )
{
$subline=$2;
%temp = {};
if( $subline =~ /($NAME)/ )
{
$temp{line}=$lineno;
$temp{iface}=$1;
$temp{used}= ($line !~ /^\#/);
push @{ $$config{interface} }, { %temp };
}
else
{
print "Error in line $lineno!";
$$config{errors}++;
}
}
elsif ($line =~ /^[\#]*[\s]*bind-interfaces/ )
{
$$config{bind_interfaces}{used}=($line!~/^\#/);
$$config{bind_interfaces}{line}=$lineno;
}
# hosts file
elsif ($line =~ /^[\#]*[\s]*no-hosts/ )
{
$$config{no_hosts}{used}=($line!~/^\#/);
$$config{no_hosts}{line}=$lineno;
}
elsif ($line =~ /(^[\#]*[\s]*addn-hosts\=)([0-9a-zA-Z\_\.\-\/]*)/ )
{
$$config{addn_hosts}{line}=$lineno;
$$config{addn_hosts}{file}=$2;
$$config{addn_hosts}{used}=($line!~/^\#/);
}
# add domain to hosts file?
elsif ($line =~ /^[\#]*[\s]*expand-hosts/ )
{
$$config{expand_hosts}{used}=($line!~/^\#/);
$$config{expand_hosts}{line}=$lineno;
}
# translate wild-card responses to NXDOMAIN
elsif ($line =~ /(^[\#]*[\s]*bogus-nxdomain\=)([0-9\.]*)/ )
{
$subline=$2;
%temp = {};
if( $subline =~ /($IPADDR)/ )
{
$temp{line}=$lineno;
$temp{addr}=$1;
$temp{used}= ($line !~ /^\#/);
push @{ $$config{bogus} }, { %temp };
}
else
{
print "Error in line $lineno!";
$$config{errors}++;
}
}
# local domain
elsif ($line =~ /(^[\#]*[\s]*domain\=)([0-9a-zA-Z\.\-\/]*)/ )
{
$$config{domain}{line}=$lineno;
$$config{domain}{domain}=$2;
$$config{domain}{used}=($line!~/^\#/);
}
# cache size
elsif ($line =~ /(^[\#]*[\s]*cache-size\=)([0-9]*)/ )
{
$$config{cache_size}{line}=$lineno;
$$config{cache_size}{size}=$2;
$$config{cache_size}{used}=($line !~/^\#/);
}
# negative cache
elsif ($line =~ /(^[\#]*[\s]*no-negcache)/ )
{
$$config{neg_cache}{line}=$lineno;
$$config{neg_cache}{used}=($line !~/^\#/);
}
# local ttl
elsif ($line =~ /(^[\#]*[\s]*local-ttl\=)([0-9]*)/ )
{
$$config{local_ttl}{line}=$lineno;
$$config{local_ttl}{ttl}=$2;
$$config{local_ttl}{used}=($line !~/^\#/);
}
# log requests?
elsif ($line =~ /(^[\#]*[\s]*log-queries)/ )
{
$$config{log_queries}{line}=$lineno;
$$config{log_queries}{used}=($line !~/^\#/);
}
# alias IP addresses
elsif ($line =~ /(^[\#]*[\s]*alias\=)([0-9\.\,]*)/ )
{
$subline=$2;
%temp = {};
if( $subline =~ /($IPADDR)\,($IPADDR)\,($IPADDR)/ )
{ # with netmask
$temp{line}=$lineno;
$temp{from}=$1;
$temp{to}=$2;
$temp{netmask}=$3;
$temp{netmask_used}=1;
$temp{used}= ($line !~ /^\#/);
push @{ $$config{alias} }, { %temp };
}
elsif( $subline =~ /($IPADDR)\,($IPADDR)/ )
{ # no netmask
$temp{line}=$lineno;
$temp{from}=$1;
$temp{to}=$2;
$temp{netmask}=0;
$temp{netmask_used}=0;
$temp{used}= ($line !~ /^\#/);
push @{ $$config{alias} }, { %temp };
}
else
{
print "Error in line $lineno!";
$$config{errors}++;
}
}
# DHCP
# address range to use
elsif ($line =~ /(^[\#]*[\s]*dhcp-range\=)([0-9a-zA-Z\.\,\-\_]*)/ )
{
%temp={};
$subline=$2;
$temp{line}=$lineno;
$temp{used}=($line !~/^\#/);
if ($subline =~ /^($NAME)\,($IPADDR)\,($IPADDR)\,($IPADDR)(\,*)(\d*[mh]*)/ )
{
# network id, start, end, netmask, time (optionally)
$temp{id}=$1;
$temp{id_used}=1;
$temp{start}=$2;
$temp{end}=$3;
$temp{mask}=$4;
$temp{mask_used}=1;
$temp{leasetime}=$6;
$temp{time_used}=($6 =~ /^\d/);
$temp{used} =( $line !~ /^\#/ );
push @{ $$config{dhcp_range} }, { %temp };
}
elsif ($subline =~ /^($NAME)\,($IPADDR)\,($IPADDR)(\,*)(\d*[mh]*)/ )
{
# network id, start, end, time (optionally)
$temp{id}=$1;
$temp{id_used}=1;
$temp{start}=$2;
$temp{end}=$3;
$temp{mask}="";
$temp{mask_used}=0;
$temp{leasetime}=$5;
$temp{time_used}=($5 =~ /^\d/);
$temp{used} =( $line !~ /^\#/ );
push @{ $$config{dhcp_range} }, { %temp };
}
elsif ($subline =~ /^($IPADDR)\,($IPADDR)\,($IPADDR)(\,*)(\d*[mh]*)/ )
{
# start, end, netmask, time (optionally)
$temp{id}="";
$temp{id_used}=0;
$temp{start}=$1;
$temp{end}=$2;
$temp{mask}=$3;
$temp{mask_used}=1;
$temp{leasetime}=$5;
$temp{time_used}=($5 =~ /^\d/);
$temp{used} =( $line !~ /^\#/ );
push @{ $$config{dhcp_range} }, { %temp };
}
elsif ($subline =~ /^($IPADDR)\,($IPADDR)(\,*)(\d*[mh]*)/ )
{
# start, end, time (optionally)
$temp{id}="";
$temp{id_used}=0;
$temp{start}=$1;
$temp{end}=$2;
$temp{mask}="";
$temp{mask_used}=0;
$temp{leasetime}=$4;
$temp{time_used}=($4 =~ /^\d/);
$temp{used} =( $line !~ /^\#/ );
push @{ $$config{dhcp_range} }, { %temp };
}
else
{
print "Error in line $lineno!";
$$config{errors}++;
}
}
# specify hosts
elsif ($line =~ /(^[\#]*[\s]*dhcp-host\=)([0-9a-zA-Z\.\:\,\*]*)/)
{
# too many to classify - all as string!
%temp = {};
$temp{line}=$lineno;
$temp{option}=$2;
$temp{used}=($line !~/^\#/);
push @{ $$config{dhcp_host} }, { %temp };
}
# vendor class
elsif ($line =~ /(^[\#]*[\s]*dhcp-vendorclass\=)($NAME)\,($NAME)/ )
{
%temp = {};
$temp{line}=$lineno;
$temp{class}=$2;
$temp{vendor}=$3;
$temp{used}=($line !~/^\#/);
push @{ $$config{vendor_class} }, { %temp };
}
# user class
elsif ($line =~ /(^[\#]*[\s]*dhcp-userclass\=)($NAME)\,($NAME)/ )
{
%temp = {};
$temp{line}=$lineno;
$temp{class}=$2;
$temp{user}=$3;
$temp{used}=($line !~/^\#/);
push @{ $$config{user_class} }, { %temp };
}
# /etc/ethers?
elsif ($line =~ /(^[\#]*[\s]*read-ethers)/ )
{
$$config{dhcp_ethers}{line}=$lineno;
$$config{dhcp_ethers}{used}=($line !~/^\#/);
}
# dchp options
elsif ($line =~ /(^[\#]*[\s]*dhcp-option\=)([0-9a-zA-Z\,\_\.]*)/ )
{
# too many to classify - all as string!
%temp = {};
$temp{line}=$lineno;
$temp{option}=$2;
$temp{used}=($line !~/^\#/);
push @{ $$config{dhcp_option} }, { %temp };
}
# lease time
elsif ($line =~ /(^[\#]*[\s]*dhcp-lease-max\=)([0-9]*)/ )
{
$$config{dhcp_leasemax}{line}=$lineno;
$$config{dhcp_leasemax}{max}=$2;
$$config{dhcp_leasemax}{used}=($line !~/^\#/);
}
# bootp host & file
elsif ($line =~ /(^[\#]*[\s]*dhcp-boot\=)([0-9a-zA-Z0-9\,\_\.\/]*)/ )
{
$subline=$2;
if( $subline =~ /([0-9a-zA-Z\.\-\_\/]+)\,($NAME)\,($IPADDR)/ )
{
$$config{dhcp_boot}{line}=$lineno;
$$config{dhcp_boot}{file}=$1;
$$config{dhcp_boot}{host}=$2;
$$config{dhcp_boot}{address}=$3;
$$config{dhcp_boot}{used}=($line !~/^\#/);
}
}
# leases file
elsif ($line =~ /(^[\#]*[\s]*dhcp-leasefile\=)([0-9a-zA-Z0-9\_\.\/]*)/ )
{
$$config{dhcp_leasefile}{line}=$lineno;
$$config{dhcp_leasefile}{file}=$2;
$$config{dhcp_leasefile}{used}=($line !~/^\#/);
}
else
{
# everything else that's not a comment
# we don't understand so it may be an error!
if( $line !~ /^#/ )
{
$config{errors}++;
}
}
}
}
} #end of sub read_config_file
#
# update the config file array
#
# arguments are:
# $lineno - the line number (array index) to update
# $text - the new contents of the line
# $file - reference to the array to change
# $comm - put a comment marker ('#') at start of line?
# false (0) means comment the line
#
sub update
{
my $lineno = shift;
my $text = shift;
my $file = shift;
my $comm = shift;
my $line;
$line = ( $comm != 0 ) ?
$text :
"#" . $text;
if( $lineno == 0 )
{
push @$file, $line;
}
else
{
@$file[$lineno]=$line;
}
} # end of sub update
1;
dnsmasq/servers.cgi 0000755 0000000 0000000 00000007040 10512350076 013402 0 ustar root root #!/usr/bin/perl
#
# DNSMasq Webmin Module - server.cgi; Upstream Servers config
# Copyright (C) 2006 by Neil Fisher
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This module inherited from the Webmin Module Template 0.79.1 by tn
do '../web-lib.pl';
do '../ui-lib.pl';
do 'dnsmasq-lib.pl';
$|=1;
&init_config("DNSMasq");
%access=&get_module_acl;
## put in ACL checks here if needed
## sanity checks
&header($text{'index_title'}, "", "intro", 1, 1, undef,
"Written by Neil Fisher<BR><A HREF=mailto:neil\@magnecor.com.au>Author</A><BR><A HREF=http://www.authorpage.invalid>Home://page</A>");
# uses the index_title entry from ./lang/en or appropriate
## Insert Output code here
# read config file
$config_file = &read_file_lines( $config{config_file} );
# pass into data structure
# output as web page
my $count=0;
&header( "DNSMasq settings", "" );
&parse_config_file( \%config, \$config_file );
print "<h2>";
print $text{'DNS_servers'};
print "</h2>";
print &ui_form_start( "srv_apply.cgi", "post" );
print "<h3>".$text{dynamic}."</h3>";
print $text{resolv};
print &ui_yesno_radio( "resolv", ($config{no_resolv}{used}?0:1) );
print "<br>".$text{resolv_file_explicit};
print &ui_yesno_radio( "resolv_std", ($config{resolv_file}{used}?1:0) );
print "<br>".$text{resolv_file};
print &ui_textbox( "resolv_file", $config{resolv_file}{filename}, 50 );
print "<br><br>".$text{poll}."<br>";
print &ui_yesno_radio( "poll", ($config{no_poll}{used}?0:1) );
print "<br><br>".$text{strict_order};
print &ui_yesno_radio( "strict", ($config{strict_order}{used}?1:0) );
print "<br><br><h3>".$text{in_file}."</h3>";
print &ui_columns_start( [ $text{domain}, $text{address},
$text{in_use}, "" ], 100 );
foreach my $server ( @{$config{servers}} )
{
local ( $mover, $edit );
if( $count == @{$config{servers}}-1 )
{
$mover="<img src=images/gap.gif>";
}
else
{
$mover = "<a href='srv_move.cgi?idx=$count&".
"dir=down'><img src=".
"images/down.gif border=0></a>";
}
if( $count == 0 )
{
$mover.="<img src=images/gap.gif>";
}
else
{
$mover .= "<a href='srv_move.cgi?idx=$count&".
"dir=up'><img src=images/up.gif ".
"border=0></a>";
}
$edit = "<a href=srv_edit.cgi?idx=$count>".$$server{address}."</a>";
print &ui_columns_row( [ $$server{domain}, $edit,
($$server{used})?$text{used}:$text{not_used}, $mover ],
[ "width=30%", "width=30%", "width=30%", "width=10%" ] );
$count++;
}
print &ui_columns_end();
print "<br><a href=add.cgi?what=server=0.0.0.0&where=servers.cgi>".
$text{new_dns_serv}."</a><hr>";
print "<br>" . &ui_submit( $text{'save_button'} );
print &ui_form_end();
print "<hr>";
print "<a href=\"index.cgi\">";
print $text{'DNS_settings'};
print "</a><br>";
print "<a href=\"iface.cgi\">";
print $text{'iface_config'};
print "</a><br>";
print "<a href=\"alias.cgi\">";
print $text{'alias_config'};
print "</a><br>";
print "<hr>";
print "<a href=\"dhcp.cgi\">";
print $text{'DHCP_config'};
print "</a><br>";
&footer("/", $text{'index'});
# uses the index entry in /lang/en
## if subroutines are not in an extra file put them here
### END of servers.cgi ###.
dnsmasq/iface.cgi 0000755 0000000 0000000 00000007117 10512345430 012763 0 ustar root root #!/usr/bin/perl
#
# DNSMasq Webmin Module - iface.cgi; network interfaces
# Copyright (C) 2006 by Neil Fisher
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This module inherited from the Webmin Module Template 0.79.1 by tn
do '../web-lib.pl';
do '../ui-lib.pl';
do 'dnsmasq-lib.pl';
$|=1;
&init_config("DNSMasq");
%access=&get_module_acl;
## put in ACL checks here if needed
## sanity checks
&header($text{'index_title'}, "", "intro", 1, 1, undef,
"Written by Neil Fisher<BR><A HREF=mailto:neil\@magnecor.com.au>Author</A><BR><A HREF=http://www.authorpage.invalid>Home://page</A>");
# uses the index_title entry from ./lang/en or appropriate
## Insert Output code here
# read config file
$config_file = &read_file_lines( $config{config_file} );
# pass into data structure
# output as web page
my $count=0;
&header( "DNSMasq settings", "" );
&parse_config_file( \%config, \$config_file );
print "<h2>";
print $text{'iface_listen'};
print "</h2>";
print &ui_columns_start( [ $text{iface}, $text{in_use} ], 100 );
foreach my $iface ( @{$config{interface}} )
{
my $edit = "<a href=iface_edit.cgi?idx=$count>".$$iface{iface}."</a>";
print &ui_columns_row( [ $edit, ($$iface{used})?$text{used}:$text{not_used} ],
[ "width=30%", "width=30%", "width=30%" ] );
$count++;
}
print &ui_columns_end();
print "<br><a href=add.cgi?what=interface=new&where=iface.cgi>".
$text{new_iface}."</a><hr>";
print "<h2>";
print $text{'xiface_listen'};
print "</h2>";
$count=0;
print &ui_columns_start( [ $text{xiface}, $text{in_use} ], 100 );
foreach my $iface ( @{$config{ex_interface}} )
{
my $edit = "<a href=xiface_edit.cgi?idx=$count>".$$iface{iface}."</a>";
print &ui_columns_row( [ $edit, ($$iface{used})?$text{used}:$text{not_used} ],
[ "width=30%", "width=30%", "width=30%" ] );
$count++;
}
print &ui_columns_end();
print "<br><a href=add.cgi?what=except-interface=new&where=iface.cgi>".
$text{new_iface}."</a><hr>";
print "<h2>";
print $text{'listen_addr'};
print "</h2>";
$count=0;
print &ui_columns_start( [ $text{listen_addr}, $text{in_use} ], 100 );
foreach my $iface ( @{$config{listen_on}} )
{
my $edit = "<a href=listen_edit.cgi?idx=$count>".$$iface{address}."</a>";
print &ui_columns_row( [ $edit, ($$iface{used})?$text{used}:$text{not_used} ],
[ "width=30%", "width=30%", "width=30%" ] );
$count++;
}
print &ui_columns_end();
print "<br>";
print "<br><a href=add.cgi?what=listen-address=0.0.0.0&where=iface.cgi>".
$text{new_addr}."</a><hr><br>";
print &ui_form_start( 'iface_apply.cgi', "post" );
print $text{bind_iface};
print &ui_yesno_radio( "bind_iface", ($config{bind_interfaces}{used})?1:0 );
print "<br>".&ui_submit( $text{save_button} );
print &ui_form_end();
print "<hr><br><a href=\"index.cgi\">".$text{'DNS_settings'}."</a><br>";
print "<a href=\"servers.cgi\">".$text{'servers_config'}."</a><br>";
print "<a href=\"alias.cgi\">".$text{'alias_config'}."</a><br>";
print "<hr>";
print "<a href=\"dhcp.cgi\">";
print $text{'DHCP_config'};
print "</a><br>";
&footer("/", $text{'index'});
# uses the index entry in /lang/en
## if subroutines are not in an extra file put them here
### END of iface.cgi ###.
dnsmasq/iface_edit.cgi 0000755 0000000 0000000 00000004061 10512324451 013763 0 ustar root root #!/usr/bin/perl
#
# DNSMasq Webmin Module - iface_edit.cgi; edit interface
# Copyright (C) 2006 by Neil Fisher
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This module inherited from the Webmin Module Template 0.79.1 by tn
do '../web-lib.pl';
do '../ui-lib.pl';
do 'dnsmasq-lib.pl';
$|=1;
&init_config("DNSMasq");
%access=&get_module_acl;
## put in ACL checks here if needed
## sanity checks
## Insert Output code here
# read config file
$config_file = &read_file_lines( $config{config_file} );
# pass into data structure
&parse_config_file( \%config, \$config_file );
# read posted data
&ReadParse();
# check for errors in read config
if( $config{errors} > 0 )
{
&header( "DNSMasq settings", "" );
print "<hr><h2>";
print $text{warn_errors};
print $config{errors};
print $text{didnt_apply};
print "</h3><hr>\n";
&footer( "/", $text{'index'});
exit;
}
# adjust everything to what we got
#
&header( "DNSMasq settings", "" );
print "<h2>".$text{edit_iface}."</h2>";
print &ui_form_start( "iface_edit_apply.cgi", "post" );
print &ui_hidden( "idx", $in{idx} );
print "<br>".$text{in_use}.&ui_yesno_radio( "used",
($config{interface}[$in{idx}]{used})?1:0 );
print "<br>".$text{iface_name};
print &ui_textbox( "iface", $config{interface}[$in{idx}]{iface}, 50 );
print "<br><br>" . &ui_submit( $text{'save_button'} )."<br>";
print &ui_form_end();
print "<a href=delete.cgi?idx=".$in{idx}."&what=interface&where=iface.cgi".
">".$text{delet}."</a>";
print "<br><a href=iface.cgi>".$text{iface_config}."</a>";
&footer( "/", $text{'index'});
#
#
# sub-routines
#
### END of iface_edit.cgi ###.
dnsmasq/help/ 0000755 0000000 0000000 00000000000 10507121320 012141 5 ustar root root dnsmasq/help/intro.html 0000644 0000000 0000000 00000002022 10507121320 014156 0 ustar root root <header>DNSmasq Configuration</header>
<h3>Introduction to DNSmasq</h3>
DNSmasq is an integrated DNS caching proxy server and DHCP server designed
to run on a host that is masquerading a local private network to the rest
of the internet. <p>
<h3>Configuring DNSmasq</h3>
In most cases, all you'll need to change will be the local domain name. Under
some circumstances, you may want to change how DNSmasq resolves names to
allow for other local nameservers (if for example you are using a VPN
tunnel to another location).<p>
All the functionality of DNSmasq is beyond the scope of this help file -
please read the man pages!
<h3>Limitations</h3>
Please read the README file.<br>
In Short, this is a quick and dirty implementation with virtually <em>
no error checking</em>. Therefore, it assumes <em>you
know what you are doing!</em> <br>
<h3>Use with care!</h3> If you enter a name where a IP address
should be (for example) then you may need to edit the config file
manually to remove or edit the offending line. YOU HAVE BEEN WARNED!
dnsmasq/alias.cgi 0000755 0000000 0000000 00000007540 10512627251 013011 0 ustar root root #!/usr/bin/perl
#
# DNSMasq Webmin Module - alias.cgi; aliasing and redirection
# Copyright (C) 2006 by Neil Fisher
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This module inherited from the Webmin Module Template 0.79.1 by tn
do '../web-lib.pl';
do '../ui-lib.pl';
do 'dnsmasq-lib.pl';
$|=1;
&init_config("DNSMasq");
%access=&get_module_acl;
## put in ACL checks here if needed
## sanity checks
## Insert Output code here
# read config file
$config_file = &read_file_lines( $config{config_file} );
# pass into data structure
# output as web page
&parse_config_file( \%config, \$config_file );
if( $config{errors} > 0 )
{
my $line="error.cgi?line=xx&type=".$text{err_configbad};
&redirect( $line );
exit;
}
&header($text{'index_title'}, "", "intro", 1, 1, undef,
"Written by Neil Fisher<BR><A HREF=mailto:neil\@magnecor.com.au>Author</A><BR><A HREF=http://www.authorpage.invalid>Home://page</A>");
print "<hr>\n";
# uses the index_title entry from ./lang/en or appropriate
print "<br>\n";
print "<h2>".$text{forced}."</h2>";
print "<br><br>\n";
my $count=0;
print &ui_columns_start( [ $text{forced_domain}, $text{forced_ip},
$text{in_use} ], 100 );
foreach my $frcd ( @{$config{forced}} )
{
my $edit = "<a href=forced_edit.cgi?idx=$count>".$$frcd{domain}."</a>";
print &ui_columns_row( [ $edit, $$frcd{addr}, ($$frcd{used}) ?
$text{used} : $text{not_used} ],
[ "width=30%", "width=30%", "width=30%" ] );
$count++;
}
print &ui_columns_end();
print "<br>\n";
print "<a href=add.cgi?what=address=/new/0.0.0.0&where=alias.cgi>".
$text{forced_add}."</a>";
print "<br>\n";
print "<br><br>\n";
print "<hr>";
print "<br>\n";
print "<h2>".$text{alias}."</h2>";
print "<br><br>\n";
$count=0;
print &ui_columns_start( [ $text{forced_from}, $text{forced_ip},
$text{forced_mask}, $text{in_use} ], 100 );
foreach my $frcd ( @{$config{alias}} )
{
my $edit = "<a href=alias_edit.cgi?idx=$count>".$$frcd{from}."</a>";
print &ui_columns_row( [
$edit, $$frcd{to},
($$frcd{netmask_used}) ?
$$frcd{netmask} : "255.255.255.255",
($$frcd{used}) ?
$text{used} : $text{not_used} ],
[ "width=25%", "width=25%", "width=25%", "width=25%" ] );
$count++;
}
print &ui_columns_end();
print "<br>\n";
print "<a href=add.cgi?what=alias=0.0.0.0,0.0.0.0&where=alias.cgi>".
$text{alias_add}."</a>";
print "<br>\n";
print "<hr>";
print "<br>\n";
print "<h2>".$text{nx}."</h2>";
print "<br><br>\n";
$count=0;
print &ui_columns_start( [ $text{forced_from}, $text{in_use} ], 100 );
foreach my $frcd ( @{$config{bogus}} )
{
my $edit = "<a href=nx_edit.cgi?idx=$count>".$$frcd{addr}."</a>";
print &ui_columns_row( [
$edit,
($$frcd{used}) ?
$text{used} : $text{not_used} ],
[ "width=50%", "width=50%" ] );
$count++;
}
print &ui_columns_end();
print "<br>\n";
print "<a href=add.cgi?what=bogus-nxdomain=0.0.0.0&where=alias.cgi>".
$text{nx_add}."</a>";
print "<br>\n";
print "<hr>";
print "<br><br>\n";
print "<br><br>\n";
print "<a href=\"index.cgi\">";
print $text{'DNS_settings'};
print "</a><br>";
print "<a href=\"servers.cgi\">";
print $text{'DNS_servers'};
print "</a><br>";
print "<a href=\"iface.cgi\">";
print $text{'iface_config'};
print "</a><br>";
print "<hr>";
print "<a href=\"dhcp.cgi\">";
print $text{'DHCP_config'};
print "</a><br>";
&footer("/", $text{'index'});
# uses the index entry in /lang/en
## if subroutines are not in an extra file put them here
### END of alias.cgi ###.
dnsmasq/dhcp.cgi 0000755 0000000 0000000 00000013060 10512347345 012633 0 ustar root root #!/usr/bin/perl
#
# DNSMasq Webmin Module - dhcp.cgi; DHCP config
# Copyright (C) 2006 by Neil Fisher
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This module inherited from the Webmin Module Template 0.79.1 by tn
do '../web-lib.pl';
do '../ui-lib.pl';
do 'dnsmasq-lib.pl';
$|=1;
&init_config("DNSMasq");
%access=&get_module_acl;
## put in ACL checks here if needed
## sanity checks
&header($text{'index_title'}, "", "intro", 1, 1, undef,
"Written by Neil Fisher<BR><A HREF=mailto:neil\@magnecor.com.au>Author</A><BR><A HREF=http://www.authorpage.invalid>Home://page</A>");
# uses the index_title entry from ./lang/en or appropriate
## Insert Output code here
# read config file
$config_file = &read_file_lines( $config{config_file} );
# pass into data structure
# output as web page
&header( "DNSMasq settings", "" );
&parse_config_file( \%config, \$config_file );
print "<hr>\n";
if( $config{errors} > 0 )
{
print "<h3>WARNING: found ";
print $config{errors};
print "errors in config file!</h3><br>\n";
}
print "<br>\n";
print "<h2>$text{'DHCP_settings'}</h2>";
print "<br><hr><br>\n";
my $count;
my $width;
$count=0;
$width="width=33%";
print "<h2>".$text{vendor_classes}."</h2>";
print &ui_columns_start( [ $text{class},
$text{vendor}, $text{in_use} ], 100 );
foreach my $range ( @{$config{vendor_class}} )
{
my $edit = "<a href=vend_edit.cgi?idx=$count>".$$range{class}."</a>";
print &ui_columns_row( [
$edit, $$range{vendor},
($$range{used}) ?
$text{used} : $text{not_used} ],
[ $width, $width, $width ] );
$count++;
}
print &ui_columns_end();
print "<br><a href=add.cgi?what=dhcp-vendorclass=new&where=dhcp.cgi>".
$text{vend_add}."</a><br><hr><br>";
$count=0;
$width="width=33%";
print "<h2>".$text{user_classes}."</h2>";
print &ui_columns_start( [ $text{class},
$text{user}, $text{in_use} ], 100 );
foreach my $range ( @{$config{user_class}} )
{
my $edit = "<a href=user_edit.cgi?idx=$count>".$$range{class}."</a>";
print &ui_columns_row( [
$edit, $$range{user},
($$range{used}) ?
$text{used} : $text{not_used} ],
[ $width, $width, $width ] );
$count++;
}
print &ui_columns_end();
print "<br><a href=add.cgi?what=dhcp-userclass=new&where=dhcp.cgi>".
$text{user_add}."</a><br><hr><br>";
$count=0;
$width="20%";
print "<h2>".$text{dhcp_range}."</h2>";
print &ui_columns_start( [ $text{net_id}, $text{forced_from}, $text{forced_ip},
$text{forced_mask}, $text{leasetime},
$text{in_use} ], 100 );
foreach my $range ( @{$config{dhcp_range}} )
{
my $edit = "<a href=range_edit.cgi?idx=$count>".$$range{start}."</a>";
print &ui_columns_row( [
$$range{id}, $edit, $$range{end}, $$range{mask},
$$range{leasetime},
($$range{used}) ?
$text{used} : $text{not_used} ],
[ $width, $width, $width, $width, $width ] );
$count++;
}
print &ui_columns_end();
print "<br><a href=add.cgi?what=dhcp-range=0.0.0.0,0.0.0.0&where=dhcp.cgi>".
$text{range_add}."</a><br><hr><br>";
$count=0;
$width="width=50%";
print "<h2>".$text{hosts}."</h2>";
print &ui_columns_start( [ $text{hosts}, $text{in_use} ], 100 );
foreach my $range ( @{$config{dhcp_host}} )
{
my $edit = "<a href=host_edit.cgi?idx=$count>".$$range{option}."</a>";
print &ui_columns_row( [
$edit,
($$range{used}) ?
$text{used} : $text{not_used} ],
[ $width, $width ] );
$count++;
}
print &ui_columns_end();
print "<br><a href=add.cgi?what=dhcp-host=new,0.0.0.0&where=dhcp.cgi>".
$text{host_add}."</a><br><hr><br>";
$count=0;
$width="width=50%";
print "<h2>".$text{dhcp_options}."</h2>";
print &ui_columns_start( [ $text{dhcp_option}, $text{in_use} ], 100 );
foreach my $range ( @{$config{dhcp_option}} )
{
my $edit = "<a href=option_edit.cgi?idx=$count>".$$range{option}."</a>";
print &ui_columns_row( [
$edit,
($$range{used}) ?
$text{used} : $text{not_used} ],
[ $width, $width ] );
$count++;
}
print &ui_columns_end();
print "<br><a href=add.cgi?what=dhcp-option=27&where=dhcp.cgi>".
$text{dhcp_add}."</a><br><hr><br>";
print &ui_form_start( 'dhcp_apply.cgi', "get" );
print "<h2>".$text{misc}."</h2><br>";
print $text{read_ethers}.&ui_yesno_radio( "ethers",
($config{dhcp_ethers}{used})?1:0 );
print "<br><br>".$text{use_bootp}.&ui_yesno_radio ( "bootp",
($config{dhcp_boot}{used})?1:0 );
print "<br>".$text{bootp_host}.&ui_textbox( "bootp_host",
$config{dhcp_boot}{host}, 80 );
print "<br>".$text{bootp_file}.&ui_textbox( "bootp_file",
$config{dhcp_boot}{file}, 80 );
print "<br>".$text{bootp_address}.&ui_textbox( "bootp_addr",
$config{dhcp_boot}{address}, 80 );
print "<br><br>".$text{max_leases}.&ui_textbox( "max_leases",
$config{dhcp_leasemax}{max}, 10 );
print "<br><br>".$text{leasefile}.&ui_yesno_radio( "useleasefile",
($config{dhcp_leasefile}{used})?1:0 );
print "<br>".$text{lfiletouse}.&ui_textbox( "leasefile",
$config{dhcp_leasefile}{file}, 80 );
print "<br><br>".&ui_submit( $text{'save_button'} );
print &ui_form_end( );
print "<br><hr><br><a href=\"index.cgi\">";
print $text{'DNS_settings'};
print "</a><br>";
&footer("/", $text{'index'});
# uses the index entry in /lang/en
## if subroutines are not in an extra file put them here
### END of dhcp.cgi ###.
dnsmasq/restart.cgi 0000755 0000000 0000000 00000003005 10507123056 013372 0 ustar root root #!/usr/bin/perl
#
# DNSMasq Webmin Module - restart.cgi; restart DNSmasq
# Copyright (C) 2006 by Neil Fisher
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This module inherited from the Webmin Module Template 0.79.1 by tn
do '../web-lib.pl';
do '../ui-lib.pl';
do 'dnsmasq-lib.pl';
$|=1;
&init_config("DNSMasq");
%access=&get_module_acl;
## put in ACL checks here if needed
## sanity checks
&header($text{'index_title'}, "", "intro", 1, 1, undef,
"Written by Neil Fisher<BR><A HREF=mailto:neil\@magnecor.com.au>Author</A><BR><A HREF=http://www.authorpage.invalid>Home://page</A>");
# uses the index_title entry from ./lang/en or appropriate
## Insert Output code here
# output as web page
my $line=$config{restart};
&header( "DNSMasq settings", "" );
print $text{restarting} . "<br>";
print `$line`;
print "<br><hr><a href=index.cgi>";
print $text{DNS_settings};
print "</a>";
&footer("/", $text{'index'});
# uses the index entry in /lang/en
## if subroutines are not in an extra file put them here
### END of restart.cgi ###.
dnsmasq/srv_apply.cgi 0000755 0000000 0000000 00000004153 10512642213 013727 0 ustar root root #!/usr/bin/perl
#
# DNSMasq Webmin Module - srv_apply.cgi; update DNS server info
# Copyright (C) 2006 by Neil Fisher
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This module inherited from the Webmin Module Template 0.79.1 by tn
do '../web-lib.pl';
do '../ui-lib.pl';
do 'dnsmasq-lib.pl';
$|=1;
&init_config("DNSMasq");
%access=&get_module_acl;
## put in ACL checks here if needed
## sanity checks
## Insert Output code here
# read config file
$config_file = &read_file_lines( $config{config_file} );
# pass into data structure
&parse_config_file( \%config, \$config_file );
# read posted data
&ReadParse();
# check for errors in read config
if( $config{errors} > 0 )
{
my $line = "error.cgi?line=xx&type=".$text{err_configbad};
&redirect( $line );
exit;
}
# check for input data errors
if( ($in{resolv_std}) && ($in{resolv_file} !~ /^$FILE$/) )
{
my $line = "error.cgi?line=".$text{resolv_file};
$line .= "&type=".$text{err_filebad};
&redirect( $line );
exit;
}
# adjust everything to what we got
#
# use resolv.conf?
#
&update( $config{no_resolv}{line}, "no-resolv",
$config_file, ( $in{resolv} == 0 ) );
#
# standard location for resolv.conf?
#
&update( $config{resolv_file}{line}, "resolv-file=".$in{resolv_file},
$config_file, ( $in{resolv_std} == 1 ) );
#
# servers in order provided?
#
&update( $config{strict_order}{line}, "strict-order",
$config_file, ( $in{strict} == 1 ) );
#
# poll resolv.conf?
#
&update( $config{no_poll}{line}, "no-poll",
$config_file, ( $in{poll} == 0 ) );
#
#
# write file!!
&flush_file_lines();
#
# re-load basic page
&redirect( "servers.cgi" );
#
# sub-routines
#
### END of srv_apply.cgi ###.
dnsmasq/restart.sh 0000755 0000000 0000000 00000000340 10506066357 013252 0 ustar root root #!/bin/bash
echo "killing existing process PID is "
cat /var/run/dnsmasq.pid
kill -9 `cat /var/run/dnsmasq.pid`
echo "done. Starting new process..."
/usr/local/sbin/dnsmasq
echo "Done. New PID is "
cat /var/run/dnsmasq.pid
dnsmasq/srv_move.cgi 0000755 0000000 0000000 00000004045 10507102723 013551 0 ustar root root #!/usr/bin/perl
#
# DNSMasq Webmin Module - dns_move.cgi; move server
# Copyright (C) 2006 by Neil Fisher
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This module inherited from the Webmin Module Template 0.79.1 by tn
do '../web-lib.pl';
do '../ui-lib.pl';
do 'dnsmasq-lib.pl';
$|=1;
&init_config("DNSMasq");
%access=&get_module_acl;
## put in ACL checks here if needed
## sanity checks
## Insert Output code here
# read config file
$config_file = &read_file_lines( $config{config_file} );
# pass into data structure
&parse_config_file( \%config, \$config_file );
# read posted data
&ReadParse();
# check for errors in read config
if( $config{errors} > 0 )
{
&header( "DNSMasq settings", "" );
print "<hr><h2>";
print $text{warn_errors};
print $config{errors};
print $text{didnt_apply};
print "</h3><hr>\n";
&footer( "/", $text{'index'});
exit;
}
# adjust everything to what we got
#
my $selected=$config{servers}[$in{idx}]{line};
if( $in{dir} eq "up" )
{
$config{servers}[$in{idx}]{line}=$config{servers}[$in{idx}-1]{line};
$config{servers}[$in{idx}-1]{line}=$selected;
}
else
{
$config{servers}[$in{idx}]{line}=$config{servers}[$in{idx}+1]{line};
$config{servers}[$in{idx}+1]{line}=$selected;
}
foreach my $server (@{$config{servers}})
{
$line= ($$server{domain_used}) ?
"server=/".$$server{domain}."/".$$server{address} :
"server=".$$server{address};
&update( $$server{line}, $line,
$config_file, ($$server{used}) );
}
#
# write file!!
&flush_file_lines();
#
# re-load basic page
&redirect( "servers.cgi" );
#
# sub-routines
#
### END of dns_move.cgi ###.
dnsmasq/srv_edit_apply.cgi 0000755 0000000 0000000 00000003646 10512642225 014745 0 ustar root root #!/usr/bin/perl
#
# DNSMasq Webmin Module - srv_edit_apply.cgi; do the update
# Copyright (C) 2006 by Neil Fisher
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This module inherited from the Webmin Module Template 0.79.1 by tn
do '../web-lib.pl';
do '../ui-lib.pl';
do 'dnsmasq-lib.pl';
$|=1;
&init_config("DNSMasq");
%access=&get_module_acl;
## put in ACL checks here if needed
## sanity checks
## Insert Output code here
# read config file
$config_file = &read_file_lines( $config{config_file} );
# pass into data structure
&parse_config_file( \%config, \$config_file );
# read posted data
&ReadParse();
# check for errors in read config
if( $config{errors} > 0 )
{
my $line = "error.cgi?line=xx&type=".$text{err_configbad};
&redirect( $line );
exit;
}
# check for input data errors
if( $in{addr} !~ /^$IPADDR$/ )
{
my $line = "error.cgi?line=".$text{srv_addr};
$line .= "&type=".$text{err_notip};
&redirect( $line );
exit;
}
if( ($in{named}) && ($in{name} !~ /^$NAME$/) )
{
my $line = "error.cgi?line=".$text{srv_name};
$line .= "&type=".$text{err_domainbad};
&redirect( $line );
exit;
}
# adjust everything to what we got
#
my $line="server=";
$line .= ($in{named})?"/".$in{name}."/":"";
$line .= $in{addr};
&update( $config{servers}[$in{idx}]{line}, $line,
$config_file, ( $in{used} == 1 ) );
#
# write file!!
&flush_file_lines();
#
# re-load basic page
&redirect( "servers.cgi" );
#
# sub-routines
#
### END of srv_edit_apply.cgi ###.
dnsmasq/delete.cgi 0000755 0000000 0000000 00000002654 10512627424 013165 0 ustar root root #!/usr/bin/perl
#
# DNSMasq Webmin Module - delete.cgi; delete a line
# Copyright (C) 2006 by Neil Fisher
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This module inherited from the Webmin Module Template 0.79.1 by tn
do '../web-lib.pl';
do '../ui-lib.pl';
do 'dnsmasq-lib.pl';
$|=1;
&init_config("DNSMasq");
%access=&get_module_acl;
## put in ACL checks here if needed
## sanity checks
## Insert Output code here
# read config file
$config_file = &read_file_lines( $config{config_file} );
# pass into data structure
&parse_config_file( \%config, \$config_file );
# read posted data
&ReadParse();
# check for errors in read config
if( $config{errors} > 0 )
{
my $line="error.cgi?line=xx&type=".$text{err_configbad};
&redirect( $line );
exit;
}
# adjust everything to what we got
#
#
&update( $config{$in{what}}[$in{idx}]{line}, "",
$config_file, 0 );
&flush_file_lines();
&redirect( $in{where} );
#
# sub-routines
#
### END of delete.cgi ###.
dnsmasq/xiface_edit.cgi 0000755 0000000 0000000 00000004104 10512343715 014155 0 ustar root root #!/usr/bin/perl
#
# DNSMasq Webmin Module - xiface_edit.cgi; edit except interface
# Copyright (C) 2006 by Neil Fisher
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This module inherited from the Webmin Module Template 0.79.1 by tn
do '../web-lib.pl';
do '../ui-lib.pl';
do 'dnsmasq-lib.pl';
$|=1;
&init_config("DNSMasq");
%access=&get_module_acl;
## put in ACL checks here if needed
## sanity checks
## Insert Output code here
# read config file
$config_file = &read_file_lines( $config{config_file} );
# pass into data structure
&parse_config_file( \%config, \$config_file );
# read posted data
&ReadParse();
# check for errors in read config
if( $config{errors} > 0 )
{
&header( "DNSMasq settings", "" );
print "<hr><h2>";
print $text{warn_errors};
print $config{errors};
print $text{didnt_apply};
print "</h3><hr>\n";
&footer( "/", $text{'index'});
exit;
}
# adjust everything to what we got
#
&header( "DNSMasq settings", "" );
print "<h2>".$text{edit_xiface}."</h2>";
print &ui_form_start( "xiface_edit_apply.cgi", "post" );
print &ui_hidden( "idx", $in{idx} );
print "<br>".$text{in_use}.&ui_yesno_radio( "used",
($config{ex_interface}[$in{idx}]{used})?1:0 );
print "<br>".$text{xiface_name};
print &ui_textbox( "iface", $config{ex_interface}[$in{idx}]{iface}, 50 );
print "<br><br>" . &ui_submit( $text{'save_button'} )."<br>";
print &ui_form_end();
print "<a href=delete.cgi?idx=".$in{idx}."&what=ex_interface&where=dhcp.cgi>".
$text{delet}."</a>";
print "<br>< a href=iface.cgi>".$text{iface_config}."</a>";
&footer( "/", $text{'index'});
#
#
# sub-routines
#
### END of xiface_edit.cgi ###.
dnsmasq/listen_edit.cgi 0000755 0000000 0000000 00000004070 10512324553 014215 0 ustar root root #!/usr/bin/perl
#
# DNSMasq Webmin Module - listen_edit.cgi; edit listen on
# Copyright (C) 2006 by Neil Fisher
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This module inherited from the Webmin Module Template 0.79.1 by tn
do '../web-lib.pl';
do '../ui-lib.pl';
do 'dnsmasq-lib.pl';
$|=1;
&init_config("DNSMasq");
%access=&get_module_acl;
## put in ACL checks here if needed
## sanity checks
## Insert Output code here
# read config file
$config_file = &read_file_lines( $config{config_file} );
# pass into data structure
&parse_config_file( \%config, \$config_file );
# read posted data
&ReadParse();
# check for errors in read config
if( $config{errors} > 0 )
{
&header( "DNSMasq settings", "" );
print "<hr><h2>";
print $text{warn_errors};
print $config{errors};
print $text{didnt_apply};
print "</h3><hr>\n";
&footer( "/", $text{'index'});
exit;
}
# adjust everything to what we got
#
&header( "DNSMasq settings", "" );
print "<h2>".$text{edit_listen}."</h2>";
print &ui_form_start( "listen_edit_apply.cgi", "post" );
print &ui_hidden( "idx", $in{idx} );
print "<br>".$text{in_use}.&ui_yesno_radio( "used",
($config{listen_on}[$in{idx}]{used})?1:0 );
print "<br>".$text{listen_name};
print &ui_textbox( "addr", $config{listen_on}[$in{idx}]{address}, 50 );
print "<br><br>" . &ui_submit( $text{'save_button'} )."<br>";
print &ui_form_end();
print "<a href=delete.cgi?idx=".$in{idx}."&what=listen_on&where=iface.cgi".
">".$text{delet}."</a>";
print "<br><a href=iface.cgi>".$text{iface_config}."</a>";
&footer( "/", $text{'index'});
#
#
# sub-routines
#
### END of listen_edit.cgi ###.
dnsmasq/nx_edit.cgi 0000755 0000000 0000000 00000004025 10512324660 013343 0 ustar root root #!/usr/bin/perl
#
# DNSMasq Webmin Module - nx_edit.cgi; edit forced NXDOMAIN
# Copyright (C) 2006 by Neil Fisher
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This module inherited from the Webmin Module Template 0.79.1 by tn
do '../web-lib.pl';
do '../ui-lib.pl';
do 'dnsmasq-lib.pl';
$|=1;
&init_config("DNSMasq");
%access=&get_module_acl;
## put in ACL checks here if needed
## sanity checks
## Insert Output code here
# read config file
$config_file = &read_file_lines( $config{config_file} );
# pass into data structure
&parse_config_file( \%config, \$config_file );
# read posted data
&ReadParse();
# check for errors in read config
if( $config{errors} > 0 )
{
&header( "DNSMasq settings", "" );
print "<hr><h2>";
print $text{warn_errors};
print $config{errors};
print $text{didnt_apply};
print "</h3><hr>\n";
&footer( "/", $text{'index'});
exit;
}
# adjust everything to what we got
#
&header( "DNSMasq settings", "" );
print "<h2>".$text{bogus}."</h2>";
print &ui_form_start( "nx_edit_apply.cgi", "post" );
print &ui_hidden( "idx", $in{idx} );
print $text{forced_from}. &ui_textbox( "from",
$config{bogus}[$in{idx}]{addr}, 15 );
print "<br>".$text{in_use}.&ui_yesno_radio( "used",
($config{bogus}[$in{idx}]{used})?1:0 );
print "<br><br>" . &ui_submit( $text{'save_button'} )."<br>";
print &ui_form_end();
print "<a href=delete.cgi?idx=".$in{idx}."&what=bogus&where=alias.cgi".
">".$text{delet}."</a>";
print "<br><a href=alias.cgi>".$text{alias_config}."</a>";
&footer( "/", $text{'index'});
#
#
# sub-routines
#
### END of nx_edit.cgi ###.
dnsmasq/add.cgi 0000755 0000000 0000000 00000002650 10512627117 012446 0 ustar root root #!/usr/bin/perl
#
# DNSMasq Webmin Module - add.cgi; add a line
# Copyright (C) 2006 by Neil Fisher
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This module inherited from the Webmin Module Template 0.79.1 by tn
do '../web-lib.pl';
do '../ui-lib.pl';
do 'dnsmasq-lib.pl';
$|=1;
&init_config("DNSMasq");
%access=&get_module_acl;
## put in ACL checks here if needed
## sanity checks
## Insert Output code here
# read config file
$config_file = &read_file_lines( $config{config_file} );
# pass into data structure
&parse_config_file( \%config, \$config_file );
# read posted data
&ReadParse();
# check for errors in read config
if( $config{errors} > 0 )
{
my $line="error.cgi?line=xx&type=".$text{err_configbad};
&redirect( $line );
exit;
}
# adjust everything to what we got
#
push @{$config_file}, "#".$in{what};
#
# write file!!
&flush_file_lines();
#
# re-load basic page
&redirect( $in{where} );
#
# sub-routines
#
### END of add.cgi ###.
dnsmasq/README 0000644 0000000 0000000 00000004255 10512644024 012106 0 ustar root root
This is the README for the DNSmasq webmin module.
Problems:
1) There's only basic error checking - if you enter some bad
addresses or names, they will go straight into the config file
although we do check for things like IP addresses being of
the correct form (no letters, 4 groups of up to 3 digits
separated by dots etc). One thing that ISN'T CHECKED FOR is
that IP dotted quads are all numbers < 256. Another is that
netmasks are logical (you could enter a netmask of 255.0.255.0
for example). Essentially, if it'll pass the config file
regex scanner (and the above examples will), it won't be
flagged as "bad" even if it is a big no-no for dnsmasq itself.
2) Code is ugly and a kludge - I ain't a programmer! There are probably
a lot of things that could be done to tidy up the code - eg,
it probably wouldn't hurt to move some common stuff into the lib file.
3) I've used the %text hash and written an english lang file, but
I am mono-lingual so no other language support as yet.
4) for reasons unknown to me, the icon does not appear properly
on the servers page of webmin (at least it doesn't for me!)
5) icons have been shamelessly stolen from the ipfilter module,
specifically the up and down arrows.
6) if you delete an item, the config file will contain
an otherwise empty, but commented line. This means that if
you add some new stuff, then delete it, the config file
will have a number of lines at the end that are just comments.
Therefore, the config file could possibly grow quite large.
7) NO INCLUDE FILES!
if you use an include file, it'll be flagged as an error.
OK if the include file line is commented out though.
8) deprecated lines not supported (eg user and group) - they
may produce an error! (user and group don't, but you can't change
them)
IOW, it works, it's just not very elegant and not very robust.
Hope you find it useful though - I do, as I prevents me having to ever
wade through the config file and man pages again.
If you modify it, or add a language file, and you have a spare moment,
please e-mail me - I won't be upset at all if you fix my poor coding!
(rather the opposite - I'd be pleased someone found it usefull)
Cheers,
Neil Fisher <neil@magnecor.com.au>
dnsmasq/iface_edit_apply.cgi 0000755 0000000 0000000 00000003040 10512633233 015165 0 ustar root root #!/usr/bin/perl
#
# DNSMasq Webmin Module - iface_edit_apply.cgi; do the update
# Copyright (C) 2006 by Neil Fisher
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This module inherited from the Webmin Module Template 0.79.1 by tn
do '../web-lib.pl';
do '../ui-lib.pl';
do 'dnsmasq-lib.pl';
$|=1;
&init_config("DNSMasq");
%access=&get_module_acl;
## put in ACL checks here if needed
## sanity checks
## Insert Output code here
# read config file
$config_file = &read_file_lines( $config{config_file} );
# pass into data structure
&parse_config_file( \%config, \$config_file );
# read posted data
&ReadParse();
# check for errors in read config
if( $config{errors} > 0 )
{
my $line = "error.cgi?line=xx&type=".$text{err_configbad};
&redirect( $line );
exit;
}
# adjust everything to what we got
#
my $line="interface=".$in{iface};
&update( $config{interface}[$in{idx}]{line}, $line,
$config_file, ( $in{used} == 1 ) );
#
# write file!!
&flush_file_lines();
#
# re-load basic page
&redirect( "iface.cgi" );
#
# sub-routines
#
### END of iface_edit_apply.cgi ###.
dnsmasq/xiface_edit_apply.cgi 0000755 0000000 0000000 00000003055 10512640306 015362 0 ustar root root #!/usr/bin/perl
#
# DNSMasq Webmin Module - xiface_edit_apply.cgi; do the update
# Copyright (C) 2006 by Neil Fisher
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This module inherited from the Webmin Module Template 0.79.1 by tn
do '../web-lib.pl';
do '../ui-lib.pl';
do 'dnsmasq-lib.pl';
$|=1;
&init_config("DNSMasq");
%access=&get_module_acl;
## put in ACL checks here if needed
## sanity checks
## Insert Output code here
# read config file
$config_file = &read_file_lines( $config{config_file} );
# pass into data structure
&parse_config_file( \%config, \$config_file );
# read posted data
&ReadParse();
# check for errors in read config
if( $config{errors} > 0 )
{
my $line = "error.cgi?line=xx&type=".$text{err_configbad};
&redirect( $line );
exit;
}
# adjust everything to what we got
#
my $line="except-interface=".$in{iface};
&update( $config{ex_interface}[$in{idx}]{line}, $line,
$config_file, ( $in{used} == 1 ) );
#
# write file!!
&flush_file_lines();
#
# re-load basic page
&redirect( "iface.cgi" );
#
# sub-routines
#
### END of _xiface_edit_apply.cgi ###.
dnsmasq/listen_edit_apply.cgi 0000755 0000000 0000000 00000003325 10512642154 015424 0 ustar root root #!/usr/bin/perl
#
# DNSMasq Webmin Module - listen_edit_apply.cgi; do the update
# Copyright (C) 2006 by Neil Fisher
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This module inherited from the Webmin Module Template 0.79.1 by tn
do '../web-lib.pl';
do '../ui-lib.pl';
do 'dnsmasq-lib.pl';
$|=1;
&init_config("DNSMasq");
%access=&get_module_acl;
## put in ACL checks here if needed
## sanity checks
## Insert Output code here
# read config file
$config_file = &read_file_lines( $config{config_file} );
# pass into data structure
&parse_config_file( \%config, \$config_file );
# read posted data
&ReadParse();
# check for errors in read config
if( $config{errors} > 0 )
{
my $line= "error.cgi?line=x&type=".$text{listen_addr};
&redirect( $line );
exit;
}
# check for input data errors
if( $in{addr} !~ /^$IPADDR$/ )
{
my $line= "error.cgi?line=".$text{listen_addr};
$line .= "&type=".$text{err_notip};
&redirect( $line );
exit;
}
# adjust everything to what we got
#
my $line="listen-address=".$in{addr};
&update( $config{listen_on}[$in{idx}]{line}, $line,
$config_file, ( $in{used} == 1 ) );
#
# write file!!
&flush_file_lines();
#
# re-load basic page
&redirect( "iface.cgi" );
#
# sub-routines
#
### END of listen_edit_apply.cgi ###.
dnsmasq/range_edit_apply.cgi 0000755 0000000 0000000 00000005352 10512642203 015217 0 ustar root root #!/usr/bin/perl
#
# DNSMasq Webmin Module - range_edit_apply.cgi; do the update
# Copyright (C) 2006 by Neil Fisher
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This module inherited from the Webmin Module Template 0.79.1 by tn
do '../web-lib.pl';
do '../ui-lib.pl';
do 'dnsmasq-lib.pl';
$|=1;
&init_config("DNSMasq");
%access=&get_module_acl;
## put in ACL checks here if needed
## sanity checks
## Insert Output code here
# read config file
$config_file = &read_file_lines( $config{config_file} );
# pass into data structure
&parse_config_file( \%config, \$config_file );
# read posted data
&ReadParse();
# check for errors in read config
if( $config{errors} > 0 )
{
my $line = "error.cgi?line=xx&type=".$text{err_configbad};
&redirect( $line );
exit;
}
# check for input data errors
if( $in{from} !~ /^$IPADDR$/ )
{
my $line = "error.cgi?line=".$text{forced_from};
$line .= "&type=".$text{err_notip};
&redirect( $line );
exit;
}
if( $in{to} !~ /^$IPADDR$/ )
{
my $line = "error.cgi?line=".$text{forced_ip};
$line .= "&type=".$text{err_notip};
&redirect( $line );
exit;
}
if( ($in{masked}) && ($in{mask} !~ /^$IPADDR$/) )
{
my $line = "error.cgi?line=".$text{forced_mask};
$line .= "&type=".$text{err_notmask};
&redirect( $line );
exit;
}
if( ($in{timed}) && ($in{'time'} !~ /^$TIME$/) )
{
my $line = "error.cgi?line=".$text{leasetime};
$line .= "&type=".$text{err_nottime};
&redirect( $line );
exit;
}
# adjust everything to what we got
#
my $line="dhcp-range=";
$line .= $in{id}."," if $in{ided};
$line .= $in{from}.",".$in{to};
$line .= $in{mask} if $in{masked};
$line .= $in{'time'} if $in{timed};
&update( $config{dhcp_range}[$in{idx}]{line}, $line,
$config_file, ( $in{used} == 1 ) );
#
# write file!!
&flush_file_lines();
#
# re-load basic page
&redirect( "dhcp.cgi" );
#
# sub-routines
#
### END of range_edit_apply.cgi ###.
# adjust everything to what we got
#
my $line="dhcp-range=";
$line .= $in{id}."," if $in{ided};
$line .= $in{from}.",".$in{to};
$line .= $in{mask} if $in{masked};
$line .= $in{'time'} if $in{timed};
&update( $config{dhcp_range}[$in{idx}]{line}, $line,
$config_file, ( $in{used} == 1 ) );
#
# write file!!
&flush_file_lines();
#
# re-load basic page
&redirect( "dhcp.cgi" );
#
# sub-routines
#
### END of range_edit_apply.cgi ###.
dnsmasq/host_edit.cgi 0000755 0000000 0000000 00000004057 10512351537 013703 0 ustar root root #!/usr/bin/perl
#
# DNSMasq Webmin Module - host_edit.cgi; edit DHCP host
# Copyright (C) 2006 by Neil Fisher
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This module inherited from the Webmin Module Template 0.79.1 by tn
do '../web-lib.pl';
do '../ui-lib.pl';
do 'dnsmasq-lib.pl';
$|=1;
&init_config("DNSMasq");
%access=&get_module_acl;
## put in ACL checks here if needed
## sanity checks
## Insert Output code here
# read config file
$config_file = &read_file_lines( $config{config_file} );
# pass into data structure
&parse_config_file( \%config, \$config_file );
# read posted data
&ReadParse();
# check for errors in read config
if( $config{errors} > 0 )
{
&header( "DNSMasq settings", "" );
print "<hr><h2>";
print $text{warn_errors};
print $config{errors};
print $text{didnt_apply};
print "</h3><hr>\n";
&footer( "/", $text{'index'});
exit;
}
# adjust everything to what we got
#
&header( "DNSMasq settings", "" );
print "<h2>".$text{edit_host}."</h2>";
print &ui_form_start( "host_edit_apply.cgi", "post" );
print &ui_hidden( "idx", $in{idx} );
print "<br>".$text{in_use}.&ui_yesno_radio( "used",
($config{dhcp_host}[$in{idx}]{used})?1:0 );
print "<br>".$text{host_spec};
print &ui_textbox( "host", $config{dhcp_host}[$in{idx}]{option}, 80 );
print "<br><br>" . &ui_submit( $text{'save_button'} )."<br>";
print &ui_form_end();
print "<a href=delete.cgi?idx=".$in{idx}."&what=dhcp_host&where=dhcp.cgi".
">".$text{delet}."</a>";
print "<br><a href=dhcp.cgi>".$text{DHCP_settings}."</a>";
&footer( "/", $text{'index'});
#
#
# sub-routines
#
### END of host_edit.cgi ###.
dnsmasq/range_edit.cgi 0000755 0000000 0000000 00000005413 10512347165 014021 0 ustar root root #!/usr/bin/perl
#
# DNSMasq Webmin Module - range_edit.cgi; DHCP range edit
# Copyright (C) 2006 by Neil Fisher
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This module inherited from the Webmin Module Template 0.79.1 by tn
do '../web-lib.pl';
do '../ui-lib.pl';
do 'dnsmasq-lib.pl';
$|=1;
&init_config("DNSMasq");
%access=&get_module_acl;
## put in ACL checks here if needed
## sanity checks
## Insert Output code here
# read config file
$config_file = &read_file_lines( $config{config_file} );
# pass into data structure
&parse_config_file( \%config, \$config_file );
# read posted data
&ReadParse();
# check for errors in read config
if( $config{errors} > 0 )
{
&header( "DNSMasq settings", "" );
print "<hr><h2>";
print $text{warn_errors};
print $config{errors};
print $text{didnt_apply};
print "</h3><hr>\n";
&footer( "/", $text{'index'});
exit;
}
# adjust everything to what we got
#
&header( "DNSMasq settings", "" );
print "<h2>".$text{range_edit}."</h2>";
print &ui_form_start( "range_edit_apply.cgi", "post" );
print &ui_hidden( "idx", $in{idx} );
print "<br>".$text{in_use}.&ui_yesno_radio( "used",
($config{dhcp_range}[$in{idx}]{used})?1:0 );
print "<br>".$text{ided}.&ui_yesno_radio( "ided",
($config{dhcp_range}[$in{idx}]{id_used})?1:0 );
print "<br>".$text{id};
print &ui_textbox( "id", $config{dhcp_range}[$in{idx}]{id}, 50 );
print "<br>".$text{forced_from};
print &ui_textbox( "from", $config{dhcp_range}[$in{idx}]{start}, 18 );
print "<br>".$text{forced_ip};
print &ui_textbox( "to", $config{dhcp_range}[$in{idx}]{end}, 18 );
print "<br>".$text{forced_mask_used}.&ui_yesno_radio( "masked",
($config{dhcp_range}[$in{idx}]{mask_used})?1:0 );
print "<br>".$text{forced_mask};
print &ui_textbox( "mask", $config{dhcp_range}[$in{idx}]{mask}, 18 );
print "<br>".$text{timed}.&ui_yesno_radio( "timed",
($config{dhcp_range}[$in{idx}]{time_used})?1:0 );
print "<br>".$text{leasetime};
print &ui_textbox( "time", $config{dhcp_range}[$in{idx}]{leasetime}, 18 );
print "<br><br>" . &ui_submit( $text{'save_button'} )."<br>";
print &ui_form_end();
print "<a href=delete.cgi?idx=".$in{idx}."&what=dhcp_range&where=dhcp.cgi".
">".$text{delet}."</a>";
print "<br><a href=dhcp.cgi>".$text{DHCP_settings}."</a>";
&footer( "/", $text{'index'});
#
#
# sub-routines
#
### END of range_edit.cgi ###.
dnsmasq/option_edit.cgi 0000755 0000000 0000000 00000004076 10512351517 014235 0 ustar root root #!/usr/bin/perl
#
# DNSMasq Webmin Module - option_edit.cgi; edit DHCP option
# Copyright (C) 2006 by Neil Fisher
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This module inherited from the Webmin Module Template 0.79.1 by tn
do '../web-lib.pl';
do '../ui-lib.pl';
do 'dnsmasq-lib.pl';
$|=1;
&init_config("DNSMasq");
%access=&get_module_acl;
## put in ACL checks here if needed
## sanity checks
## Insert Output code here
# read config file
$config_file = &read_file_lines( $config{config_file} );
# pass into data structure
&parse_config_file( \%config, \$config_file );
# read posted data
&ReadParse();
# check for errors in read config
if( $config{errors} > 0 )
{
&header( "DNSMasq settings", "" );
print "<hr><h2>";
print $text{warn_errors};
print $config{errors};
print $text{didnt_apply};
print "</h3><hr>\n";
&footer( "/", $text{'index'});
exit;
}
# adjust everything to what we got
#
&header( "DNSMasq settings", "" );
print "<h2>".$text{edit_opt}."</h2>";
print &ui_form_start( "option_edit_apply.cgi", "post" );
print &ui_hidden( "idx", $in{idx} );
print "<br>".$text{in_use}.&ui_yesno_radio( "used",
($config{dhcp_option}[$in{idx}]{used})?1:0 );
print "<br>".$text{option_spec};
print &ui_textbox( "host", $config{dhcp_option}[$in{idx}]{option}, 80 );
print "<br><br>" . &ui_submit( $text{'save_button'} )."<br>";
print &ui_form_end();
print "<a href=delete.cgi?idx=".$in{idx}."&what=dhcp_option&where=dhcp.cgi".
">".$text{delet}."</a>";
print "<br><a href=dhcp.cgi>".$text{DHCP_settings}."</a>";
&footer( "/", $text{'index'});
#
#
# sub-routines
#
### END of option_edit.cgi ###.
dnsmasq/host_edit_apply.cgi 0000755 0000000 0000000 00000003032 10512633002 015066 0 ustar root root #!/usr/bin/perl
#
# DNSMasq Webmin Module - host_edit_apply.cgi; do the update
# Copyright (C) 2006 by Neil Fisher
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This module inherited from the Webmin Module Template 0.79.1 by tn
do '../web-lib.pl';
do '../ui-lib.pl';
do 'dnsmasq-lib.pl';
$|=1;
&init_config("DNSMasq");
%access=&get_module_acl;
## put in ACL checks here if needed
## sanity checks
## Insert Output code here
# read config file
$config_file = &read_file_lines( $config{config_file} );
# pass into data structure
&parse_config_file( \%config, \$config_file );
# read posted data
&ReadParse();
# check for errors in read config
if( $config{errors} > 0 )
{
my $line="error.cgi?line=xx&type=".$text{err_configbad};
&redirect( $line );
exit;
}
# adjust everything to what we got
#
my $line="dhcp-host=".$in{host};
&update( $config{dhcp_host}[$in{idx}]{line}, $line,
$config_file, ( $in{used} == 1 ) );
#
# write file!!
&flush_file_lines();
#
# re-load basic page
&redirect( "dhcp.cgi" );
#
# sub-routines
#
### END of host_edit_apply.cgi ###.
dnsmasq/iface_apply.cgi 0000755 0000000 0000000 00000003002 10512633156 014162 0 ustar root root #!/usr/bin/perl
#
# DNSMasq Webmin Module - iface_apply.cgi; do the update
# Copyright (C) 2006 by Neil Fisher
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This module inherited from the Webmin Module Template 0.79.1 by tn
do '../web-lib.pl';
do '../ui-lib.pl';
do 'dnsmasq-lib.pl';
$|=1;
&init_config("DNSMasq");
%access=&get_module_acl;
## put in ACL checks here if needed
## sanity checks
## Insert Output code here
# read config file
$config_file = &read_file_lines( $config{config_file} );
# pass into data structure
&parse_config_file( \%config, \$config_file );
# read posted data
&ReadParse();
# check for errors in read config
if( $config{errors} > 0 )
{
my $line = "error.cgi?line=xx&type=".$text{err_configbad};
&redirect( $line );
exit;
}
# adjust everything to what we got
#
&update( $config{bind_interfaces}{line}, "bind-interfaces",
$config_file, ( $in{bind_iface} == 1 ) );
#
# write file!!
&flush_file_lines();
#
# re-load basic page
&redirect( "iface.cgi" );
#
# sub-routines
#
### END of iface_apply.cgi ###.
dnsmasq/forced_edit.cgi 0000755 0000000 0000000 00000004230 10512324260 014152 0 ustar root root #!/usr/bin/perl
#
# DNSMasq Webmin Module - forced_edit.cgi; forced domain response edit
# Copyright (C) 2006 by Neil Fisher
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This module inherited from the Webmin Module Template 0.79.1 by tn
do '../web-lib.pl';
do '../ui-lib.pl';
do 'dnsmasq-lib.pl';
$|=1;
&init_config("DNSMasq");
%access=&get_module_acl;
## put in ACL checks here if needed
## sanity checks
## Insert Output code here
# read config file
$config_file = &read_file_lines( $config{config_file} );
# pass into data structure
&parse_config_file( \%config, \$config_file );
# read posted data
&ReadParse();
# check for errors in read config
if( $config{errors} > 0 )
{
&header( "DNSMasq settings", "" );
print "<hr><h2>";
print $text{warn_errors};
print $config{errors};
print $text{didnt_apply};
print "</h3><hr>\n";
&footer( "/", $text{'index'});
exit;
}
# adjust everything to what we got
#
&header( "DNSMasq settings", "" );
print "<h2>".$text{forced}."</h2>";
print &ui_form_start( "forced_edit_apply.cgi", "post" );
print &ui_hidden( "idx", $in{idx} );
print $text{forced_domain}. &ui_textbox( "domain",
$config{forced}[$in{idx}]{domain}, 50 );
print "<br>";
print $text{forced_ip}. &ui_textbox( "to",
$config{forced}[$in{idx}]{addr}, 15 );
print "<br>".$text{in_use}.&ui_yesno_radio( "used",
($config{forced}[$in{idx}]{used})?1:0 );
print "<br><br>" . &ui_submit( $text{'save_button'} )."<br>";
print &ui_form_end();
print "<a href=delete.cgi?idx=".$in{idx}."&what=forced&where=alias.cgi".
">".$text{delet}."</a>";
print "<br><a href=alias.cgi>".$text{alias_config}."</a>";
&footer( "/", $text{'index'});
#
#
# sub-routines
#
### END of forced_edit.cgi ###.
dnsmasq/alias_edit.cgi 0000755 0000000 0000000 00000004350 10512627345 014016 0 ustar root root #!/usr/bin/perl
#
# DNSMasq Webmin Module - alias_edit.cgi; IP alias edit
# Copyright (C) 2006 by Neil Fisher
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This module inherited from the Webmin Module Template 0.79.1 by tn
do '../web-lib.pl';
do '../ui-lib.pl';
do 'dnsmasq-lib.pl';
$|=1;
&init_config("DNSMasq");
%access=&get_module_acl;
## put in ACL checks here if needed
## sanity checks
## Insert Output code here
# read config file
$config_file = &read_file_lines( $config{config_file} );
# pass into data structure
&parse_config_file( \%config, \$config_file );
# read posted data
&ReadParse();
# check for errors in read config
if( $config{errors} > 0 )
{
my $line="error.cgi?line=xx&type=".$text{err_configbad};
&redirect( $line );
exit;
}
# adjust everything to what we got
#
&header( "DNSMasq settings", "" );
print "<h2>".$text{alias}."</h2>";
print &ui_form_start( "alias_edit_apply.cgi", "post" );
print &ui_hidden( "idx", $in{idx} );
print $text{forced_from}. &ui_textbox( "from",
$config{alias}[$in{idx}]{from}, 15 );
print "<br>";
print $text{forced_ip}. &ui_textbox( "to",
$config{alias}[$in{idx}]{to}, 15 );
print "<br>";
print $text{forced_mask_used}. &ui_yesno_radio( "mask",
($config{alias}[$in{idx}]{netmask_used})?1:0 );
print $text{forced_mask}. &ui_textbox( "netmask",
$config{alias}[$in{idx}]{netmask}, 15 );
print "<br>".$text{in_use}.&ui_yesno_radio( "used",
($config{forced}[$in{idx}]{used})?1:0 );
print "<br><br>" . &ui_submit( $text{'save_button'} )."<br>";
print &ui_form_end();
print "<a href=delete.cgi?idx=".$in{idx}."&what=alias&where=alias.cgi".
">".$text{delet}."</a>";
print "<br><a href=alias.cgi>".$text{alias_config}."</a>";
&footer( "/", $text{'index'});
#
#
# sub-routines
#
### END of alias_edit.cgi ###.
dnsmasq/option_edit_apply.cgi 0000755 0000000 0000000 00000003040 10512633571 015433 0 ustar root root #!/usr/bin/perl
#
# DNSMasq Webmin Module - option_edit_apply.cgi; do the update
# Copyright (C) 2006 by Neil Fisher
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This module inherited from the Webmin Module Template 0.79.1 by tn
do '../web-lib.pl';
do '../ui-lib.pl';
do 'dnsmasq-lib.pl';
$|=1;
&init_config("DNSMasq");
%access=&get_module_acl;
## put in ACL checks here if needed
## sanity checks
## Insert Output code here
# read config file
$config_file = &read_file_lines( $config{config_file} );
# pass into data structure
&parse_config_file( \%config, \$config_file );
# read posted data
&ReadParse();
# check for errors in read config
if( $config{errors} > 0 )
{
my $line= "error.cgi?line=x&type=".$text{listen_addr};
&redirect( $line );
exit;
}
# adjust everything to what we got
#
my $line="dhcp-option=".$in{host};
&update( $config{dhcp_option}[$in{idx}]{line}, $line,
$config_file, ( $in{used} == 1 ) );
#
# write file!!
&flush_file_lines();
#
# re-load basic page
&redirect( "dhcp.cgi" );
#
# sub-routines
#
### END of option_edit_apply.cgi ###.
dnsmasq/basic_apply.cgi 0000755 0000000 0000000 00000007200 10512642037 014176 0 ustar root root #!/usr/bin/perl
#
# DNSMasq Webmin Module - dns_apply.cgi; update basic DNS info
# Copyright (C) 2006 by Neil Fisher
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This module inherited from the Webmin Module Template 0.79.1 by tn
do '../web-lib.pl';
do '../ui-lib.pl';
do 'dnsmasq-lib.pl';
$|=1;
&init_config("DNSMasq");
%access=&get_module_acl;
## put in ACL checks here if needed
## sanity checks
## Insert Output code here
# read config file
$config_file = &read_file_lines( $config{config_file} );
# pass into data structure
&parse_config_file( \%config, \$config_file );
# read posted data
&ReadParse();
# check for errors in read config
if( $config{errors} > 0 )
{
my $line = "error.cgi?line=xx&type=".$text{err_configbad};
&redirect( $line );
exit;
}
# check user input for obvious errors
if( $in{local_domain} !~ /^$FILE$/ )
{
my $line = "error.cgi?line=".$text{local_domain};
$line .= "&type=".$text{err_domainbad};
&redirect( $line );
exit;
}
if( ($in{xhosts}) && ($in{addn_hosts} !~ /^$FILE$/) )
{
my $line = "error.cgi?line=".$text{xhostsfile};
$line .= "&type=".$text{err_filebad};
&redirect( $line );
exit;
}
if( ($in{cache_size}) && ($in{cust_cache_size} !~ /^$NUMBER/) )
{
my $line = "error.cgi?line=".$text{cust_cache_size};
$line .= "&type=".$text{err_numbbad};
&redirect( $line );
exit;
}
if( ($in{local_ttl}) && ($in{ttl} !~ /^$NUMBER/) )
{
my $line = "error.cgi?line=".$text{ttl};
$line .= "&type=".$text{err_numbbad};
&redirect( $line );
exit;
}
# adjust everything to what we got
#
#our local domain
#
&update( $config{domain}{line}, "domain=".$in{local_domain},
$config_file, 1 );
#
# need domains for forwarded lookups?
#
&update( $config{domain_needed}{line}, "domain-needed",
$config_file, ( $in{domain_needed} == 1 ) );
#
# add local domain to local hosts?
#
&update( $config{expand_hosts}{line}, "expand-hosts",
$config_file, ( $in{expand_hosts} == 1 ) );
#
# reverse lookups of local subnets propogating?
#
# NOTE: reversed logic in question!
&update( $config{bogus_priv}{line}, "bogus-priv",
$config_file, ( $in{bogus_priv} == 0 ) );
#
# reverse lookups of local subnets propogating?
#
&update( $config{filterwin2k}{line}, "filterwin2k",
$config_file, ( $in{filterwin2k} == 1 ) );
#
# read /etc/hosts?
#
# NOTE: reverse logic in config file
&update( $config{no_hosts}{line}, "no-hosts",
$config_file, ( $in{hosts} == 0 ) );
#
# read extra hosts file?
#
&update( $config{addn_hosts}{line}, "addn-hosts=".$in{addn_hosts},
$config_file, ( $in{xhosts} == 1 ) );
#
# negative caching?
#
# NOTE: reverse logic in config file
&update( $config{neg_cache}{line}, "no-negcache",
$config_file, ( $in{neg_cache} == 0 ) );
#
# custom cache size?
#
&update( $config{cache_size}{line}, "cache-size=".$in{cust_cache_size},
$config_file, ( $in{cache_size} == 1 ) );
#
# log all lookups?
#
&update( $config{log_queries}{line}, "log-queries",
$config_file, ( $in{log_queries} == 1 ) );
#
# cache size?
#
&update( $config{local_ttl}{line}, "local-ttl=".$in{ttl},
$config_file, ( $in{local_ttl} == 1) );
#
#
#
# write file!!
&flush_file_lines();
#
# re-load basic page
&redirect( "index.cgi" );
#
# sub-routines
#
### END of dns_apply.cgi ###.
dnsmasq/alias_edit_apply.cgi 0000755 0000000 0000000 00000004073 10512641777 015232 0 ustar root root #!/usr/bin/perl
#
# DNSMasq Webmin Module - alias_edit_apply.cgi; do the update
# Copyright (C) 2006 by Neil Fisher
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This module inherited from the Webmin Module Template 0.79.1 by tn
do '../web-lib.pl';
do '../ui-lib.pl';
do 'dnsmasq-lib.pl';
$|=1;
&init_config("DNSMasq");
%access=&get_module_acl;
## put in ACL checks here if needed
## sanity checks
## Insert Output code here
# read config file
$config_file = &read_file_lines( $config{config_file} );
# pass into data structure
&parse_config_file( \%config, \$config_file );
# read posted data
&ReadParse();
# check for errors in read config
if( $config{errors} > 0 )
{
my $line="error.cgi?line=xx&type=".$text{err_configbad};
&redirect( $line );
exit;
}
# check user input for obvious errors
if( $in{from} !~ /^$IPADDR$/ )
{
my $line="error.cgi?line=".$text{forced_from};
$line .= "&type=".$text{err_notip};
&redirect( $line );
exit;
}
if( $in{to} !~ /^$IPADDR$/ )
{
my $line="error.cgi?line=".$text{forced_ip};
$line .= "&type=".$text{err_notip};
&redirect( $line );
exit;
}
if( ($in{mask}) && ($in{netmask} !~ /^$IPADDR$/) )
{
my $line="error.cgi?line=".$text{forced_mask};
$line .= "&type=".$text{err_notip};
&redirect( $line );
exit;
}
# adjust everything to what we got
#
my $line="alias=".$in{from}.",".$in{to};
$line .= ",".$in{netmask} if $in{mask};
&update( $config{alias}[$in{idx}]{line}, $line,
$config_file, ( $in{used} == 1 ) );
#
# write file!!
&flush_file_lines();
#
# re-load basic page
&redirect( "alias.cgi" );
#
# sub-routines
#
### END of alias_edit_apply.cgi ###.
dnsmasq/forced_edit_apply.cgi 0000755 0000000 0000000 00000003571 10512642101 015363 0 ustar root root #!/usr/bin/perl
#
# DNSMasq Webmin Module - forced_edit_apply.cgi; do the update
# Copyright (C) 2006 by Neil Fisher
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This module inherited from the Webmin Module Template 0.79.1 by tn
do '../web-lib.pl';
do '../ui-lib.pl';
do 'dnsmasq-lib.pl';
$|=1;
&init_config("DNSMasq");
%access=&get_module_acl;
## put in ACL checks here if needed
## sanity checks
## Insert Output code here
# read config file
$config_file = &read_file_lines( $config{config_file} );
# pass into data structure
&parse_config_file( \%config, \$config_file );
# read posted data
&ReadParse();
# check for errors in read config
if( $config{errors} > 0 )
{
my $line="error.cgi?line=xx&type=".$text{err_configbad};
&redirect( $line );
exit;
}
# check for input data errors
if( $in{domain} !~ /^$NAME$/ )
{
my $line="error.cgi?line=".$text{forced_domain};
$line .= "&type=".$text{err_domainbad};
&redirect( $line );
exit;
}
if( $in{to} !~ /^$IPADDR$/ )
{
my $line="error.cgi?line=".$text{forced_domain};
$line .= "&type=".$text{err_domainbad};
&redirect( $line );
exit;
}
# adjust everything to what we got
#
my $line="address=/".$in{domain}."/".$in{to};
&update( $config{forced}[$in{idx}]{line}, $line,
$config_file, ( $in{used} == 1 ) );
#
# write file!!
&flush_file_lines();
#
# re-load basic page
&redirect( "alias.cgi" );
#
# sub-routines
#
### END of forced_edit_apply.cgi ###.
dnsmasq/nx_edit_apply.cgi 0000755 0000000 0000000 00000003311 10512642170 014544 0 ustar root root #!/usr/bin/perl
#
# DNSMasq Webmin Module - nx_edit_apply.cgi; do the update
# Copyright (C) 2006 by Neil Fisher
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This module inherited from the Webmin Module Template 0.79.1 by tn
do '../web-lib.pl';
do '../ui-lib.pl';
do 'dnsmasq-lib.pl';
$|=1;
&init_config("DNSMasq");
%access=&get_module_acl;
## put in ACL checks here if needed
## sanity checks
## Insert Output code here
# read config file
$config_file = &read_file_lines( $config{config_file} );
# pass into data structure
&parse_config_file( \%config, \$config_file );
# read posted data
&ReadParse();
# check for errors in read config
if( $config{errors} > 0 )
{
my $line= "error.cgi?line=x&type=".$text{listen_addr};
&redirect( $line );
exit;
}
# check for input data errors
if( $in{from} !~ /^$IPADDR$/ )
{
my $line= "error.cgi?line=".$text{forced_from};
$line .= "&type=".$text{err_notip};
&redirect( $line );
exit;
}
# adjust everything to what we got
#
my $line="bogus-nxdomain=".$in{from};
&update( $config{bogus}[$in{idx}]{line}, $line,
$config_file, ( $in{used} == 1 ) );
#
# write file!!
&flush_file_lines();
#
# re-load basic page
&redirect( "alias.cgi" );
#
# sub-routines
#
### END of nx_edit_apply.cgi ###.
dnsmasq/user_edit.cgi 0000755 0000000 0000000 00000004171 10512343452 013676 0 ustar root root #!/usr/bin/perl
#
# DNSMasq Webmin Module - vend_edit.cgi; edit user class
# Copyright (C) 2006 by Neil Fisher
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This module inherited from the Webmin Module Template 0.79.1 by tn
do '../web-lib.pl';
do '../ui-lib.pl';
do 'dnsmasq-lib.pl';
$|=1;
&init_config("DNSMasq");
%access=&get_module_acl;
## put in ACL checks here if needed
## sanity checks
## Insert Output code here
# read config file
$config_file = &read_file_lines( $config{config_file} );
# pass into data structure
&parse_config_file( \%config, \$config_file );
# read posted data
&ReadParse();
# check for errors in read config
if( $config{errors} > 0 )
{
&header( "DNSMasq settings", "" );
print "<hr><h2>";
print $text{warn_errors};
print $config{errors};
print $text{didnt_apply};
print "</h3><hr>\n";
&footer( "/", $text{'index'});
exit;
}
# adjust everything to what we got
#
&header( "DNSMasq settings", "" );
print "<h2>".$text{user_classes}."</h2>";
print &ui_form_start( "user_edit_apply.cgi", "post" );
print &ui_hidden( "idx", $in{idx} );
print $text{in_use}.&ui_yesno_radio( "used",
($config{user_class}[$in{idx}]{used})?1:0 );
print $text{class}. &ui_textbox( "class",
$config{user_class}[$in{idx}]{class}, 60 );
print "<br>".$text{user}. &ui_textbox( "user",
$config{user_class}[$in{idx}]{user}, 60 );
print "<br><br>" . &ui_submit( $text{'save_button'} )."<br>";
print &ui_form_end();
print "<a href=delete.cgi?idx=".$in{idx}."&what=user_class&where=dhcp.cgi".
">".$text{delet}."</a>";
print "<br><a href=dhcp.cgi>".$text{DHCP_config}."</a>";
&footer( "/", $text{'index'});
#
#
# sub-routines
#
### END of user_edit.cgi ###.
dnsmasq/vend_edit.cgi 0000755 0000000 0000000 00000004210 10512343567 013655 0 ustar root root #!/usr/bin/perl
#
# DNSMasq Webmin Module - vend_edit.cgi; edit vendor class
# Copyright (C) 2006 by Neil Fisher
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This module inherited from the Webmin Module Template 0.79.1 by tn
do '../web-lib.pl';
do '../ui-lib.pl';
do 'dnsmasq-lib.pl';
$|=1;
&init_config("DNSMasq");
%access=&get_module_acl;
## put in ACL checks here if needed
## sanity checks
## Insert Output code here
# read config file
$config_file = &read_file_lines( $config{config_file} );
# pass into data structure
&parse_config_file( \%config, \$config_file );
# read posted data
&ReadParse();
# check for errors in read config
if( $config{errors} > 0 )
{
&header( "DNSMasq settings", "" );
print "<hr><h2>";
print $text{warn_errors};
print $config{errors};
print $text{didnt_apply};
print "</h3><hr>\n";
&footer( "/", $text{'index'});
exit;
}
# adjust everything to what we got
#
&header( "DNSMasq settings", "" );
print "<h2>".$text{vendor_classes}."</h2>";
print &ui_form_start( "vend_edit_apply.cgi", "post" );
print &ui_hidden( "idx", $in{idx} );
print $text{in_use}.&ui_yesno_radio( "used",
($config{vendor_class}[$in{idx}]{used})?1:0 );
print $text{class}. &ui_textbox( "class",
$config{vendor_class}[$in{idx}]{class}, 60 );
print "<br>".$text{vendor}. &ui_textbox( "vendor",
$config{vendor_class}[$in{idx}]{vendor}, 60 );
print "<br><br>" . &ui_submit( $text{'save_button'} )."<br>";
print &ui_form_end();
print "<a href=delete.cgi?idx=".$in{idx}."&what=vendor_class&where=dhcp.cgi>".
$text{delet}."</a>";
print "<br><a href=dhcp.cgi>".$text{DHCP_config}."</a>";
&footer( "/", $text{'index'});
#
#
# sub-routines
#
### END of vend_edit.cgi ###.
dnsmasq/dhcp_apply.cgi 0000755 0000000 0000000 00000005362 10512642064 014042 0 ustar root root #!/usr/bin/perl
#
# DNSMasq Webmin Module - dhcp_apply.cgi; update misc DHCP info
# Copyright (C) 2006 by Neil Fisher
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This module inherited from the Webmin Module Template 0.79.1 by tn
do '../web-lib.pl';
do '../ui-lib.pl';
do 'dnsmasq-lib.pl';
$|=1;
&init_config("DNSMasq");
%access=&get_module_acl;
## put in ACL checks here if needed
## sanity checks
## Insert Output code here
# read config file
$config_file = &read_file_lines( $config{config_file} );
# pass into data structure
&parse_config_file( \%config, \$config_file );
# read posted data
&ReadParse();
# check for errors in read config
if( $config{errors} > 0 )
{
my $line="error.cgi?line=xx&type=".$text{err_configbad};
&redirect( $line );
exit;
}
# check for input data errors
if( $in{bootp_addr} !~ /^$IPADDR$/ )
{
my $line="error.cgi?line=".$text{bootp_address};
$line .= "&type=".$text{err_notip};
&redirect( $line );
exit;
}
if( $in{bootp_file} !~ /^$FILE$/ )
{
my $line="error.cgi?line=".$text{bootp_file};
$line .= "&type=".$text{err_filebad};
&redirect( $line );
exit;
}
if( $in{bootp_host} !~ /^$NAME$/ )
{
my $line="error.cgi?line=".$text{bootp_host};
$line .= "&type=".$text{err_hostbad};
&redirect( $line );
exit;
}
if( $in{max_leases} !~ /^$NUMBER$/ )
{
my $line="error.cgi?line=".$text{max_leases};
$line .= "&type=".$text{err_numbbad};
&redirect( $line );
exit;
}
if( $in{leasefile} !~ /^$FILE$/ )
{
my $line="error.cgi?line=".$text{leasefile};
$line .= "&type=".$text{err_filebad};
&redirect( $line );
exit;
}
# adjust everything to what we got
#
# read /etc/ethers
#
&update( $config{dhcp_ethers}{line}, "read-ethers",
$config_file, ($in{ethers} == 1) );
#
# bootp
#
my $line="dhcp-boot=".$in{bootp_file}.",".$in{bootp_host};
$line .= ",".$in{bootp_addr};
&update( $config{dhcp_boot}{line}, $line,
$config_file, ($in{bootp} == 1) );
#
# max leases
#
&update( $config{dhcp_leasemax}{line}, "dhcp-lease-max=".$in{max_leases},
$config_file, ($in{max_leases} != 150) );
#
# leases file
#
&update( $config{dhcp_leasefile}{line}, "dhcp-leasefile=".$in{leasefile},
$config_file, ($in{useleasefile} == 1) );
#
# write file!!
&flush_file_lines();
#
# re-load basic page
&redirect( "dhcp.cgi" );
#
# sub-routines
#
### END of dhcp_apply.cgi ###.
dnsmasq/user_edit_apply.cgi 0000755 0000000 0000000 00000003557 10512642234 015112 0 ustar root root #!/usr/bin/perl
#
# DNSMasq Webmin Module - user_edit_apply.cgi; do the update
# Copyright (C) 2006 by Neil Fisher
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This module inherited from the Webmin Module Template 0.79.1 by tn
do '../web-lib.pl';
do '../ui-lib.pl';
do 'dnsmasq-lib.pl';
$|=1;
&init_config("DNSMasq");
%access=&get_module_acl;
## put in ACL checks here if needed
## sanity checks
## Insert Output code here
# read config file
$config_file = &read_file_lines( $config{config_file} );
# pass into data structure
&parse_config_file( \%config, \$config_file );
# read posted data
&ReadParse();
# check for errors in read config
if( $config{errors} > 0 )
{
my $line = "error.cgi?line=xx&type=".$text{err_configbad};
&redirect( $line );
exit;
}
# check for input data errors
if( $in{class} !~ /^$NAME$/ )
{
my $line = "error.cgi?line=".$text{class};
$line .= "&type=".$text{err_namebad};
&redirect( $line );
exit;
}
if( $in{user} !~ /^$NAME$/ )
{
my $line = "error.cgi?line=".$text{user};
$line .= "&type=".$text{err_namebad};
&redirect( $line );
exit;
}
# adjust everything to what we got
#
my $line="dhcp-userclass=".$in{class}.",".$in{user};
&update( $config{user_class}[$in{idx}]{line}, $line,
$config_file, ( $in{used} == 1 ) );
#
# write file!!
&flush_file_lines();
#
# re-load basic page
&redirect( "dhcp.cgi" );
#
# sub-routines
#
### END of user_edit_apply.cgi ###.
dnsmasq/vend_edit_apply.cgi 0000755 0000000 0000000 00000003573 10512642243 015066 0 ustar root root #!/usr/bin/perl
#
# DNSMasq Webmin Module - vend_edit_apply.cgi; do the update
# Copyright (C) 2006 by Neil Fisher
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This module inherited from the Webmin Module Template 0.79.1 by tn
do '../web-lib.pl';
do '../ui-lib.pl';
do 'dnsmasq-lib.pl';
$|=1;
&init_config("DNSMasq");
%access=&get_module_acl;
## put in ACL checks here if needed
## sanity checks
## Insert Output code here
# read config file
$config_file = &read_file_lines( $config{config_file} );
# pass into data structure
&parse_config_file( \%config, \$config_file );
# read posted data
&ReadParse();
# check for errors in read config
if( $config{errors} > 0 )
{
my $line = "error.cgi?line=xx&type=".$text{err_configbad};
&redirect( $line );
exit;
}
# check for input data errors
if( $in{class} !~ /^$NAME$/ )
{
my $line = "error.cgi?line=".$text{class};
$line .= "&type=".$text{err_namebad};
&redirect( $line );
exit;
}
if( $in{vendor} !~ /^$NAME$/ )
{
my $line = "error.cgi?line=".$text{vendor};
$line .= "&type=".$text{err_namebad};
&redirect( $line );
exit;
}
# adjust everything to what we got
#
my $line="dhcp-vendorclass=".$in{class}.",".$in{vendor};
&update( $config{vendor_class}[$in{idx}]{line}, $line,
$config_file, ( $in{used} == 1 ) );
#
# write file!!
&flush_file_lines();
#
# re-load basic page
&redirect( "dhcp.cgi" );
#
# sub-routines
#
### END of vend_edit_apply.cgi ###.
dnsmasq/error.cgi 0000755 0000000 0000000 00000003026 10511350547 013044 0 ustar root root #!/usr/bin/perl
#
# DNSMasq Webmin Module - error.cgi; report errors
# Copyright (C) 2006 by Neil Fisher
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This module inherited from the Webmin Module Template 0.79.1 by tn
do '../web-lib.pl';
do '../ui-lib.pl';
do 'dnsmasq-lib.pl';
$|=1;
&init_config("DNSMasq");
%access=&get_module_acl;
## put in ACL checks here if needed
## sanity checks
&header($text{'index_title'}, "", "intro", 1, 1, undef,
"Written by Neil Fisher<BR><A HREF=mailto:neil\@magnecor.com.au>Author</A><BR><A HREF=http://www.authorpage.invalid>Home://page</A>");
# uses the index_title entry from ./lang/en or appropriate
## Insert Output code here
# output as web page
&ReadParse();
print "<h2>".$text{error_heading}."</h2>";
print "<br><br>";
print $text{err_line};
print $in{line};
print "<br>\n";
print $text{err_type};
print $in{type};
print "<br><br>\n";
print $text{err_help};
&footer("/", $text{'index'});
# uses the index entry in /lang/en
## if subroutines are not in an extra file put them here
### END of error.cgi ###.
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>