diff options
author | Rutger Broekhoff | 2024-11-14 00:32:31 +0100 |
---|---|---|
committer | Rutger Broekhoff | 2024-11-14 00:32:31 +0100 |
commit | 6993a0b90012ccd5eeb1b41aac02bb31b0281cc9 (patch) | |
tree | 86b3aa5ec2675f5d97453851dad1186a709d48c7 /config.go | |
parent | 3d967b586c8b277a5fd2ddc16289856205144036 (diff) | |
download | icalproxy-6993a0b90012ccd5eeb1b41aac02bb31b0281cc9.tar.gz icalproxy-6993a0b90012ccd5eeb1b41aac02bb31b0281cc9.zip |
Why is Go so terrible
Diffstat (limited to 'config.go')
-rw-r--r-- | config.go | 23 |
1 files changed, 12 insertions, 11 deletions
@@ -15,14 +15,14 @@ type userToken struct { | |||
15 | Salt []byte `json:"salt"` | 15 | Salt []byte `json:"salt"` |
16 | } | 16 | } |
17 | 17 | ||
18 | type jsonURL url.URL | 18 | type jsonURL struct{ v url.URL } |
19 | 19 | ||
20 | func (u *jsonURL) UnmarshalText(v []byte) error { | 20 | func (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 | ||
69 | func loadConfigFrom(filename string) config { | 70 | func loadConfigFrom(filename string) config { |