-
Notifications
You must be signed in to change notification settings - Fork 1
/
types.go
49 lines (39 loc) · 1.08 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main
import (
"encoding/json"
"time"
)
type config struct {
AcmeDNSURL string `json:"acme_dns_url"`
PropagationDuration duration `json:"propagation_duration"`
Domains map[string]domain `json:"domains"`
}
type domain struct {
Username string `json:"username"`
Password string `json:"password"`
FullDomain string `json:"fulldomain"`
Subdomain string `json:"subdomain"`
AllowFrom []string `json:"allowfrom"`
AcmeDNSURL string `json:"acme_dns_url"`
PropagationDuration duration `json:"propagation_duration"`
}
type updateBody struct {
Subdomain string `json:"subdomain"`
Txt string `json:"txt"`
}
type duration time.Duration
func (d duration) MarshalJSON() ([]byte, error) {
return []byte(time.Duration(d).String()), nil
}
func (d *duration) UnmarshalJSON(data []byte) error {
var s string
if err := json.Unmarshal(data, &s); err != nil {
return err
}
dur, err := time.ParseDuration(s)
if err != nil {
return err
}
*d = duration(dur)
return nil
}