📄 save_record.cgi
字号:
$value = &ip_to_arpa($v); } else { $v = &expand_ip6(&ip6arpa_to_net($value)); $value = &net_to_ip6arpa($v); } unless (&valipaddr($v, $1, 0, 0, 1, -1)) { &terror(($1 eq '.in-addr.arpa.') ? 'edit_eip' : 'edit_eip6', $v); } } elsif (! &valdnsname($value, 0, $origin)) { &terror('edit_ecname', $value); }}elsif ($type eq 'DNAME') { unless ($value) { &terror('edit_emissing_value'); } $value = &convert_fqdn(1, $value, $origin, 1); if ($value =~ /(\.(in-addr|ip6)\.arpa\.)$/o) { if ($2 eq 'in-addr') { $v = &compress_ip(&arpa_to_ip($value)); $value = &ip_to_arpa($v); if ($name =~ /^(\d+\.){4}/o) { &terror('edit_edname', &arpa_to_ip($name)); } elsif ($v =~ /^(\d+\.){3}\d+$/o) { &terror('edit_edname', $v); } if (($name =~ tr/././) != ($value =~ tr/././)) { &terror('edit_edname_len'); } } else { # # For IPv6 sub-domains we must preserve any leading # zeros in the final part of the sub-domain. Otherwise # it will be filled with leading zeros, and hence give # us the wrong sub-domain. We must do this for the # label and the DNAME value. # $sfx = ($in{'value0'} =~ /([^:]*)$/o) ? $1 : ''; $v = &ip6arpa_to_net($value); $v =~ s/[^:]+$//o; $v .= $sfx; if ($v =~ /^([\da-f]+:){7}[\da-f]{4}$/o) { &terror('edit_edname', $v); } else { $value = &net_to_ip6arpa($v); $sfx = join('.', split(//, reverse($sfx))); $value =~ s/^([\da-f]\.){4}//o; $value = $sfx . '.' . $value; } # # Now do the same thing for the record label. # $sfx = ($in{'name'} =~ /([^:]*)$/o) ? $1 : ''; $sfx = join('.', split(//, reverse($sfx))); $name =~ s/^([\da-f]\.){4}//o; $name = $sfx . '.' . $name; if ($name =~ /^([\da-f]\.){32}/o) { &terror('edit_edname', &ip6arpa_to_net($name)); } if (length($name) != length($value)) { &terror('edit_edname_len'); } } unless (&valipaddr($v, $1, 0, 0, 1, -1)) { &terror(($1 eq '.in-addr.arpa.') ? 'edit_eip' : 'edit_eip6', $v); } } elsif (! &valdnsname($value, 0, $origin)) { &terror('edit_edname', $value); }}elsif ($type eq 'MX') { unless ($value) { &terror('edit_emissing_value'); } $v = &convert_fqdn(1, $in{'value1'}, $origin, 1); if ($v !~ /\.(in-addr|ip6)\.arpa\.$/o && &valdnsname($v, 0, $origin)) { $value = $in{'value0'} . ' ' . $v; } else { &terror('edit_emx', $in{'value1'}); } if ($in{'value0'} =~ /\D/o) { &terror('edit_epri', $in{'value0'}); }}elsif ($type eq 'HINFO') { unless ($value) { &terror('edit_emissing_value'); } if ($in{'value0'} =~ /[\s;"]/o) { &terror('edit_ehard'); } if ($in{'value1'} =~ /[\s";]/o) { &terror('edit_eos'); }}elsif ($type eq 'TXT') { my @str = (); $v = ''; &trim($value); $value =~ s/([;"])/\\$1/g; $value =~ s/(\\")/\\\\$1/g if ($dynamic); @str = split(/\s+/, $value); foreach $z (@str) { if (length($z) > 255) { &terror('edit_etxt_toolong1', $z); } else { $v .= $z . ' '; } } $v =~ s/\s+$//o; if ($dynamic) { $value = '\"' . $v . '\"'; } else { $value = '"' . $v . '"'; } if (length($value) > 2048) { &terror('edit_etxt_toolong2'); } &fix_oldtxt_rec();}elsif ($type eq 'WKS') { my @wks = (); unless ($value) { &terror('edit_emissing_value'); } $v = &compress_ip($in{'value0'}); if (&valipaddr($v, $origin, 0, 0, 0, 1)) { $in{'value0'} = $v; } else { &terror('edit_eip', $in{'value0'}); } unless ($in{'value2'}) { &terror('edit_ewks'); } $value = $in{'value0'} . ' ' . $in{'value1'} . ' ('; # # Because this is a multi-line record we must add the comment in now, # on the first line, and then prevent it being added on the last line. # if ($in{'comment'}) { $value .= "\t;" . $in{'comment'}; $in{'comment'} = ''; } @wks = split(/\n+|\s+/, $in{'value2'}); foreach $z (@wks) { unless ($z =~ /^[a-z][-\w]*\w$/io) { &terror('edit_ebadserv', $z); } $value .= "\n\t\t\t\t\t" . $z; } $value .= ' )';}elsif ($type eq 'RP') { if ($in{'value0'} && $in{'value0'} ne '.') { unless (&valemail($in{'value0'})) { &terror('edit_eemail', $in{'value0'}); } } else { $in{'value0'} = '.'; } if ($in{'value1'} && $in{'value1'} ne '.') { $value = &convert_fqdn(1, $in{'value1'}, $origin, 1); if ($value =~ /(\.(in-addr|ip6)\.arpa\.)$/o) { if ($2 eq 'in-addr') { $value = &compress_ip(&arpa_to_ip($value)); $in{'value1'} = &ip_to_arpa($value); } else { $value = &expand_ip6(&ip6arpa_to_net($value)); $in{'value1'} = &net_to_ip6arpa($value); } unless (&valipaddr($value, $1, 0, 0, 1, -1)) { &terror('edit_etxt', $value); } } elsif (&valdnsname($value, 0, $origin)) { $in{'value1'} = $value; } else { &terror('edit_etxt', $in{'value1'}); } } else { $in{'value1'} = '.'; } $value = &email_to_dotted($in{'value0'}, $origin) . ' ' . $in{'value1'};}elsif ($type eq 'LOC') { unless ($value =~ /\S/o) { &terror('edit_eloc'); }}elsif ($type eq 'SRV') { &trim($in{'serv'}); unless ($in{'serv'}) { &terror('edit_esrv_missing'); } elsif ($in{'serv'} =~ /[^-\w]/o || $in{'serv'} !~ /[a-z]/io) { &terror('edit_esrv', $in{'serv'}); } else { $in{'serv'} =~ s/^_//o; } if ($in{'proto'} =~ /[^-\w]/o || $in{'proto'} !~ /[a-z]/io) { &terror('edit_srv_proto', $in{'proto'}); } else { $in{'proto'} =~ s/^_//o; } unless ($in{'value0'}) { &terror('edit_eopt_missing'); } elsif ($in{'value0'} =~ /\D/o) { &terror('edit_epri', $in{'value0'}); } unless ($in{'value1'}) { &terror('edit_eopt_missing'); } elsif ($in{'value1'} =~ /\D/o) { &terror('edit_eweight', $in{'value1'}); } unless ($in{'value2'}) { &terror('edit_eopt_missing'); } elsif ($in{'value2'} =~ /\D/o) { &terror('edit_eport', $in{'value2'}); } unless ($in{'value3'}) { &terror('edit_etarget_missing'); } $in{'value3'} = &convert_fqdn(1, $in{'value3'}, $origin, 1); if (&valdnsname($in{'value3'}, 0, $origin)) { $value = join(' ', $in{'value0'}, $in{'value1'}, $in{'value2'}, $in{'value3'}); } else { &terror('edit_etarget', $in{'value3'}); } $name = join('.', '_' . $in{'serv'}, '_' . $in{'proto'}, $name);}elsif ($type eq 'KEY') { unless ($in{'value0'}) { &terror('edit_eflags_missing'); } elsif ($in{'value0'} !~ /^(\d+|0x[\da-f]+)$/io) { &terror('edit_eflags', $in{'value0'}); } unless ($in{'value1'}) { &terror('edit_eproto_missing'); } elsif ($in{'value1'} =~ /\D/o) { &terror('edit_eproto', $in{'value1'}); } unless ($in{'value2'}) { &terror('edit_ealg_missing'); } elsif ($in{'value2'} =~ /\D/o) { &terror('edit_ealg', $in{'value2'}); } $in{'value3'} =~ s/[\s\n]//go; unless ($in{'value3'} =~ /^[a-z\d\/+]+$/io) { &terror('edit_ekey'); } $value = join(' ', $in{'value0'}, $in{'value1'}, $in{'value2'}, $in{'value3'});}## Check that the new domain name is still in this zone.#if ($name !~ /$origin$/i) { if ($reverse) { $name = ($ipv4_zone) ? &arpa_to_ip($name) : &ip6arpa_to_net($name); &terror('edit_wrong_zone_rev', $name); } else { &terror('edit_wrong_zone_fwd', $name); }}## Check if we are creating or modifying a top-level or sub-domain name at all.#unless ($reverse) { if ($new) { unless (&check_tld($name, $origin, \%access, $in{'ztype'}, $type)) { &terror('edit_tld'); } unless (&check_sd($name, $origin, \%access, $in{'ztype'}, $type)) { &terror('edit_sd'); } } elsif ($oldname ne lc($name)) { unless (&check_tld($name, $origin, \%access, $in{'ztype'}, $type) && &check_tld($oldname, $origin, \%access, $in{'ztype'}, $type)) { &terror('edit_tld'); } unless (&check_sd($name, $origin, \%access, $in{'ztype'}, $type) && &check_sd($oldname, $origin, \%access, $in{'ztype'}, $type)) { &terror('edit_sd'); } }}## Check for any record name collision.#&check_name_collision();## Now we can add the new record or modify an existing one.#if ($new) { # # Add a new record. # &create_record($zone, $file, $name, $ttl, 'IN', $type, $value, $in{'comment'}); $rec = { 'name' => $name, 'ttl' => $ttl, 'class' => 'IN', 'type' => $type, 'values' => [ split(/\s+/, $value) ], 'comment' => $in{'comment'} };}else { # # Update an existing record. # &modify_record($zone, $file, $rec, $name, $ttl, 'IN', $type, $value, $in{'comment'});}## Now handle any new or existing forward or reverse records. Anything involving# a wildcard record is not touched.#if ($in{'rev'} && $name !~ /\*/o) { # # The user may create a new record which already has a reverse record. # In this case we do not want to create another reverse record, but to # update the existing one. To do this we simply set all the old reverse # record references to the new one. # if ($new) { $oconf = $revconf; $ofile = $revfile; $orec = $revrec; } # # If the old reverse record is not within the zone of the new one then # delete the old reverse record (if requested). # if ($oconf && $revconf && $oconf->{'value'} eq $revconf->{'value'}) { # # We need to trap the case when nothing has changed with a # record except perhaps its TTL value, but the user has # specified to create a new reverse record. We do NOT want to # do this since we would end up with two identical records # (except for their TTL). So to do this we simply look for the # old reverse record being the same as the new one and flag it. # $only_ttl_changed++ if ($orec && $revrec && $orec->{'fqdn'} eq $revrec->{'fqdn'} && $orec->{'values'}->[0] eq $revrec->{'values'}->[0]); # # If nothing has changed then the TTL values will also be the # same. In this case just zeroise revconf, and the code will # drop through any changes. # if ($only_ttl_changed && ($ttl == $revrec->{'ttl'} || ($ttl == 0 && ! defined($revrec->{'ttl'})))) { $revconf = 0; } else { $revrec = $orec; # We don't need orec itself anymore. } } else { &delete_rev_rec() if ($oconf && $in{'rev'} == 2); } # # At this point the old reverse record may have been deleted, and so we # only need to update the new reverse record. This is also the case for # new records. Or both the old and new reverse records are within the # same zone file, and so we need to update the old record. This will
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -