mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2025-12-09 13:46:07 +08:00
fixup!
This commit is contained in:
parent
cbbb396026
commit
29dbdbbd5c
5 changed files with 27 additions and 16 deletions
|
|
@ -19,20 +19,27 @@ func (handle *RP) Name() string {
|
|||
return "RP"
|
||||
}
|
||||
|
||||
// FromArgs fills in the RecordConfig from []any, which is typically from a parsed config file.
|
||||
func (handle *RP) FromArgs(dc *models.DomainConfig, rec *models.RecordConfig, args []any) error {
|
||||
if err := rtypecontrol.PaveArgs(args[1:], "ss"); err != nil {
|
||||
return err
|
||||
}
|
||||
rec.F = &RP{
|
||||
fields := &RP{
|
||||
dns.RP{
|
||||
Mbox: args[1].(string),
|
||||
Txt: args[2].(string),
|
||||
},
|
||||
}
|
||||
|
||||
// TODO: Generate friendly Comparable and ZonefilePartial values.
|
||||
rec.Comparable = rec.F.(*RP).Mbox + " " + rec.F.(*RP).Txt
|
||||
rec.ZonefilePartial = rec.Comparable
|
||||
return handle.FromStruct(dc, rec, args[0].(string), fields)
|
||||
}
|
||||
|
||||
// FromStruct fills in the RecordConfig from a struct, typically from an API response.
|
||||
func (handle *RP) FromStruct(dc *models.DomainConfig, rec *models.RecordConfig, name string, fields any) error {
|
||||
rec.F = fields
|
||||
|
||||
rec.ZonefilePartial = rec.GetTargetRFC1035Quoted()
|
||||
rec.Comparable = rec.ZonefilePartial
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import (
|
|||
|
||||
"github.com/StackExchange/dnscontrol/v4/models"
|
||||
"github.com/StackExchange/dnscontrol/v4/pkg/domaintags"
|
||||
"github.com/miekg/dns"
|
||||
"github.com/miekg/dns/dnsutil"
|
||||
)
|
||||
|
||||
|
|
@ -74,8 +73,12 @@ func NewRecordConfigFromStruct(name string, ttl uint32, t string, fields any, dc
|
|||
}
|
||||
setRecordNames(rec, dc, name)
|
||||
|
||||
// Fill in the .F/.Fields* fields.
|
||||
err := Func[t].FromArgs(dc, rec, []any{name, fields.(*dns.RP).Mbox, fields.(*dns.RP).Txt})
|
||||
// // Fill in the .F/.Fields* fields.
|
||||
// err := Func[t].FromArgs(dc, rec, []any{name, fields.(*dns.RP).Mbox, fields.(*dns.RP).Txt})
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
err := Func[t].FromStruct(dc, rec, name, fields)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ type RType interface {
|
|||
|
||||
// RecordConfig factory. Updates a RecordConfig's fields based on args.
|
||||
FromArgs(*models.DomainConfig, *models.RecordConfig, []any) error
|
||||
FromStruct(*models.DomainConfig, *models.RecordConfig, string, any) error
|
||||
|
||||
CopyToLegacyFields(*models.RecordConfig)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@ func (handle *CfRedirect) FromArgs(dc *models.DomainConfig, rec *models.RecordCo
|
|||
return FromArgs_helper(dc, rec, args, 301)
|
||||
}
|
||||
|
||||
// func (handle *CfRedirect) FromStruct(dc *models.DomainConfig, rec *models.RecordConfig, fields any) error {
|
||||
// panic("CF_REDIRECT: FromStruct not implemented")
|
||||
// }
|
||||
func (handle *CfRedirect) FromStruct(dc *models.DomainConfig, rec *models.RecordConfig, name string, fields any) error {
|
||||
panic("CF_REDIRECT: FromStruct not implemented")
|
||||
}
|
||||
|
||||
func (handle *CfRedirect) CopyToLegacyFields(rec *models.RecordConfig) {
|
||||
// Nothing needs to be copied. The CLOUDFLAREAPI_SINGLE_REDIRECT FromArgs copies everything needed.
|
||||
|
|
@ -43,9 +43,9 @@ func (handle *CfTempRedirect) FromArgs(dc *models.DomainConfig, rec *models.Reco
|
|||
return FromArgs_helper(dc, rec, args, 302)
|
||||
}
|
||||
|
||||
// func (handle *CfTempRedirect) FromStruct(dc *models.DomainConfig, rec *models.RecordConfig, fields any) error {
|
||||
// panic("CF_TEMP_REDIRECT: FromStruct not implemented")
|
||||
// }
|
||||
func (handle *CfTempRedirect) FromStruct(dc *models.DomainConfig, rec *models.RecordConfig, name string, fields any) error {
|
||||
panic("CF_TEMP_REDIRECT: FromStruct not implemented")
|
||||
}
|
||||
|
||||
func (handle *CfTempRedirect) CopyToLegacyFields(rec *models.RecordConfig) {
|
||||
// Nothing needs to be copied. The CLOUDFLAREAPI_SINGLE_REDIRECT FromArgs copies everything needed.
|
||||
|
|
|
|||
|
|
@ -76,9 +76,9 @@ func (handle *SingleRedirectConfig) FromArgs(dc *models.DomainConfig, rec *model
|
|||
return nil
|
||||
}
|
||||
|
||||
// func (handle *SingleRedirectConfig) FromStruct(dc *models.DomainConfig, rec *models.RecordConfig, fields any) error {
|
||||
// panic("CLOUDFLAREAPI_SINGLE_REDIRECT: FromStruct not implemented")
|
||||
// }
|
||||
func (handle *SingleRedirectConfig) FromStruct(dc *models.DomainConfig, rec *models.RecordConfig, name string, fields any) error {
|
||||
panic("CLOUDFLAREAPI_SINGLE_REDIRECT: FromStruct not implemented")
|
||||
}
|
||||
|
||||
// targetFromRaw create the display text used for a normal Redirect.
|
||||
func targetFromRaw(name string, code uint16, when, then string) string {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue