mirror of
https://github.com/tuxis-ie/nsedit.git
synced 2025-04-19 20:09:14 +03:00
Merge pull request #63 from tuxis-ie/allow-pdns-v4
Allow pdns 4.0 users to use nsedit as well, by allowing to set the AP…
This commit is contained in:
commit
8f2290019e
4 changed files with 24 additions and 4 deletions
8
doc/apiconf.txt
Normal file
8
doc/apiconf.txt
Normal file
|
@ -0,0 +1,8 @@
|
|||
There are several values in config.inc.php that you MUST set for the API to work.
|
||||
|
||||
$apipass : The API password or API Authentication Key
|
||||
$apiip : The IP on which the API is reachable
|
||||
$apiport : The port on which the API is reachable. Default port is 8081
|
||||
$apivers : The version of the API to use. In pre-PDNS 4.0, the API was
|
||||
reachable via /. In 4.0, the path was changed to /api/v1. You do NOT set the path of the API, you set the version of the API. 0 is for pre 4.0, 1 is currently only used in 4.0.
|
||||
|
|
@ -4,6 +4,7 @@ $apiuser = ''; # The PowerDNS API username. Leave empty for authmethod
|
|||
$apipass = ''; # The PowerDNS API-user password or the PowerDNS-API key (see AUTHENTICATION)
|
||||
$apiip = ''; # The IP of the PowerDNS API
|
||||
$apiport = '8081'; # The port of the PowerDNS API
|
||||
$apivers = 0; # The version of the PowerDNS API. 0 == experimental, 1 = v1 (pdns 4.0)
|
||||
$apisid = 'localhost'; # PowerDNS's :server_id
|
||||
$apiproto = 'http'; # http | https
|
||||
$apisslverify = FALSE; # Verify SSL Certificate if using https for apiproto
|
||||
|
|
|
@ -4,8 +4,13 @@ include('config.inc.php');
|
|||
|
||||
$blocklogin = FALSE;
|
||||
|
||||
if ((!isset($apipass) or empty($apipass)) or (!isset($apiip) or empty($apiip)) or (!isset($apiport) or empty($apiport))) {
|
||||
$errormsg = "You need to configure your settings for the PowerDNS API";
|
||||
if ((!isset($apipass) or empty($apipass)) or (!isset($apiip) or empty($apiip)) or (!isset($apiport) or empty($apiport)) or (!isset($apivers) or empty($apivers)) {
|
||||
$errormsg = 'You need to configure your settings for the PowerDNS API. See <a href="doc/apiconf.txt">doc/apiconf.txt</a>';
|
||||
$blocklogin = TRUE;
|
||||
}
|
||||
|
||||
if (!preg_match('/^[01]$/', $apivers)) {
|
||||
$errormsg = "The value for \$apivers is incorrect your config";
|
||||
$blocklogin = TRUE;
|
||||
}
|
||||
|
||||
|
@ -41,6 +46,12 @@ if (isset($defaults['primaryns'])) {
|
|||
|
||||
/* No need to change stuf below */
|
||||
|
||||
if ($apivers == 0) {
|
||||
$apipath = "";
|
||||
} elseif ($apivers == 1) {
|
||||
$apipath = "/api/v1";
|
||||
}
|
||||
|
||||
if (function_exists('curl_init') === FALSE) {
|
||||
$errormsg = "You need PHP Curl to run nsedit";
|
||||
$blocklogin = TRUE;
|
||||
|
|
|
@ -11,9 +11,9 @@ if (!is_csrf_safe()) {
|
|||
}
|
||||
|
||||
function api_request($path, $opts = null, $type = null) {
|
||||
global $apiproto, $apisslverify, $apisid, $apiuser, $apipass, $apiip, $apiport, $authmethod;
|
||||
global $apiproto, $apisslverify, $apisid, $apiuser, $apipass, $apiip, $apiport, $authmethod, $apipath;
|
||||
|
||||
$url = "$apiproto://$apiip:$apiport${path}";
|
||||
$url = "$apiproto://$apiip:$apiport${apipath}${path}";
|
||||
|
||||
if ($authmethod == "auto") {
|
||||
$ad = curl_init();
|
||||
|
|
Loading…
Add table
Reference in a new issue