📄 create_forward.cgi
字号:
#! /usr/bin/perl## B9DDNS - BIND 9 dynamic DNS webmin module.# Copyright (C) 2003 John Horne. <john.horne@plymouth.ac.uk>## 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.## You should have received a copy of the GNU General Public License# along with this program; if not, write to the Free Software# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.### Create a new forward zone.#use strict;no strict 'vars';require './b9ddns-lib.pl';my $ipv4 = my $ipv6 = 0;my $conf = my $vconf = my $directive = '';my $zone = my $zone_conf = my $view = '';my $zone_file = my $newidx = '';&ReadParse();&error_setup($text{'fcreate_err'});%access = &get_module_acl();unless ($access{'forward'}) { &terror('fcreate_ecannot');}if ($access{'ro'}) { &terror('master_ero');}$conf = &get_config();if ($in{'view'}) { $view = $conf->[$in{'view'}]; unless (&can_edit_view(\%access, $view)) { &terror('master_eview'); } $vconf = $view->{'members'};}else { $vconf = $conf;}$newidx = @$vconf;## Validate the inputs.#$in{'zone'} = lc($in{'zone'});if ($in{'rev'}) { if ($in{'zone'} =~ /\.(in-addr|ip6)\.arpa\.?$/o) { $ipv4 = ($1 eq 'in-addr'); $in{'zone'} .= '.' unless ($in{'zone'} =~ /\.$/o); $in{'zone'} = ($ipv4) ? &arpa_to_ip($in{'zone'}) : &ip6arpa_to_net($in{'zone'}); } $ipv4 = ($in{'zone'} =~ /^([\d.]+)$/o) && &valipaddr($1, '.in-addr.arpa.', 1, 0, 1, 1); $ipv6 = ($in{'zone'} =~ /^([\da-f:]+)$/o) && &valipaddr($1, '.ip6.arpa.', 1, 0, 1, 0); unless ($ipv4 || $ipv6) { &terror('create_enet', $in{'zone'}); } $in{'zone'} = ($ipv4) ? &ip_to_arpa($in{'zone'}) : &net_to_ip6arpa($in{'zone'});}else { $in{'zone'} .= '.' unless ($in{'zone'} =~ /\.$/o); if ($in{'zone'} =~ /^[\d.]+$/o || $in{'zone'} =~ /:/o) { &terror('create_edom2', $in{'zone'}); } unless (&valdnsname($in{'zone'}, 0, '.')) { &terror('create_edom', $in{'zone'}); }}$in{'zone'} =~ s/\.$//o;foreach $zone (&find('zone', $vconf)) { if ($zone->{'value'} =~ /^$in{'zone'}\.?$/i) { &terror('master_etaken'); }}## Before creating the zone directive we need to setup the structure first, and# then save the master server addresses into that structure -this will do all# the error checking of the master server addresses for us. Finally, we can# then save the whole directive into the named.conf file.#$zone_conf = ($in{'view'}) ? $view : &get_config_parent();$directive = { 'name' => 'zone', 'values' => [ $in{'zone'} ], 'type' => 1, 'members' => [ { 'name' => 'type', 'values' => [ 'forward' ] } ] };&save_directive($zone_conf, 'zone', [ $directive ], 0, 1, -1);&save_addr_match('forwarders', $directive, 1, 1, 1);## Now create the zone directive.#if ($in{'view'}) { $zone_file = $view->{'file'};}else { $zone_file = $config{'zones_file'} ? $config{'zones_file'} : $config{'named_conf'};}&lock_file($config{'chroot'} . $zone_file);&save_directive($zone_conf, 'zone', [ $directive ], 0, 0, -1);&flush_file_lines();&unlock_file($config{'chroot'} . $zone_file);## Add the new zone to the access list.#&add_zone_access($in{'zone'});&webmin_log('create', 'forward', $in{'zone'}, \%in);&redirect("edit_zone.cgi?index=${newidx}&view=$in{'view'}&type=forward&new_zone=1");exit;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -