mirror of
https://github.com/tuxis-ie/nsedit.git
synced 2025-04-19 20:09:14 +03:00
added initial https support
This commit is contained in:
parent
b0c35bde5e
commit
0b97e09bb7
2 changed files with 16 additions and 8 deletions
|
@ -5,8 +5,11 @@ $apipass = ''; # The PowerDNS API-user password or the PowerDNS-API key
|
|||
$apiip = ''; # The IP of the PowerDNS API
|
||||
$apiport = '8081'; # The port of the PowerDNS API
|
||||
$apisid = 'localhost'; # PowerDNS's :server_id
|
||||
$apiproto = 'http'; # http | https
|
||||
$apisslsverify = FALSE; # Verify SSL Certificate if using https for apiproto
|
||||
$allowzoneadd = FALSE; # Allow normal users to add zones
|
||||
|
||||
|
||||
### AUTHENTICATION ###
|
||||
# The first versions of the PowerDNS API used the standard webserver password
|
||||
# for authentication, newer versions use an X-API-Key mechanism. NSEdit tries
|
||||
|
|
|
@ -13,12 +13,17 @@ if (!is_csrf_safe()) {
|
|||
function api_request($path, $opts = null, $type = null) {
|
||||
global $apisid, $apiuser, $apipass, $apiip, $apiport, $authmethod;
|
||||
|
||||
$url = "http://$apiip:$apiport${path}";
|
||||
$url = "$apiproto://$apiip:$apiport${path}";
|
||||
|
||||
if ($authmethod == "auto") {
|
||||
$ad = curl_init();
|
||||
|
||||
if ( strcasecmp( $apiproto, 'https' ) == 0 ) {
|
||||
curl_setopt($ad, CURLOPT_SSL_VERIFYPEER, $apisslverify);
|
||||
}
|
||||
|
||||
curl_setopt($ad, CURLOPT_HTTPHEADER, array('X-API-Key: '.$apipass));
|
||||
curl_setopt($ad, CURLOPT_URL, "http://$apiip:$apiport/servers/localhost/statistics");
|
||||
curl_setopt($ad, CURLOPT_URL, "$apiproto://$apiip:$apiport/servers/localhost/statistics");
|
||||
curl_setopt($ad, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_exec($ad);
|
||||
if (curl_getinfo($ad, CURLINFO_HTTP_CODE) == 401) {
|
||||
|
|
Loading…
Add table
Reference in a new issue