Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

some more changes appear to be necessary for api v1 compatibility #73

Closed
ZaphodB opened this issue Jan 8, 2016 · 14 comments · Fixed by #94
Closed

some more changes appear to be necessary for api v1 compatibility #73

ZaphodB opened this issue Jan 8, 2016 · 14 comments · Fixed by #94
Assignees
Milestone

Comments

@ZaphodB
Copy link

ZaphodB commented Jan 8, 2016

I was only able to restore function with api v1 doing the following but i'm sure there is a cleaner way to get there, so this is more a note that there seem to be some issues and not a suggestion to make use of the changes below. ;-)

--- a/zones.php
+++ b/zones.php
@@ -13,7 +13,15 @@ if (!is_csrf_safe()) {
 function api_request($path, $opts = null, $type = null) {
     global $apiproto, $apisslverify, $apisid, $apiuser, $apipass, $apiip, $apiport, $authmethod, $apipath;

-    $url = "$apiproto://$apiip:$apiport${apipath}${path}";
+    syslog(LOG_INFO, "path: " . $path);
+
+    if(preg_match("/^api\/v1/", $path)) {
+       $url = "$apiproto://$apiip:$apiport/${path}";
+       syslog(LOG_INFO, "preg url: " . $url);
+    } else {
+       $url = "$apiproto://$apiip:$apiport${apipath}${path}";
+       syslog(LOG_INFO, "url: " . $url);
+    }

     if ($authmethod == "auto") {
         $ad = curl_init();
@@ -140,12 +148,12 @@ function make_record($zone, $input) {

     if ('' == $name) {
         $name = $zone['name'];
-    } elseif (string_ends_with($name, '.')) {
-        # "absolute" name, shouldn't append zone[name] - but check.
-        $name = substr($name, 0, -1);
-        if (!string_ends_with($name, $zone['name'])) {
-            jtable_respond(null, 'error', "Name $name not in zone ".$zone['name']);
-        }
+    #} elseif (string_ends_with($name, '.')) {
+    #    # "absolute" name, shouldn't append zone[name] - but check.
+    #    $name = substr($name, 0, -1);
+    #    if (!string_ends_with($name, $zone['name'])) {
+    #        jtable_respond(null, 'error', "Name $name not in zone ".$zone['name']);
+    #    }
     } else if (!string_ends_with($name, $zone['name'])) {
         $name = $name . '.' . $zone['name'];
     }
@tuxis-ie
Copy link
Owner

I don't get the $url part. https://github.com/tuxis-ie/nsedit/blob/master/includes/misc.inc.php#L54 should set $apipath if needed.

@Stary2001
Copy link

with APIv1, the zoneurl returned by powerdns looks like "api/v1/zone/path", this patch fixes it by not including $apipath if the path already starts with "api/v1", the problem before was the API path was being added twice: once by powerdns, once by us. Possibly a cleaner fix would be to fix zoneurl when we get it either in the list action or in get_all_zones.

@celevra
Copy link

celevra commented Feb 16, 2016

the patch worked for me until there is a real fix, thank you!

@thekoma
Copy link

thekoma commented Feb 26, 2016

More and more changes are coming on the 4.0 (alpha 2 has added new features)

@celevra
Copy link

celevra commented Mar 2, 2016

jep, i've updated today and now nsedit can't fetch my records anymore

@tuxis-ie
Copy link
Owner

tuxis-ie commented Mar 2, 2016

You've updated what?

@celevra
Copy link

celevra commented Mar 2, 2016

pdns
ns html # dpkg -l | grep pdns
ii pdns-backend-mysql 0.0.781gfbb356b-1pdns.trusty amd64 generic MySQL backend for PowerDNS
ii pdns-server 0.0.781gfbb356b-1pdns.trusty amd64 extremely powerful and versatile nameserver

@tuxis-ie
Copy link
Owner

tuxis-ie commented Mar 2, 2016

Yes. Well, as long as pdns has not completely finished their API, I'm not in the mood to adjust nsedit for it. e.g., PowerDNS/pdns#3253 is open and that's something I would really like to see. If anyone is willing to fix this, please send a PR. But keep in mind that stable pdns should still work..

@HLFH
Copy link

HLFH commented Mar 2, 2016

In the meantime before the final release of PowerDNS 4.0, we could use pdnsutil in CLI.

@tuxis-ie
Copy link
Owner

tuxis-ie commented Mar 2, 2016

@zeha has just created PowerDNS/pdns#3495 which should make this pretty easy. I'll track that PR and make sure nsedit supports it ASAP. (Feel free to write a PR to implement this).

@petzsch
Copy link

petzsch commented Apr 27, 2016

just wanted to note that alpha2 is included in ubuntu 16.04. The patch above got rid of some 404 api errors when editing zones. But trying to add an A Record, I still get:
API Error 422: Key 'ttl' not an Integer or not present

Any help with this would be appreciated.

@julian7
Copy link

julian7 commented Jun 10, 2016

It looks like there are a lot of API changes.

  • listrecord: the JSON response have "rrsets" instead of "records". However, now we have multiple contents for the same record, in an array in "records".
  • createrecord: "ttl" also has to be put to the response.

Certainly all of the methods might require some changes.

@tuxis-ie
Copy link
Owner

Yes. I`m planning to create a 2.0 branche to fix compatibility with the new pdns api. Help would be much appreciated

@tuxis-ie
Copy link
Owner

tuxis-ie commented Aug 4, 2016

Working on this, nearing completion.

I'm expection to release NSEdit 1.0 tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants