mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
NEW PROVIDER: CSCGLOBAL as DNS Service Provider (#1516)
* Move the registrar features to a separate file * Prepare the testing framework * Roughed out functions * Fix up structs * WIP! * First tests pass * wip! * Flesh out remaining rTypes, get nameservers, etc * Fix TXT records * Clean up code * More cleanups. Fix CAA/SRV * Linting * Cleanups/linting * Fix CAA [more] and more cleanups * CSC does not like very long txt records * Use timer only when interactive * Disable CAA for now * Update docs * Remove debug printf * add go-isatty * cleanups
This commit is contained in:
129
providers/cscglobal/convert.go
Normal file
129
providers/cscglobal/convert.go
Normal file
@@ -0,0 +1,129 @@
|
||||
package cscglobal
|
||||
|
||||
// Convert the provider's native record description to models.RecordConfig.
|
||||
|
||||
import (
|
||||
"net"
|
||||
|
||||
"github.com/StackExchange/dnscontrol/v3/models"
|
||||
)
|
||||
|
||||
// nativeToRecordA takes an A record from DNS and returns a native RecordConfig struct.
|
||||
func nativeToRecordA(nr nativeRecordA, origin string, defaultTTL uint32) *models.RecordConfig {
|
||||
ttl := nr.TTL
|
||||
if ttl == 0 {
|
||||
ttl = defaultTTL
|
||||
}
|
||||
rc := &models.RecordConfig{
|
||||
Type: "A",
|
||||
TTL: ttl,
|
||||
}
|
||||
rc.SetLabel(nr.Key, origin)
|
||||
rc.SetTargetIP(net.ParseIP(nr.Value).To4())
|
||||
return rc
|
||||
}
|
||||
|
||||
// nativeToRecordCNAME takes a CNAME record from DNS and returns a native RecordConfig struct.
|
||||
func nativeToRecordCNAME(nr nativeRecordCNAME, origin string, defaultTTL uint32) *models.RecordConfig {
|
||||
ttl := nr.TTL
|
||||
if ttl == 0 {
|
||||
ttl = defaultTTL
|
||||
}
|
||||
rc := &models.RecordConfig{
|
||||
Type: "CNAME",
|
||||
TTL: ttl,
|
||||
}
|
||||
rc.SetLabel(nr.Key, origin)
|
||||
rc.SetTarget(nr.Value)
|
||||
return rc
|
||||
}
|
||||
|
||||
// nativeToRecordA takes an AAAA record from DNS and returns a native RecordConfig struct.
|
||||
func nativeToRecordAAAA(nr nativeRecordAAAA, origin string, defaultTTL uint32) *models.RecordConfig {
|
||||
ttl := nr.TTL
|
||||
if ttl == 0 {
|
||||
ttl = defaultTTL
|
||||
}
|
||||
rc := &models.RecordConfig{
|
||||
Type: "AAAA",
|
||||
TTL: ttl,
|
||||
}
|
||||
rc.SetLabel(nr.Key, origin)
|
||||
rc.SetTargetIP(net.ParseIP(nr.Value).To16())
|
||||
return rc
|
||||
}
|
||||
|
||||
// nativeToRecordTXT takes a TXT record from DNS and returns a native RecordConfig struct.
|
||||
func nativeToRecordTXT(nr nativeRecordTXT, origin string, defaultTTL uint32) *models.RecordConfig {
|
||||
ttl := nr.TTL
|
||||
if ttl == 0 {
|
||||
ttl = defaultTTL
|
||||
}
|
||||
rc := &models.RecordConfig{
|
||||
Type: "TXT",
|
||||
TTL: ttl,
|
||||
}
|
||||
rc.SetLabel(nr.Key, origin)
|
||||
rc.SetTargetTXT(nr.Value)
|
||||
return rc
|
||||
}
|
||||
|
||||
// nativeToRecordMX takes a MX record from DNS and returns a native RecordConfig struct.
|
||||
func nativeToRecordMX(nr nativeRecordMX, origin string, defaultTTL uint32) *models.RecordConfig {
|
||||
ttl := nr.TTL
|
||||
if ttl == 0 {
|
||||
ttl = defaultTTL
|
||||
}
|
||||
rc := &models.RecordConfig{
|
||||
Type: "MX",
|
||||
TTL: ttl,
|
||||
}
|
||||
rc.SetLabel(nr.Key, origin)
|
||||
rc.SetTargetMX(nr.Priority, nr.Value)
|
||||
return rc
|
||||
}
|
||||
|
||||
// nativeToRecordNS takes a NS record from DNS and returns a native RecordConfig struct.
|
||||
func nativeToRecordNS(nr nativeRecordNS, origin string, defaultTTL uint32) *models.RecordConfig {
|
||||
ttl := nr.TTL
|
||||
if ttl == 0 {
|
||||
ttl = defaultTTL
|
||||
}
|
||||
rc := &models.RecordConfig{
|
||||
Type: "NS",
|
||||
TTL: ttl,
|
||||
}
|
||||
rc.SetLabel(nr.Key, origin)
|
||||
rc.SetTarget(nr.Value)
|
||||
return rc
|
||||
}
|
||||
|
||||
// nativeToRecordSRV takes a SRV record from DNS and returns a native RecordConfig struct.
|
||||
func nativeToRecordSRV(nr nativeRecordSRV, origin string, defaultTTL uint32) *models.RecordConfig {
|
||||
ttl := nr.TTL
|
||||
if ttl == 0 {
|
||||
ttl = defaultTTL
|
||||
}
|
||||
rc := &models.RecordConfig{
|
||||
Type: "SRV",
|
||||
TTL: ttl,
|
||||
}
|
||||
rc.SetLabel(nr.Key, origin)
|
||||
rc.SetTargetSRV(nr.Priority, nr.Weight, nr.Port, nr.Value)
|
||||
return rc
|
||||
}
|
||||
|
||||
// nativeToRecordCAA takes a CAA record from DNS and returns a native RecordConfig struct.
|
||||
func nativeToRecordCAA(nr nativeRecordCAA, origin string, defaultTTL uint32) *models.RecordConfig {
|
||||
ttl := nr.TTL
|
||||
if ttl == 0 {
|
||||
ttl = defaultTTL
|
||||
}
|
||||
rc := &models.RecordConfig{
|
||||
Type: "CAA",
|
||||
TTL: ttl,
|
||||
}
|
||||
rc.SetLabel(nr.Key, origin)
|
||||
rc.SetTargetCAA(nr.Flag, nr.Tag, nr.Value)
|
||||
return rc
|
||||
}
|
Reference in New Issue
Block a user