Documentation
¶
Overview ¶
Package dns implements the functionality of Dns methods. Package implements getData and changeRecords methods. To create the appropriate methods, you need to call either CallGetData or CallChangeRecords. Also, package contains:
- github.com/ThCompiler/go.beget.api/api/dns/record package, that implements structures representing records from getData response.
- github.com/ThCompiler/go.beget.api/api/dns/general package, that implements structures with a generalized representation of the DNS server records supported by Beget.
- github.com/ThCompiler/go.beget.api/api/dns/build package, that implements builders of BasicRecords, DNSRecords, CNAMERecords and NSRecords.
Index ¶
Constants ¶
const ( MaxDNSRecords = 4 // limit for DNS-records. MaxBasicRecords = 10 // limit for "A, MX, TXT" records. MaxCNAMERecords = 1 // limit for CNAME-records. MaxNSRecords = 10 // limit for NS-records. )
Limits on the number of specific records.
const ( GetDataMethodName = "GetData" GetDataMethodPath = "dns/getData" ChangeRecordsMethodName = "ChangeRecords" ChangeRecordsMethodPath = "dns/changeRecords" )
Constants used to implement the getData and changeRecords methods.
Variables ¶
var ( // "too mach DNS records, max records 4" ErrTooMuchDNSRecords = errors.New(fmt.Sprintf("too mach DNS records, max records %d", MaxDNSRecords)) // "too mach DNS_IP records, max records 4" ErrTooMuchDNSIPRecords = errors.New(fmt.Sprintf("too mach DNS_IP records, max records %d", MaxDNSRecords)) // "too mach NS records, max records 10" ErrTooMuchNsRecords = errors.New(fmt.Sprintf("too mach NS records, max records %d", MaxNSRecords)) // "too mach CNAME records, max records 1" ErrTooMuchCNameRecords = errors.New(fmt.Sprintf("too mach CNAME records, max records %d", MaxCNAMERecords)) // "too mach A records, max records 1" ErrTooMuchARecords = errors.New(fmt.Sprintf("too mach A records, max records %d", MaxBasicRecords)) // "too mach AAAA records, max records 10" ErrTooMuchAAAARecords = errors.New(fmt.Sprintf("too mach AAAA records, max records %d", MaxBasicRecords)) // "too mach MX records, max records 10" ErrTooMuchMxRecords = errors.New(fmt.Sprintf("too mach MX records, max records %d", MaxBasicRecords)) // "too mach TXT records, max records 10" ErrTooMuchTxtRecords = errors.New(fmt.Sprintf("too mach TXT records, max records %d", MaxBasicRecords)) // "DNS records not equal DNS_IP records" ErrNumberDNSRecordsNotEqual = errors.New("DNS records not equal DNS_IP records") )
Validation errors for new records for DNS record change request (changeRecords).
Functions ¶
func CallChangeRecords ¶
func CallChangeRecords(domainName string, records SettableRecords) core.APIMethod[result.BoolResult]
CallChangeRecords is a creation function that returns a core.APIMethod corresponding to the method changeRecords. The function expects the domain name for which DNS records need to be changed, and the modified set of records that need to be applied.
Three types of records are supported:
- "A, MX, TXT" records (BasicRecords).
- NS-records (NSRecords).
- CNAME-records (CNAMERecords).
Also, each record can contain DNS records (DNSRecords).
Important ¶
The beget system replaces the current DNS server records with the ones passed in the request. The old records will be lost.
If you need to change only one record for a domain, you should first get full information about the records of this DNS server domain using the CallGetData method. Then change the necessary information in the received records. And pass all this as the body for the change request.
Noticed ¶
If the domain contains SRV or CAA records, it is not possible to change them by changeRecords method. If you attempt to change other records for this domain by changeRecords method, SRV and CAA records will be deleted.
func CallGetData ¶
CallGetData is a creation function that returns a core.APIMethod corresponding to the method getData. The function is waiting for the domain name for which it is necessary to get data from the DNS server.
Types ¶
type BasicRecords ¶
type BasicRecords struct {
DNSRecords
A []ChangedRecord `json:"A,omitempty"` // A records.
AAAA []ChangedRecord `json:"AAAA,omitempty"` // AAAA records.
Mx []ChangedRecord `json:"MX,omitempty"` // MX records.
Txt []ChangedRecord `json:"TXT,omitempty"` // TXT records.
}
BasicRecords represents a changed "A, MX, TXT" records. There is no information about AAAA-records in the documentation of the Beget.API, but if this field is set, the requests are executed successfully
func (*BasicRecords) Validate ¶
func (b *BasicRecords) Validate() error
Validate checks records for limiting their number and checks embedded DNSRecords.
Can return errors:
type CNAMERecords ¶
type CNAMERecords struct {
DNSRecords
CName []ChangedRecord `json:"CNAME,omitempty"` // CNAME records.
}
CNAMERecords represents a changed CNAME-records.
func (*CNAMERecords) Validate ¶
func (c *CNAMERecords) Validate() error
Validate checks records for limiting their number and checks embedded DNSRecords.
Can return errors:
type ChangedRecord ¶
ChangedRecord represents a single changed record.
type DNSRecords ¶
type DNSRecords struct {
DNS []ChangedRecord `json:"DNS,omitempty"` // DNS records.
DNSIP []ChangedRecord `json:"DNS_IP,omitempty"` // DNS_IP records.
}
DNSRecords represents a changed DNS-records. If the DNS servers are not proprietary (i.e. they are not located on one of the subdomains of the main domain), then the DNS_IP section can be omitted.
func (*DNSRecords) Validate ¶
func (d *DNSRecords) Validate() error
Validate checks records for limiting their number and for matching the number of DNS records to the number of DNS_IP records (if the latter are not omitted).
Can return errors:
type NSRecords ¶
type NSRecords struct {
DNSRecords
Ns []ChangedRecord `json:"NS,omitempty"` // NS records.
}
NSRecords represents a changed NS-records.
func (*NSRecords) Validate ¶
Validate checks records for limiting their number and checks embedded DNSRecords.
Can return errors:
type SettableRecords ¶
type SettableRecords interface {
// Validate indicates whether the entries are correct from the API's point of view.
// If the entries are not correct, the method should return an error, otherwise "nil".
Validate() error
}
SettableRecords provides records that can be applied on the DNS server for a specific domain.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package build implements builders of github.com/ThCompiler/go.beget.api/api/dns.BasicRecords, github.com/ThCompiler/go.beget.api/api/dns.DNSRecords, github.com/ThCompiler/go.beget.api/api/dns.CNAMERecords and github.com/ThCompiler/go.beget.api/api/dns.NSRecords.
|
Package build implements builders of github.com/ThCompiler/go.beget.api/api/dns.BasicRecords, github.com/ThCompiler/go.beget.api/api/dns.DNSRecords, github.com/ThCompiler/go.beget.api/api/dns.CNAMERecords and github.com/ThCompiler/go.beget.api/api/dns.NSRecords. |
|
Package general implements structures with a generalized representation of the DNS server records supported by Beget.
|
Package general implements structures with a generalized representation of the DNS server records supported by Beget. |
|
Package record implements structures representing records from [getData] response.
|
Package record implements structures representing records from [getData] response. |