2018-02-16 01:02:50 +08:00
|
|
|
package models
|
|
|
|
|
|
|
|
// SetTargetTXT sets the TXT fields when there is 1 string.
|
|
|
|
func (rc *RecordConfig) SetTargetTXT(s string) error {
|
2018-03-20 05:18:58 +08:00
|
|
|
rc.SetTarget(s)
|
2018-02-16 01:02:50 +08:00
|
|
|
rc.TxtStrings = []string{s}
|
|
|
|
if rc.Type == "" {
|
|
|
|
rc.Type = "TXT"
|
|
|
|
}
|
|
|
|
if rc.Type != "TXT" {
|
|
|
|
panic("assertion failed: SetTargetTXT called when .Type is not TXT")
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetTargetTXTs sets the TXT fields when there are many strings.
|
|
|
|
func (rc *RecordConfig) SetTargetTXTs(s []string) error {
|
2018-03-20 05:18:58 +08:00
|
|
|
rc.SetTarget(s[0])
|
2018-02-16 01:02:50 +08:00
|
|
|
rc.TxtStrings = s
|
|
|
|
if rc.Type == "" {
|
|
|
|
rc.Type = "TXT"
|
|
|
|
}
|
|
|
|
if rc.Type != "TXT" {
|
|
|
|
panic("assertion failed: SetTargetTXT called when .Type is not TXT")
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2018-02-25 02:40:18 +08:00
|
|
|
// SetTargetTXTString is like SetTargetTXT but accepts one big string,
|
|
|
|
// which must be parsed into one or more strings based on how it is quoted.
|
2018-02-16 01:02:50 +08:00
|
|
|
// Ex: foo << 1 string
|
|
|
|
// foo bar << 1 string
|
|
|
|
// "foo" "bar" << 2 strings
|
|
|
|
func (rc *RecordConfig) SetTargetTXTString(s string) error {
|
|
|
|
return rc.SetTargetTXTs(ParseQuotedTxt(s))
|
|
|
|
}
|