aboutsummaryrefslogtreecommitdiffstats
path: root/config.go
diff options
context:
space:
mode:
Diffstat (limited to 'config.go')
-rw-r--r--config.go23
1 files changed, 12 insertions, 11 deletions
diff --git a/config.go b/config.go
index 746e437..9070ae9 100644
--- a/config.go
+++ b/config.go
@@ -15,14 +15,14 @@ type userToken struct {
15 Salt []byte `json:"salt"` 15 Salt []byte `json:"salt"`
16} 16}
17 17
18type jsonURL url.URL 18type jsonURL struct{ v url.URL }
19 19
20func (u *jsonURL) UnmarshalText(v []byte) error { 20func (u *jsonURL) UnmarshalText(v []byte) error {
21 parsed, err := url.Parse(string(v)) 21 parsed, err := url.Parse(string(v))
22 if err != nil { 22 if err != nil {
23 return err 23 return err
24 } 24 }
25 *u = jsonURL(*parsed) 25 u.v = *parsed
26 return nil 26 return nil
27} 27}
28 28
@@ -44,16 +44,8 @@ func printConfig(cfg *config) {
44 b64 := base64.StdEncoding 44 b64 := base64.StdEncoding
45 45
46 log.Print("Loaded configuration: ") 46 log.Print("Loaded configuration: ")
47 log.Print(" Calendar URL: ", cfg.CalendarURL.v.String())
47 log.Print(" HTTP Port: ", cfg.Port) 48 log.Print(" HTTP Port: ", cfg.Port)
48 log.Print(" User Tokens:")
49 for user, token := range cfg.UserTokens {
50 log.Print(" User ", user, ":")
51 log.Print(" Hash: ", b64.EncodeToString(token.Hash))
52 log.Print(" Salt: ", b64.EncodeToString(token.Salt))
53 }
54 if len(cfg.UserTokens) == 0 {
55 log.Print(" <no users configured>")
56 }
57 log.Print(" Ignoring:") 49 log.Print(" Ignoring:")
58 for _, entry := range cfg.Ignore.LocationRegexes { 50 for _, entry := range cfg.Ignore.LocationRegexes {
59 log.Printf(" Events with locations matching %s", entry.String()) 51 log.Printf(" Events with locations matching %s", entry.String())
@@ -64,6 +56,15 @@ func printConfig(cfg *config) {
64 if len(cfg.Ignore.LocationRegexes)+len(cfg.Ignore.SummaryRegexes) == 0 { 56 if len(cfg.Ignore.LocationRegexes)+len(cfg.Ignore.SummaryRegexes) == 0 {
65 log.Printf(" <no ignore rules configured>") 57 log.Printf(" <no ignore rules configured>")
66 } 58 }
59 log.Print(" User Tokens:")
60 for user, token := range cfg.UserTokens {
61 log.Print(" User ", user, ":")
62 log.Print(" Hash: ", b64.EncodeToString(token.Hash))
63 log.Print(" Salt: ", b64.EncodeToString(token.Salt))
64 }
65 if len(cfg.UserTokens) == 0 {
66 log.Print(" <no users configured>")
67 }
67} 68}
68 69
69func loadConfigFrom(filename string) config { 70func loadConfigFrom(filename string) config {