mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
@@ -137,7 +137,7 @@ func (c *ovhProvider) GetDomainCorrections(dc *models.DomainConfig) ([]*models.C
|
||||
rec := del.Existing.Original.(*Record)
|
||||
corrections = append(corrections, &models.Correction{
|
||||
Msg: del.String(),
|
||||
F: c.deleteRecordFunc(rec.Id, dc.Name),
|
||||
F: c.deleteRecordFunc(rec.ID, dc.Name),
|
||||
})
|
||||
}
|
||||
|
||||
|
@@ -2,10 +2,12 @@ package ovh
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/StackExchange/dnscontrol/models"
|
||||
"github.com/miekg/dns/dnsutil"
|
||||
)
|
||||
|
||||
// Void an empty structure.
|
||||
type Void struct {
|
||||
}
|
||||
|
||||
@@ -30,6 +32,7 @@ func (c *ovhProvider) fetchZones() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Zone describes the attributes of a DNS zone.
|
||||
type Zone struct {
|
||||
LastUpdate string `json:"lastUpdate,omitempty"`
|
||||
HasDNSAnycast bool `json:"hasDNSAnycast,omitempty"`
|
||||
@@ -49,17 +52,18 @@ func (c *ovhProvider) fetchZone(fqdn string) (*Zone, error) {
|
||||
return &response, nil
|
||||
}
|
||||
|
||||
// Record describes a DNS record.
|
||||
type Record struct {
|
||||
Target string `json:"target,omitempty"`
|
||||
Zone string `json:"zone,omitempty"`
|
||||
TTL uint32 `json:"ttl,omitempty"`
|
||||
FieldType string `json:"fieldType,omitempty"`
|
||||
Id int64 `json:"id,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
SubDomain string `json:"subDomain,omitempty"`
|
||||
}
|
||||
|
||||
type records struct {
|
||||
recordsId []int
|
||||
recordsID []int
|
||||
}
|
||||
|
||||
func (c *ovhProvider) fetchRecords(fqdn string) ([]*Record, error) {
|
||||
@@ -130,13 +134,13 @@ func (c *ovhProvider) updateRecordFunc(old *Record, rc *models.RecordConfig, fqd
|
||||
Target: rc.Content(),
|
||||
TTL: rc.TTL,
|
||||
Zone: fqdn,
|
||||
Id: old.Id,
|
||||
ID: old.ID,
|
||||
}
|
||||
if record.SubDomain == "@" {
|
||||
record.SubDomain = ""
|
||||
}
|
||||
|
||||
return c.client.Call("PUT", fmt.Sprintf("/domain/zone/%s/record/%d", fqdn, old.Id), &record, &Void{})
|
||||
return c.client.Call("PUT", fmt.Sprintf("/domain/zone/%s/record/%d", fqdn, old.ID), &record, &Void{})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,24 +159,25 @@ func (c *ovhProvider) fetchNS(fqdn string) ([]string, error) {
|
||||
return zone.NameServers, nil
|
||||
}
|
||||
|
||||
// CurrentNameServer stores information about nameservers.
|
||||
type CurrentNameServer struct {
|
||||
ToDelete bool `json:"toDelete,omitempty"`
|
||||
Ip string `json:"ip,omitempty"`
|
||||
IP string `json:"ip,omitempty"`
|
||||
IsUsed bool `json:"isUsed,omitempty"`
|
||||
Id int `json:"id,omitempty"`
|
||||
ID int `json:"id,omitempty"`
|
||||
Host string `json:"host,omitempty"`
|
||||
}
|
||||
|
||||
// Retrieve the NS currently being deployed to the registrar
|
||||
func (c *ovhProvider) fetchRegistrarNS(fqdn string) ([]string, error) {
|
||||
var nameServersId []int
|
||||
err := c.client.Call("GET", "/domain/"+fqdn+"/nameServer", nil, &nameServersId)
|
||||
var nameServersID []int
|
||||
err := c.client.Call("GET", "/domain/"+fqdn+"/nameServer", nil, &nameServersID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var nameServers []string
|
||||
for _, id := range nameServersId {
|
||||
for _, id := range nameServersID {
|
||||
var ns CurrentNameServer
|
||||
err = c.client.Call("GET", fmt.Sprintf("/domain/%s/nameServer/%d", fqdn, id), nil, &ns)
|
||||
if err != nil {
|
||||
@@ -189,15 +194,18 @@ func (c *ovhProvider) fetchRegistrarNS(fqdn string) ([]string, error) {
|
||||
return nameServers, nil
|
||||
}
|
||||
|
||||
// DomainNS describes a domain's NS in ovh's protocol.
|
||||
type DomainNS struct {
|
||||
Host string `json:"host,omitempty"`
|
||||
Ip string `json:"ip,omitempty"`
|
||||
IP string `json:"ip,omitempty"`
|
||||
}
|
||||
|
||||
// UpdateNS describes a list of nameservers in ovh's protocol.
|
||||
type UpdateNS struct {
|
||||
NameServers []DomainNS `json:"nameServers"`
|
||||
}
|
||||
|
||||
// Task describes a task in ovh's protocol.
|
||||
type Task struct {
|
||||
Function string `json:"function,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
@@ -206,12 +214,13 @@ type Task struct {
|
||||
CreationDate string `json:"creationDate,omitempty"`
|
||||
Comment string `json:"comment,omitempty"`
|
||||
TodoDate string `json:"todoDate,omitempty"`
|
||||
Id int64 `json:"id,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
CanCancel bool `json:"canCancel,omitempty"`
|
||||
DoneDate string `json:"doneDate,omitempty"`
|
||||
CanRelaunch bool `json:"canRelaunch,omitempty"`
|
||||
}
|
||||
|
||||
// Domain describes a domain in ovh's protocol.
|
||||
type Domain struct {
|
||||
NameServerType string `json:"nameServerType,omitempty"`
|
||||
TransferLockStatus string `json:"transferLockStatus,omitempty"`
|
||||
|
Reference in New Issue
Block a user