- Timestamp:
- 11/11/09 17:55:32 (15 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r33 r34 30 30 &getSOA &getRecLine &getDomRecs 31 31 &addRec &updateRec &delRec 32 &domStatus 32 &domStatus &importAXFR 33 33 %typemap %reverse_typemap 34 34 ); … … 42 42 &getSOA &getRecLine &getDomRecs 43 43 &addRec &updateRec &delRec 44 &domStatus 44 &domStatus &importAXFR 45 45 %typemap %reverse_typemap 46 46 )] … … 824 824 ##fixme: add mode to delete&replace, merge+overwrite, merge new? 825 825 826 my $res = Net::DNS::Resolver->new; 827 $res->axfr_start($domain); 826 828 827 my $nrecs = 0; 829 828 my $flags = 0; 829 my $warnmsg; 830 830 831 831 # Allow transactions, and raise an exception on errors so we can catch it later. … … 834 834 local $dbh->{RaiseError} = 1; 835 835 836 my $dom_id; 837 836 838 eval { 837 839 # can't do this, can't nest transactions. sigh. … … 840 842 ##fixme: serial 841 843 my $sth = $dbh->prepare("INSERT INTO domains (domain,group_id,status) VALUES (?,?,?)"); 842 $sth->execute($domain,$group,$state); 844 $warnmsg = "trying lokido... (".$dbh->{AutoCommit}."), (".$dbh->{RaiseError}.")" if $domain eq 'waslokido.com'; 845 $sth->execute($domain,$group,$status); 843 846 844 847 # get domain id so we can do the records … … 846 849 $sth->execute; 847 850 ($dom_id) = $sth->fetchrow_array(); 851 $warnmsg .= " [domid $dom_id]"; 852 853 my $res = Net::DNS::Resolver->new; 854 unless ($res->axfr_start($domain)) { 855 $dbh->rollback; 856 die "Couldn't begin AXFR\n"; 857 } 858 859 #die "just started AXFR\n"; 848 860 849 861 while (my $rr = $res->axfr_next) { 862 $warnmsg = $rr->string; 850 863 my $type = $rr->type; 851 864 # nasty big ugly case-like thing here, since we have to do *some* different 852 865 # processing depending on the record. le sigh. 853 my $sql = "INSERT INTO records (domain_id,host,type, val,ttl";866 my $sql = "INSERT INTO records (domain_id,host,type,ttl,val"; 854 867 my $vallen = "?,?,?,?,?"; 855 my $host,$val; 868 # my $host = $rr->name; 869 # my $ttl = $rr->ttl; 870 # my $val; 856 871 857 872 ##work 858 # gnnnnnh. going to need to (rr->string) -> split -> <localvars> 859 my @vallist; 860 if ($type eq 'SOA') { 861 $host = $rr->mname.":".$rr->rname; 862 $val = $rr->refresh.":".$rr->retry.":".$rr->expire.":".$rr->minimum; 863 } 864 if ($type eq 'MX' || $type eq 'SRV') { 873 # gnnnnnh. going to need to (rr->string) -> split -> <localvars> ? 874 my @vallist = ($dom_id, $rr->name, $reverse_typemap{$type}, $rr->ttl); 875 876 # "Primary" types: 877 # A, NS, CNAME, SOA, PTR(warn in forward), MX, TXT, AAAA, SRV, A6(ob), SPF 878 # maybe KEY 879 880 if ($type eq 'A') { 881 push @vallist, $rr->address; 882 } elsif ($type eq 'NS') { 883 push @vallist, $rr->nsdname; 884 } elsif ($type eq 'CNAME') { 885 push @vallist, $rr->cname; 886 } elsif ($type eq 'SOA') { 887 $vallist[1] = $rr->mname.":".$rr->rname; 888 push @vallist, ($rr->refresh.":".$rr->retry.":".$rr->expire.":".$rr->minimum); 889 } elsif ($type eq 'PTR') { 890 # hmm. PTR records should not be in forward zones. 891 } elsif ($type eq 'MX') { 865 892 $sql .= ",distance"; 866 893 $vallen .= ",?"; 867 $sql .= ",weight,port" if $type eq 'SRV'; 868 $vallen .= ",?,?" if $type eq 'SRV'; 894 push @vallist, $rr->exchange; 895 push @vallist, $rr->preference; 896 } elsif ($type eq 'TXT') { 897 ##fixme: Net::DNS docs say this should be deprecated for rdatastr() or char_str_list(), 898 ## but don't really seem enthusiastic about it. 899 push @vallist, $rr->txtdata; 900 } elsif ($type eq 'SPF') { 901 ##fixme: and the same caveat here, since it is apparently a clone of ::TXT 902 push @vallist, $rr->txtdata; 903 } elsif ($type eq 'AAAA') { 904 push @vallist, $rr->address; 905 } elsif ($type eq 'SRV') { 906 $sql .= ",distance,weight,port" if $type eq 'SRV'; 907 $vallen .= ",?,?,?" if $type eq 'SRV'; 908 push @vallist, $rr->priority; 909 push @vallist, $rr->weight; 910 push @vallist, $rr->port; 911 } elsif ($type eq 'KEY') { 912 push @vallist, ($rr->flags.":".$rr->protocol.":".$rr->algorithm.":".$rr->key.":".$rr->keytag.":".$rr->privatekeyname); 869 913 } 870 $sth = $dbh->prepare($sql.") VALUES (".$vallen.")"); 871 $sth->execute(@vallist); 914 915 $warnmsg = $rr->string; 916 $dbh->rollback if $domain eq 'waslokido.com'; 917 die "first record: ".$rr->string."\n" if $domain eq 'waslokido.com'; 918 919 # BIND supports: 920 # A CNAME HINFO MB(ex) MD(ob) MF(ob) MG(ex) MINFO(ex) MR(ex) MX NS NULL 921 # PTR SOA TXT WKS AFSDB(ex) ISDN(ex) RP(ex) RT(ex) X25(ex) PX 922 # ... if one can ever find the right magic to format them correctly 923 924 # Net::DNS supports: 925 # RRSIG SIG NSAP NS NIMLOC NAPTR MX MR MINFO MG MB LOC ISDN IPSECKEY HINFO 926 # EID DNAME CNAME CERT APL AFSDB AAAA A DS NXT NSEC3PARAM NSEC3 NSEC KEY 927 # DNSKEY DLV X25 TXT TSIG TKEY SSHFP SRV SPF SOA RT RP PX PTR NULL APL::AplItem 928 929 # MX and SRV have known extras to stuff in. 930 if ($type eq 'MX') { 931 push @vallist, $rr->preference; 932 } 933 if ($type eq 'SRV') { 934 } 935 936 $sth = $dbh->prepare($sql.") VALUES (".$vallen.")"); 937 $sth->execute(@vallist) or die "failed to insert ".$rr->string.": ".$sth->errstr."\n" if $sth->err; 938 939 if ($type eq 'SOA') { 940 } 941 942 $dbh->rollback; 943 #die "die.die.die!\n"; 872 944 873 945 #print $rr->rdata."\n"; … … 878 950 my $msg = $@; 879 951 eval { $dbh->rollback; }; 880 return ('FAIL',$msg );952 return ('FAIL',$msg." $warnmsg"); 881 953 } else { 954 return ('WARN', "OOOK! Ooooook. Ook. ($warnmsg)") if $domain eq 'deepnet.cx'; 955 return ('WARN', "Funky Things Happened: $warnmsg") if $domain eq 'waslokido.com'; 882 956 return ('OK',"ook"); 883 957 } 884 958 885 return ('WARN'," 959 return ('WARN',"OOOK!"); 886 960 } # end importAXFR() 887 961 -
trunk/dns.cgi
r33 r34 615 615 my $rnum = 0; 616 616 foreach my $domain (@domlist) { 617 my %row; 618 my ($code,$msg) = importAXFR($dbh, $webvar{ifrom}, $domain, $webvar{group}, 619 $webvar{domstatus}, $webvar{rwsoa}, $webvar{rwns}); 620 $row{domok} = 1 if $code eq 'OK'; 621 $row{domwarn} = $msg if $code eq 'WARN'; 622 $row{domerr} = $msg if $code eq 'FAIL'; 623 push @debugbits, "$domain: $code<br>\n"; 617 624 # do stuff! DNSDB::importAXFR($webvar{ifrom}, $webvar{rwsoa}, $webvar{rwns}, $domain, <flags>) 618 my %row;619 625 $row{domain} = $domain; 620 626 # $row{row} = $rnum++; 621 if ($domain eq 'deepnet.cx' || $domain eq 'wh-int') {622 $row{domok} = 0; $row{domerr} = "foo! hahahaha!";623 } elsif ($domain eq 'waslokido.com') {624 $row{domwarn} = 0; $row{domwarn} = "foo! hahahaha!";625 } else {626 $row{domok} = 1;627 }628 627 push @results, \%row; 629 628 } -
trunk/templates/axfr.tmpl
r33 r34 4 4 5 5 <td align="center"> 6 7 <TMPL_IF errmsg><div class="errmsg">Error: <TMPL_VARNAME=errmsg></div></TMPL_IF>8 6 9 7 <form action="dns.cgi" method="POST"> … … 13 11 14 12 <table> 13 <TMPL_IF errmsg><tr><td class="errhead" colspan=2>Error: <TMPL_VARNAME=errmsg></td></tr></TMPL_IF> 15 14 <tr class="tableheader"><td align="center" colspan=2>Import domains via AXFR</td></tr> 16 15 <tr class="datalinelight"> -
trunk/templates/dns.css
r33 r34 69 69 td.defaults { 70 70 background-color: #DDDDDD; 71 } 72 td.errhead { 73 font-weight: bold; 74 font-size: 110%; 75 color: red; 76 background-color: #404040; 77 text-align: center; 78 padding: 3px; 79 border: solid 2px #FF0000; 71 80 } 72 81 td.err {
Note:
See TracChangeset
for help on using the changeset viewer.