@@ 27,13 27,14 @@ type Domain struct {
Domain string
A string
AcmeChallenge string
+ TsigKey string
Owner DomainOwner
}
// FetchDomainsForUser fetches all domains for a specific user.
func FetchDomainsForUser(userID string) ([]Domain, error) {
- rows, err := DBConn.Query(`SELECT id, apikey, ddns_domain, a_record
+ rows, err := DBConn.Query(`SELECT id, apikey, ddns_domain, a_record, tsigkey
FROM domains WHERE owner = $1`, userID)
if err != nil {
return nil, err
@@ 43,7 44,7 @@ func FetchDomainsForUser(userID string) ([]Domain, error) {
var domains []Domain
for rows.Next() {
var domain Domain
- err = rows.Scan(&domain.ID, &domain.APIKey, &domain.Domain, &domain.A)
+ err = rows.Scan(&domain.ID, &domain.APIKey, &domain.Domain, &domain.A, &domain.TsigKey)
if err != nil {
return nil, err
}
@@ 207,3 208,14 @@ func DeleteDomainAcmeChallenge(ddnsDomain string) error {
return nil
}
+
+// FetchDomainTsigKey fetches the tsig key of a domain.
+func FetchDomainTsigKey(ddnsDomain string) (string, error) {
+ var tsig string
+ err := DBConn.QueryRow(`SELECT tsigkey FROM domains WHERE ddns_domain = $1`,
+ ddnsDomain).Scan(&tsig)
+ if err != nil {
+ return "", err
+ }
+ return tsig, nil
+}
@@ 84,5 84,7 @@ func migrations() []string {
)`),
fmt.Sprintf(`ALTER TABLE domains
ADD acme_challenge TEXT DEFAULT ''`),
+ fmt.Sprintf(`ALTER TABLE domains
+ ADD tsigkey TEXT DEFAULT ''`),
}
}