Changeset 354
- Timestamp:
- 06/29/12 12:49:20 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tiny-import.pl
r353 r354 123 123 if ($rec =~ /^=/) { 124 124 $cnt{APTR}++; 125 if ($rec !~ /^=(?:\*|\\052)?[a-z0-9\._-]+:[\d\.]+:\d*/i) { 126 print "bad A+PTR $rec\n"; 127 return; 128 #=sud-rr-iGi0-1_sud-gw1-iGi4-2.vianet.ca::10.10.10.13:900::in 129 } 125 126 ##fixme: do checks like this for all types 127 if ($rec !~ /^=(?:\*|\\052)?[a-z0-9\._-]+:[\d\.]+:\d*/i) { 128 print "bad A+PTR $rec\n"; 129 return; 130 } 130 131 my ($host,$ip,$ttl,$stamp,$loc) = split /:/, $rec, 5; 131 132 $host =~ s/^=//; … … 146 147 } elsif ($rec =~ /^C/) { 147 148 $cnt{CNAME}++; 149 148 150 my ($host,$targ,$ttl,$stamp,$loc) = split /:/, $rec, 5; 149 151 $host =~ s/^C//; … … 176 178 } elsif ($rec =~ /^\&/) { 177 179 $cnt{NS}++; 180 178 181 } elsif ($rec =~ /^\^/) { 179 182 $cnt{PTR}++; 183 180 184 } elsif ($rec =~ /^\+/) { 181 185 $cnt{A}++; 186 182 187 } elsif ($rec =~ /^Z/) { 183 188 $cnt{SOA}++; 184 #Z128.91.209.in-addr.arpa:ns1.vianet.ca.:dnsadmin.vianet.ca.::1209600:1209600:900:900:900: 189 185 190 my ($zone,$master,$contact,$serial,$refresh,$retry,$expire,$minttl,$ttl,$stamp,$loc) = split /:/, $rec, 11; 186 191 $zone =~ s/^Z//; … … 202 207 $recsth->execute($domid, 0, "$contact:$master", 6, "$refresh:$retry:$expire:$minttl", 0, 0, 0, $ttl); 203 208 } 204 return; # since we don't use the "standard" record-add call at the bottom 209 205 210 } elsif ($rec =~ /^\@/) { 206 211 $cnt{MX}++; 212 207 213 } elsif ($rec =~ /^'/) { 208 214 $cnt{TXT}++; … … 225 231 } elsif ($rec =~ /^\./) { 226 232 $cnt{NSASOA}++; 233 227 234 my ($fqdn, $ip, $ns, $ttl, $stamp, $loc) = split /:/, $rec, 6; 228 235 $fqdn =~ s/^\.//; … … 254 261 # Even the auto-nameserver-fqdn comes out... ugly. 255 262 256 ##work257 263 } else { 258 264 my ($domid) = $dbh->selectrow_array("SELECT domain_id FROM domains WHERE lower(domain) = lower(?)", … … 271 277 } elsif ($rec =~ /^\%/) { 272 278 $cnt{VIEWS}++; 279 273 280 } elsif ($rec =~ /^:/) { 274 281 $cnt{NCUST}++; … … 276 283 # recognition and handling for the core common types, this must deal with the leftovers. 277 284 # :fqdn:type:rdata:ttl:time:loc 278 #:mx2.sys.vianet.ca:44:\001\001\215\272\152\152\123\142\120\071\320\106\160\364\107\372\153\116\036\111\247\135:900::sys 279 #:_sipfederationtls._tcp.ncstechnology.com:33:\000\144\000\001\023\305\006sipfed\006online\004lync\003com\000:3600:: 280 281 my (undef, $fqdn, $type, $rdata, $ttl, $time, $loc) = split /:/, $rec; 282 283 if ($type == 33) { 284 # SRV 285 my ($prio, $weight, $port, $target) = (0,0,0,0); 286 287 my @tmp = _byteparse(\$rdata, 2); 288 $prio = $tmp[0] * 256 + $tmp[1]; 289 @tmp = _byteparse(\$rdata, 2); 290 $weight = $tmp[0] * 256 + $tmp[1]; 291 @tmp = _byteparse(\$rdata, 2); 292 $port = $tmp[0] * 256 + $tmp[1]; 293 294 $rdata =~ s/\\\d{3}/./g; 295 ($target) = ($rdata =~ /^\.(.+)\.$/); 285 286 my (undef, $fqdn, $type, $rdata, $ttl, $stamp, $loc) = split /:/, $rec, 7; 287 $ttl = 0 if !$ttl; 288 $stamp = '' if !$stamp; 289 $loc = '' if !$loc; 290 $loc = '' if $loc =~ /^:+$/; 291 292 if ($type == 33) { 293 # SRV 294 my ($prio, $weight, $port, $target) = (0,0,0,0); 295 296 my @tmp = _byteparse(\$rdata, 2); 297 $prio = $tmp[0] * 256 + $tmp[1]; 298 @tmp = _byteparse(\$rdata, 2); 299 $weight = $tmp[0] * 256 + $tmp[1]; 300 @tmp = _byteparse(\$rdata, 2); 301 $port = $tmp[0] * 256 + $tmp[1]; 302 303 $rdata =~ s/\\\d{3}/./g; 304 ($target) = ($rdata =~ /^\.(.+)\.$/); 296 305 # hmm. the above *should* work, but What If(TM) we have ASCII-range bytes 297 306 # representing the target's fqdn part length(s)? axfr-get doesn't seem to, … … 306 315 # } 307 316 308 my $domid = DNSDB::_hostparent($dbh, $fqdn); 309 if ($domid) { 310 $recsth->execute($domid, 0, $fqdn, $type, $target, $prio, $weight, $port, $ttl) if $domid; 311 } else { 312 push @deferred, $rec unless $nodefer; 313 } 314 315 } elsif ($type == 28) { 316 # AAAA 317 318 my @v6; 319 320 for (my $i=0; $i < 8; $i++) { 321 my @tmp = _byteparse(\$rdata, 2); 322 push @v6, sprintf("%0.4x", $tmp[0] * 256 + $tmp[1]); 323 } 324 my $val = NetAddr::IP->new(join(':', @v6)); 325 326 my $domid = DNSDB::_hostparent($dbh, $fqdn); 327 if ($domid) { 328 $recsth->execute($domid, 0, $fqdn, $type, $val->addr, 0, 0, 0, $ttl) if $domid; 329 } else { 330 push @deferred, $rec unless $nodefer; 331 } 332 333 } else { 334 # ... uhhh, dunno 335 } 317 my $domid = DNSDB::_hostparent($dbh, $fqdn); 318 if ($domid) { 319 $recsth->execute($domid, 0, $fqdn, 33, $target, $prio, $weight, $port, $ttl) if $domid; 320 } else { 321 push @deferred, $rec unless $nodefer; 322 } 323 324 } elsif ($type == 28) { 325 # AAAA 326 my @v6; 327 328 for (my $i=0; $i < 8; $i++) { 329 my @tmp = _byteparse(\$rdata, 2); 330 push @v6, sprintf("%0.4x", $tmp[0] * 256 + $tmp[1]); 331 } 332 my $val = NetAddr::IP->new(join(':', @v6)); 333 334 my ($rdns) = $dbh->selectrow_array("SELECT rdns_id FROM revzones WHERE revnet >> ?", undef, ("$val")); 335 if ($rdns) { 336 $recsth->execute(0, $rdns, $fqdn, 28, $val->addr, 0, 0, 0, $ttl); 337 } else { 338 push @deferred, $rec unless $nodefer; 339 } 340 341 } else { 342 # ... uhhh, dunno 343 } 336 344 337 345 } else { 338 346 $cnt{other}++; 339 print " $_\n";347 print " $_\n"; 340 348 } 341 349 }
Note:
See TracChangeset
for help on using the changeset viewer.