📄 save_net.cgi
字号:
#! /usr/bin/perl## B9DDNS - BIND 9 dynamic DNS webmin module.# Copyright (C) 2003 John Horne. <john.horne@plymouth.ac.uk># Copyright (C) 2004 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.### Save global address options.#use strict;no strict 'vars';require './b9ddns-lib.pl';my $i = 0;my $conf = my $options = my $addr = my $dir = my $not = my $port = '';my @listen = my @qvals = ();%access = &get_module_acl();unless ($access{'defaults'}) { &terror('net_ecannot');}&error_setup($text{'net_err'});&ReadParse();&lock_file($config{'chroot'} . $config{'named_conf'});$conf = &get_config();$options = &find('options', $conf);$options = &create_entry('options', $conf) unless (defined($options));unless ($in{'listen4_def'}) { for ($i = 0; defined($addr = $in{"addrs4_$i"}); $i++) { &trim($addr); next unless ($addr); if ($addr =~ /^!\s*(.*)$/o) { $not = '!'; $addr = $1; unless ($addr) { &terror('edit_eipmissing'); } } else { $not = ''; } if (&check_ipaddress($addr)) { $addr = &compress_ip($addr); } else { &terror('edit_eip', $addr); } $dir = { 'name' => 'listen-on', 'type' => 1 }; unless ($in{"pdef4_$i"}) { $port = $in{"port4_$i"}; &trim($port); unless ($port) { &terror('controls_eport'); } elsif ($port =~ /\D/o || $port > 65535) { &terror('net_eport', $port); } $dir->{'values'} = [ 'port', $port ]; } $dir->{'members'} = [ { 'name' => $not . $addr } ]; push(@listen, $dir); }}&save_directive($options, 'listen-on', \@listen, 1);@listen = ();if (! $in{'listen6_def'} && $in{'addrs6'} != -1) { $dir = { 'name' => 'listen-on-v6', 'type' => 1 }; unless ($in{'pdef6'}) { $port = $in{'port6'}; &trim($port); unless ($port) { &terror('controls_eport'); } elsif ($port =~ /\D/o || $port > 65535) { &terror('net_eport', $port); } $dir->{'values'} = [ 'port', $port ]; } $dir->{'members'} = [ { 'name' => $in{'addrs6'} ? 'any' : 'none' } ]; push(@listen, $dir);}&save_directive($options, 'listen-on-v6', \@listen, 1);if ($in{'saddr4_def'} == -1) { push(@qvals, 'address', '*');}elsif ($in{'saddr4_def'} == 0) { &trim($in{'saddr4'}); unless ($in{'saddr4'}) { &terror('edit_eipmissing'); } elsif (&check_ipaddress($in{'saddr4'})) { $in{'saddr4'} = &compress_ip($in{'saddr4'}); } else { &terror('edit_eip', $in{'saddr4'}); } push(@qvals, 'address', $in{'saddr4'});}if ($in{'sport4_def'} == -1) { push(@qvals, 'port', '*');}elsif ($in{'sport4_def'} == 0) { $port = $in{'sport4'}; &trim($port); unless ($port) { &terror('controls_eport'); } elsif ($port =~ /\D/o || $port > 65535) { &terror('edit_eport', $port); } push(@qvals, 'port', $port);}if (@qvals) { &save_directive($options, 'query-source', [ { 'name' => 'query-source', 'values' => \@qvals } ], 1);}else { &save_directive($options, 'query-source', [ ], 1);}@qvals = ();if ($in{'saddr6_def'} == -1) { push(@qvals, 'address', '*');}elsif ($in{'saddr6_def'} == 0) { &trim($in{'saddr6'}); unless ($in{'saddr6'}) { &terror('edit_eipmissing'); } elsif (&check_ip6address($in{'saddr6'})) { $in{'saddr6'} = &compress_ip6($in{'saddr6'}); } else { &terror('edit_eip6', $in{'saddr6'}); } push(@qvals, 'address', $in{'saddr6'});}if ($in{'sport6_def'} == -1) { push(@qvals, 'port', '*');}elsif ($in{'sport6_def'} == 0) { $port = $in{'sport6'}; &trim($port); unless ($port) { &terror('controls_eport'); } elsif ($port =~ /\D/o || $port > 65535) { &terror('edit_eport', $port); } push(@qvals, 'port', $port);}if (@qvals) { &save_directive($options, 'query-source-v6', [ { 'name' => 'query-source-v6', 'values' => \@qvals } ], 1);}else { &save_directive($options, 'query-source-v6', [ ], 1);}&flush_file_lines();&unlock_file($config{'chroot'} . $config{'named_conf'});&webmin_log('net', undef, undef, \%in);&redirect('');exit;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -