mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2025-12-10 06:06:09 +08:00
Fixes #3854 Unfortunately I couldn't run the integrationTests properly as INWX doesn't seem to have properly updated their sandbox environment (it still presents `int` instead of `string` like production). Hence, the tests do fail. I don't want to run this against my own production account, to be frank. See: ```shell $ curl -X POST https://api.ote.domrobot.com/xmlrpc/ -H "Content-Type: application/xml" -d '<?xml version="1.0" encoding="UTF-8"?> <methodCall> <methodName>nameserver.info</methodName> <params> <param> <value> <struct> <member> <name>user</name> <value> <string>[USER]</string> </value> </member> <member> <name>lang</name> <value> <string>en</string> </value> </member> <member> <name>pass</name> <value> <string>[PASS]</string> </value> </member> <member> <name>domain</name> <value> <string>[DOMAIN]</string> </value> </member> </struct> </value> </param> </params> </methodCall>' | xmllint --format - | grep -iE "id|roId" -C3 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 3968 0 2971 100 997 13375 4488 --:--:-- --:--:-- --:--:-- 17954 <value> <struct> <member> <name>roId</name> <value> <int>9677</int> </value> -- <value> <struct> <member> <name>id</name> <value> <int>118057</int> </value> -- <value> <struct> <member> <name>id</name> <value> <int>118060</int> </value> -- <value> <struct> <member> <name>id</name> <value> <int>79610</int> </value> -- <value> <struct> <member> <name>id</name> <value> <int>77243</int> </value> -- </value> </member> <member> <name>svTRID</name> <value> <string>20251127--ote</string> </value> ``` Hence, only done manualy tests via `dnscontrol push --domains <example.com>`: (tested create, delete and modify) ```text CONCURRENTLY checking for 0 zone(s) SERIALLY checking for 1 zone(s) Serially checking for zone: "example.tld" CONCURRENTLY gathering records of 0 zone(s) SERIALLY gathering records of 1 zone(s) Serially Gathering: "example.tld" ******************** Domain: example.tld 3 corrections (PK-INWX) #1: - DELETE _test1.example.tld TXT "123" ttl=43200 SUCCESS! #2: ± MODIFY _test2.example.tld TXT ("1234" ttl=43200) -> ("12345" ttl=43200) SUCCESS! #3: + CREATE _test4.example.tld TXT "123" ttl=43200 SUCCESS! Done. 3 corrections. ```
48 lines
1.4 KiB
Go
48 lines
1.4 KiB
Go
package inwx
|
|
|
|
import (
|
|
"golang.org/x/net/idna"
|
|
)
|
|
|
|
const (
|
|
// https://www.inwx.com/en/help/apidoc/f/ch03.html#type.dnssecdomainstatus
|
|
// claims status values can be 'DELETE_ALL', 'MANUAL', 'UPDATE', but
|
|
// testing shows 'AUTO' is what to expect if the domain has automatic
|
|
// DNSSEC enabled.
|
|
|
|
// AutoDNSSECStatus is the status for DNSSEC enabled with automatic management
|
|
AutoDNSSECStatus = "AUTO"
|
|
// ManualDNSSECStatus is the status for DNSSEC enabled with manual management
|
|
ManualDNSSECStatus = "MANUAL"
|
|
)
|
|
|
|
// DNSSecStatus returns domain dnssec status
|
|
func (api *inwxAPI) DNSSecStatus(domain string) (string, error) {
|
|
resp, err := api.client.Dnssec.Info([]string{domain})
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
// domain has no DNSSEC configuration
|
|
if len(resp.Data) == 0 {
|
|
return "", nil
|
|
}
|
|
return resp.Data[0].DNSSecStatus, nil
|
|
}
|
|
|
|
// enableAutoDNSSEC enables automatic management of DNSSEC
|
|
func (api *inwxAPI) enableAutoDNSSEC(domain string) error {
|
|
// if the domain is IDN, it must be in Unicode - ACE encoding is not supported
|
|
// in the INWX dnssec.enablednssec endpoint
|
|
domain, err := idna.ToUnicode(domain)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
err = api.client.Dnssec.Enable(domain)
|
|
return err
|
|
}
|
|
|
|
// disableAutoDNSSEC disables automatic management of DNSSEC
|
|
func (api *inwxAPI) disableAutoDNSSEC(domain string) error {
|
|
err := api.client.Dnssec.Disable(domain)
|
|
return err
|
|
}
|