- Timestamp:
- 01/04/13 17:19:57 (12 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cgi-bin/IPDB.pm
r579 r582 17 17 use Net::SMTP; 18 18 use NetAddr::IP qw(:lower Compact ); 19 use Frontier::Client; 19 20 use POSIX; 20 21 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); … … 87 88 our $syslog_facility = 'local2'; 88 89 90 our $rpc_url = ''; 91 89 92 # Let's initialize the globals. 90 93 ## IPDB::initIPDBGlobals() … … 214 217 my $dbh = shift; 215 218 my $cidr = new NetAddr::IP shift; 219 my %args = @_; 220 221 $args{vrf} = '' if !$args{vrf}; 222 $args{rdns} = '' if !$args{rdns}; 223 $args{defloc} = '' if !$args{defloc}; 224 $args{rwhois} = 'n' if !$args{rwhois}; # fail "safe", sort of. 225 $args{rwhois} = 'n' if $args{rwhois} ne 'n' and $args{rwhois} ne 'y'; 216 226 217 227 # Allow transactions, and raise an exception on errors so we can catch it later. … … 228 238 ##fixme: rwhois should be globally-flagable somewhere, much like a number of other things 229 239 ## maybe a db table called "config"? 230 $dbh->do("INSERT INTO masterblocks (cidr,rwhois ) VALUES (?,?)", undef, ($cidr,'y') );240 $dbh->do("INSERT INTO masterblocks (cidr,rwhois,vrf,rdns) VALUES (?,?,?,?)", undef, ($cidr, 'y', $args{vrf}, $args{rdns}) ); 231 241 232 242 # Unrouted blocks aren't associated with a city (yet). We don't rely on this 233 243 # elsewhere though; legacy data may have traps and pitfalls in it to break this. 234 244 # Thus the "routed" flag. 235 $dbh->do("INSERT INTO freeblocks (cidr, maskbits,city,routed,parent,rdepth) VALUES (?,?,?,?,?,?)", undef,236 ($cidr, $cidr->masklen, '<NULL>', 'm', $cidr, 1) );245 $dbh->do("INSERT INTO freeblocks (cidr,city,routed,parent,rdepth,vrf) VALUES (?,?,?,?,?,?)", undef, 246 ($cidr, '<NULL>', 'm', $cidr, 1, $args{vrf}) ); 237 247 238 248 # If we get here, everything is happy. Commit changes. … … 278 288 # freeblocks 279 289 $sth = $dbh->prepare("DELETE FROM freeblocks WHERE cidr <<= ?"); 280 my $sth2 = $dbh->prepare("INSERT INTO freeblocks (cidr, maskbits,city,routed,parent,rdepth)".281 " VALUES (?, ?,'<NULL>','m',?,1)");290 my $sth2 = $dbh->prepare("INSERT INTO freeblocks (cidr,city,routed,parent,rdepth,vrf)". 291 " VALUES (?,'<NULL>','m',?,1,?)"); 282 292 foreach my $newblock (@blocklist) { 283 293 $sth->execute($newblock); 284 $sth2->execute($newblock, $ newblock->masklen, $cidr);294 $sth2->execute($newblock, $cidr, $args{vrf}); 285 295 } 286 296 … … 291 301 # master 292 302 $dbh->do("DELETE FROM masterblocks WHERE cidr <<= ?", undef, ($cidr) ); 293 $dbh->do("INSERT INTO masterblocks (cidr,rwhois ) VALUES (?,?)", undef, ($cidr, 'y') );303 $dbh->do("INSERT INTO masterblocks (cidr,rwhois,vrf,rdns) VALUES (?,?,?,?)", undef, ($cidr, 'y', $args{vrf}, $args{rdns}) ); 294 304 295 305 # *whew* If we got here, we likely suceeded. … … 303 313 return ('FAIL',$msg); 304 314 } else { 315 316 # Only attempt rDNS if the IPDB side succeeded 317 if ($rpc_url) { 318 # Make an object to represent the XML-RPC server. 319 my $server = Frontier::Client->new(url => $rpc_url, debug => 0); 320 my $result; 321 322 # Note *not* splitting reverse zones negates any benefit from caching the exported data. 323 # IPv6 address space is far too large to split usefully, and in any case (also due to 324 # the large address space) doesn't support the iterated template records v4 zones do 325 # that causes the bulk of the slowdown that needs the cache anyway. 326 327 my @zonelist; 328 # allow splitting reverse zones to be disabled, maybe, someday 329 #if ($splitrevzones && !$cidr->{isv6}) { 330 if (1 && !$cidr->{isv6}) { 331 my $splitpoint = ($cidr->masklen <= 16 ? 16 : 24); # hack pthui 332 @zonelist = $cidr->split($splitpoint); 333 } else { 334 @zonelist = ($cidr); 335 } 336 my @fails; 337 ##fixme: remove hardcoding where possible 338 foreach my $subzone (@zonelist) { 339 my %rpcargs = ( 340 rpcuser => $args{user}, 341 rpcsystem => 'ipdb', 342 revzone => "$subzone", 343 revpatt => $args{rdns}, 344 defloc => $args{defloc}, 345 group => 1, # not sure how these two could sanely be exposed, tbh... 346 state => 1, # could make them globally configurable maybe 347 ); 348 eval { 349 $result = $server->call('dnsdb.addRDNS', %rpcargs); 350 }; 351 if ($@) { 352 my $msg = $@; 353 $msg =~ s/Fault returned from XML RPC Server, fault code 4: error executing RPC `dnsdb.addRDNS'\.\s//; 354 push @fails, ("$subzone" => $msg); 355 } 356 } 357 if (@fails) { 358 return ('WARN',"Warning(s) adding $cidr to reverse DNS:\n".join("\n", @fails)); 359 } 360 } 305 361 return ('OK','OK'); 306 362 } -
trunk/cgi-bin/MyIPDB.pm
r517 r582 51 51 #$IPDB::syslog_facility = 'daemon'; 52 52 53 # RPC URL for pushing DNS changes out. Blank by default; disables RPC calls for DNS changes when blank. 54 #$IPDB::rpc_url = 'http://dnsadmin.example.com/dns-rpc.cgi'; 53 55 54 56 ## connectDB_My() -
trunk/cgi-bin/main.cgi
r577 r582 17 17 use POSIX qw(ceil); 18 18 use NetAddr::IP; 19 use Frontier::Client; 19 20 20 21 use Sys::Syslog; … … 100 101 $aclerr = 'addmaster'; 101 102 } 103 104 # Retrieve the list of DNS locations if we've got a place to grab them from 105 if ($IPDB::rpc_url) { 106 # Make an object to represent the XML-RPC server. 107 my $server = Frontier::Client->new(url => $IPDB::rpc_url, debug => 0); 108 my $result; 109 110 my %rpcargs = ( 111 rpcuser => $authuser, 112 rpcsystem => 'ipdb', 113 group => 1, # bleh 114 defloc => '', 115 ); 116 $result = $server->call('dnsdb.getLocDropdown', %rpcargs); 117 $page->param(loclist => $result); 118 } 119 102 120 } elsif ($webvar{action} eq 'newmaster') { 103 121 … … 108 126 $page->param(cidr => "$cidr"); 109 127 110 my ($code,$msg) = addMaster($ip_dbh, $webvar{cidr}); 128 my ($code,$msg) = addMaster($ip_dbh, $webvar{cidr}, (vrf => $webvar{vrf}, rdns => $webvar{rdns}, 129 rwhois => $webvar{rwhois}, defloc => $webvar{loc}, user => $authuser) ); 111 130 112 131 if ($code eq 'FAIL') { … … 114 133 $page->param(err => $msg); 115 134 } else { 135 if ($code eq 'WARN') { 136 $msg =~ s/\n\n/<br>\n/g; 137 $msg =~ s/:\n/:<br>\n/g; 138 $page->param(warn => $msg); 139 } 116 140 syslog "info", "$authuser added master block $webvar{cidr}"; 117 141 } -
trunk/templates/addmaster.tmpl
r517 r582 9 9 </tr> 10 10 <tr class="row1"> 11 <td>Default VRF:</td> 12 <td><input type="text" name="vrf"></td> 13 </tr> 14 <tr class="row0"> 15 <td>Default rDNS pattern:</td> 16 <td><input type="text" name="rdns"><input type="button" value=" ? " onclick="helpRDNS()" class="regular"></td> 17 </tr> 18 <tr class="row1"> 19 <TMPL_IF loclist> 20 <td>Default DNS scope:</td> 21 <td> 22 <select name="loc"> 23 <TMPL_LOOP loclist> 24 <option value="<TMPL_VAR NAME=loc>"<TMPL_IF selected> selected</TMPL_IF>><TMPL_VAR NAME=locname></option> 25 </TMPL_LOOP> 26 </select> 27 </td> 28 </tr> 29 <tr class="row0"> 30 <TMPL_ELSE> 31 </TMPL_IF> 11 32 <td class="center" colspan="2"><input type="submit" value=" Assign "></td> 12 33 </tr> -
trunk/templates/newmaster.tmpl
r517 r582 6 6 <TMPL_ELSE> 7 7 <div class="heading">Success!</div> 8 <TMPL_IF warn> 9 <div class="warning"><TMPL_VAR NAME=warn></div> 10 </TMPL_IF> 8 11 </TMPL_IF> 9 12 </div> -
trunk/templates/widgets.js
r517 r582 14 14 window.open(webPath() + "help.html", "help_window", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=700,height=400") 15 15 } 16 function openTables() {17 window.open(webPath() + "tables.html", "subnet_tables", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=600,height=250")18 }19 16 function helpAllocTypes() { 20 17 window.open(webPath() + "alloctypes.html", "alloc_window", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=750,height=550") 18 } 19 function helpRDNS() { 20 window.open(webPath() + "rDNS.html", "rdns_window", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=850,height=450") 21 21 } 22 22 function popNotes(page) {
Note:
See TracChangeset
for help on using the changeset viewer.