API adding nameserver

Acceleratic

Verified User
Joined
May 25, 2009
Messages
55
Hi all,

I’am busy with making a control panel for my clients. Working like a charm with the DirectAdmin API. Now i’am getting with DNS configuration trough the API. Going good so far, except for adding nameservers. I’am using the following query with the httpsocket.php class:

$sock->query('/CMD_API_DNS_CONTROL',
array(
"action" => "add",
"domain" => $domain,
"type" => $dns_type,
"name" => $dns_name,
"value" => $dns_value
));

It’s going well for all the records except nameservers. When adding a namseserver like: ns1.domain.com, it’s switching the value and name variables. When adding trough normal DiractAdmin interface, the variables are set right (didn’t expect less).

Is this normal behaviour? The name variable needs to be set as “ns1.domain.com” and the value variable as “domain.com.”.

Greetings
 
Hello,

This is normal behavior. The reason they're swapped is because the container class required an unique index, and the index for all NS records will be domain.com., which wouldn't be unique, thus you could only have 1 NS.

By swapping them, the values would be unique, thus you could have many. It is slightly confusing, but just the way it's programmed.

Of course, now our container classes do support multiple identical keys (eg, for A records), but to be backwards compatible with all API scripts that have been written to use this, we can't change them back now, thus they stay swapped.


Just an FYI, when debugging "what do I pass to the API with my script" type questions, run DA in debug mode with the "| grep string" option. Run it once with your browser while logged into DA, and again with your script. See what the differences are, and adjust the script to match the browser.
http://help.directadmin.com/item.php?id=293

John
 
Back
Top