-
Notifications
You must be signed in to change notification settings - Fork 1
/
settings.go
40 lines (36 loc) · 895 Bytes
/
settings.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
package main
import (
"encoding/json"
"io"
"os"
)
type Settings struct {
ListenerAddress string `json:"ListenerAddress"`
IpRetrieveUrl string `json:"IpRetrieveUrl"`
UserAgent string `json:"UserAgent"`
UpdateOnStartup bool `json:"UpdateOnStartup"`
Username string `json:"Username"`
Password string `json:"Password"`
Records []Record `json:"Records"`
}
type Record struct {
UpdateUrl string `json:"UpdateUrl"`
Method string `json:"Method"`
Headers []string `json:"Headers"`
Body string `json:"Body"`
}
func LoadSettings() (*Settings, error) {
settings := new(Settings)
file, err := os.Open("dyndnsconfig.json")
if err != nil {
return settings, err
} else {
buffer, err := io.ReadAll(file)
if err != nil {
return settings, err
} else {
json.Unmarshal(buffer, settings)
return settings, nil
}
}
}