Skip to content

Commit 9aad292

Browse files
authored
INWX: Fix INWX provider after their unexpected data-type breaking-change (#3855)
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. ```
1 parent f306472 commit 9aad292

File tree

6 files changed

+28
-34
lines changed

6 files changed

+28
-34
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ require (
3838
github.com/miekg/dns v1.1.68
3939
github.com/mittwald/go-powerdns v0.6.7
4040
github.com/namedotcom/go v0.0.0-20180403034216-08470befbe04
41-
github.com/nrdcg/goinwx v0.11.0
41+
github.com/nrdcg/goinwx v0.12.0
4242
github.com/ovh/go-ovh v1.9.0
4343
github.com/philhug/opensrs-go v0.0.0-20171126225031-9dfa7433020d
4444
github.com/pkg/errors v0.9.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,8 @@ github.com/nicholas-fedor/shoutrrr v0.12.0 h1:8mwJdfU+uBEybSymwQJMGl/grG7lvVUKbV
307307
github.com/nicholas-fedor/shoutrrr v0.12.0/go.mod h1:WYiRalR4C43Qmd2zhPWGIFIxu633NB1hDM6Ap/DQcsA=
308308
github.com/nozzle/throttler v0.0.0-20180817012639-2ea982251481 h1:Up6+btDp321ZG5/zdSLo48H9Iaq0UQGthrhWC6pCxzE=
309309
github.com/nozzle/throttler v0.0.0-20180817012639-2ea982251481/go.mod h1:yKZQO8QE2bHlgozqWDiRVqTFlLQSj30K/6SAK8EeYFw=
310-
github.com/nrdcg/goinwx v0.11.0 h1:GER0SE3POub7rxARt3Y3jRy1OON1hwF1LRxHz5xsFBw=
311-
github.com/nrdcg/goinwx v0.11.0/go.mod h1:0BXSC0FxVtU4aTjX0Zw3x0DK32tjugLzeNIAGtwXvPQ=
310+
github.com/nrdcg/goinwx v0.12.0 h1:ujdUqDBnaRSFwzVnImvPHYw3w3m9XgmGImNUw1GyMb4=
311+
github.com/nrdcg/goinwx v0.12.0/go.mod h1:IrVKd3ZDbFiMjdPgML4CSxZAY9wOoqLvH44zv3NodJ0=
312312
github.com/onsi/ginkgo/v2 v2.27.2 h1:LzwLj0b89qtIy6SSASkzlNvX6WktqurSHwkk2ipF/Ns=
313313
github.com/onsi/ginkgo/v2 v2.27.2/go.mod h1:ArE1D/XhNXBXCBkKOLkbsb2c81dQHCRcF5zwn/ykDRo=
314314
github.com/onsi/gomega v1.38.2 h1:eZCjf2xjZAqe+LeWvKb5weQ+NcPwX84kqJ0cZNxok2A=

pkg/zonerecs/zonerecords.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func CorrectZoneRecords(driver models.DNSProvider, dc *models.DomainConfig) ([]*
1919
models.CanonicalizeTargets(existingRecords, dc.Name)
2020
models.CanonicalizeTargets(dc.Records, dc.Name)
2121

22-
// Copy dc so that any corrections code that wants to
22+
// Copy dc so that any correction code that wants to
2323
// modify the records may. For example, if the provider only
2424
// supports certain TTL values, it will adjust the ones in
2525
// dc.Records.

providers/inwx/auditrecords.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,8 @@ import (
1010
// supported, an empty list is returned.
1111
func AuditRecords(records []*models.RecordConfig) []error {
1212
a := rejectif.Auditor{}
13-
14-
a.Add("TXT", rejectif.TxtHasBackticks) // Last verified 2021-03-01
15-
13+
a.Add("TXT", rejectif.TxtHasBackticks) // Last verified 2021-03-01
1614
a.Add("TXT", rejectif.TxtHasTrailingSpace) // Last verified 2021-03-01
17-
18-
a.Add("TXT", rejectif.TxtIsEmpty) // Last verified 2021-03-01
19-
15+
a.Add("TXT", rejectif.TxtIsEmpty) // Last verified 2021-03-01
2016
return a.Audit(records)
2117
}

providers/inwx/dnssec.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,22 @@ const (
1010
// testing shows 'AUTO' is what to expect if the domain has automatic
1111
// DNSSEC enabled.
1212

13-
// AutoDNSSEC is the status for DNSSEC enabled with automatic management
13+
// AutoDNSSECStatus is the status for DNSSEC enabled with automatic management
1414
AutoDNSSECStatus = "AUTO"
15-
// ManualDNSSEC is the status for DNSSEC enabled with manual management
15+
// ManualDNSSECStatus is the status for DNSSEC enabled with manual management
1616
ManualDNSSECStatus = "MANUAL"
1717
)
1818

1919
// DNSSecStatus returns domain dnssec status
2020
func (api *inwxAPI) DNSSecStatus(domain string) (string, error) {
21-
2221
resp, err := api.client.Dnssec.Info([]string{domain})
2322
if err != nil {
2423
return "", err
2524
}
26-
2725
// domain has no DNSSEC configuration
2826
if len(resp.Data) == 0 {
2927
return "", nil
3028
}
31-
3229
return resp.Data[0].DNSSecStatus, nil
3330
}
3431

@@ -40,16 +37,12 @@ func (api *inwxAPI) enableAutoDNSSEC(domain string) error {
4037
if err != nil {
4138
return err
4239
}
43-
4440
err = api.client.Dnssec.Enable(domain)
45-
4641
return err
4742
}
4843

4944
// disableAutoDNSSEC disables automatic management of DNSSEC
5045
func (api *inwxAPI) disableAutoDNSSEC(domain string) error {
51-
5246
err := api.client.Dnssec.Disable(domain)
53-
5447
return err
5548
}

providers/inwx/inwxProvider.go

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ import (
2222
/*
2323
INWX Registrar and DNS provider
2424
25+
Based on this great INWX API implementation:
26+
https://github.com/nrdcg/goinwx
27+
2528
Info required in `creds.json`:
2629
- username
2730
- password
@@ -34,7 +37,6 @@ Either of the following settings is required when two factor authentication is e
3437
3538
Additional settings available in `creds.json`:
3639
- sandbox (set to 1 to use the sandbox API from INWX)
37-
3840
*/
3941

4042
// InwxProductionDefaultNs contains the default INWX nameservers.
@@ -182,10 +184,10 @@ func makeNameserverRecordRequest(domain string, rec *models.RecordConfig) *goinw
182184

183185
switch rType := rec.Type; rType {
184186
/*
185-
INWX is a little bit special for CNAME,NS,MX and SRV records:
187+
INWX is a little bit special for CNAME, NS, MX and SRV records:
186188
The API will not accept any target with a final dot but will
187189
instead always add this final dot internally.
188-
Records with empty targets (i.e. records with target ".")
190+
Records with empty targets (i.e., records with target ".")
189191
are allowed.
190192
*/
191193
case "CNAME", "NS", "ALIAS":
@@ -219,14 +221,14 @@ func (api *inwxAPI) createRecord(domain string, rec *models.RecordConfig) error
219221
}
220222

221223
// updateRecord is used by GetDomainCorrections to update an existing record.
222-
func (api *inwxAPI) updateRecord(RecordID int, rec *models.RecordConfig) error {
224+
func (api *inwxAPI) updateRecord(RecordID string, rec *models.RecordConfig) error {
223225
req := makeNameserverRecordRequest("", rec)
224226
err := api.client.Nameservers.UpdateRecord(RecordID, req)
225227
return err
226228
}
227229

228230
// deleteRecord is used by GetDomainCorrections to delete a record.
229-
func (api *inwxAPI) deleteRecord(RecordID int) error {
231+
func (api *inwxAPI) deleteRecord(RecordID string) error {
230232
return api.client.Nameservers.DeleteRecord(RecordID)
231233
}
232234

@@ -244,7 +246,8 @@ func (api *inwxAPI) AutoDnssecToggle(dc *models.DomainConfig, corrections []*mod
244246
}
245247

246248
if dnssecStatus == ManualDNSSECStatus && dc.AutoDNSSEC != "" {
247-
return corrections, fmt.Errorf("INWX: Domain %s has manual DNSSEC enabled. Disable it before using AUTODNSSEC_ON/AUTODNSSEC_OFF", dc.Name)
249+
return corrections, fmt.Errorf("INWX: Domain %s has manual DNSSEC enabled. Disable it before using "+
250+
"AUTODNSSEC_ON/AUTODNSSEC_OFF", dc.Name)
248251
}
249252

250253
if dnssecStatus != AutoDNSSECStatus && dc.AutoDNSSEC == "on" {
@@ -289,31 +292,33 @@ func (api *inwxAPI) GetZoneRecordsCorrections(dc *models.DomainConfig, foundReco
289292
return nil, 0, err
290293
}
291294
for _, change := range changes {
292-
changeMsgs := change.MsgsJoined
295+
changeMessage := change.MsgsJoined
293296
switch change.Type {
294297
case diff2.REPORT:
295-
corrections = append(corrections, &models.Correction{Msg: changeMsgs})
298+
corrections = append(corrections, &models.Correction{Msg: changeMessage})
296299
case diff2.CHANGE:
297300
oldRec := change.Old[0]
298301
newRec := change.New[0]
299302
if isNullMX(newRec) || isNullMX(oldRec) {
300-
// changing to or from a Null MX has to be delete then create
303+
// changing to or from a Null MX has to be deleted then create
301304
deletes = append(deletes, &models.Correction{
302-
Msg: color.RedString("- DELETE %s %s %s ttl=%d", oldRec.GetLabelFQDN(), oldRec.Type, oldRec.ToComparableNoTTL(), oldRec.TTL),
305+
Msg: color.RedString("- DELETE %s %s %s ttl=%d", oldRec.GetLabelFQDN(), oldRec.Type,
306+
oldRec.ToComparableNoTTL(), oldRec.TTL),
303307
F: func() error {
304308
return api.deleteRecord(oldRec.Original.(goinwx.NameserverRecord).ID)
305309
},
306310
})
307311
deferred = append(deferred, &models.Correction{
308-
Msg: color.GreenString("+ CREATE %s %s %s ttl=%d", newRec.GetLabelFQDN(), newRec.Type, newRec.ToComparableNoTTL(), newRec.TTL),
312+
Msg: color.GreenString("+ CREATE %s %s %s ttl=%d", newRec.GetLabelFQDN(), newRec.Type,
313+
newRec.ToComparableNoTTL(), newRec.TTL),
309314
F: func() error {
310315
return api.createRecord(dc.Name, newRec)
311316
},
312317
})
313318
} else {
314319
recID := oldRec.Original.(goinwx.NameserverRecord).ID
315320
corrections = append(corrections, &models.Correction{
316-
Msg: changeMsgs,
321+
Msg: changeMessage,
317322
F: func() error {
318323
return api.updateRecord(recID, newRec)
319324
},
@@ -322,15 +327,15 @@ func (api *inwxAPI) GetZoneRecordsCorrections(dc *models.DomainConfig, foundReco
322327
}
323328
case diff2.CREATE:
324329
creates = append(creates, &models.Correction{
325-
Msg: changeMsgs,
330+
Msg: changeMessage,
326331
F: func() error {
327332
return api.createRecord(dc.Name, change.New[0])
328333
},
329334
})
330335
case diff2.DELETE:
331336
recID := change.Old[0].Original.(goinwx.NameserverRecord).ID
332337
deletes = append(deletes, &models.Correction{
333-
Msg: changeMsgs,
338+
Msg: changeMessage,
334339
F: func() error { return api.deleteRecord(recID) },
335340
})
336341
default:
@@ -343,7 +348,7 @@ func (api *inwxAPI) GetZoneRecordsCorrections(dc *models.DomainConfig, foundReco
343348
return corrections, actualChangeCount, nil
344349
}
345350

346-
// getDefaultNameservers returns string map with default nameservers based on e.g. sandbox mode.
351+
// getDefaultNameservers returns a string map with default nameservers based on e.g. sandbox mode.
347352
func (api *inwxAPI) getDefaultNameservers() []string {
348353
if api.sandbox {
349354
return InwxSandboxDefaultNs

0 commit comments

Comments
 (0)