aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Rutger Broekhoff2024-11-14 00:32:31 +0100
committerLibravatar Rutger Broekhoff2024-11-14 00:32:31 +0100
commit6993a0b90012ccd5eeb1b41aac02bb31b0281cc9 (patch)
tree86b3aa5ec2675f5d97453851dad1186a709d48c7
parent3d967b586c8b277a5fd2ddc16289856205144036 (diff)
downloadicalproxy-6993a0b90012ccd5eeb1b41aac02bb31b0281cc9.tar.gz
icalproxy-6993a0b90012ccd5eeb1b41aac02bb31b0281cc9.zip
Why is Go so terrible
-rw-r--r--config.go23
-rw-r--r--icalproxy.go2
2 files changed, 13 insertions, 12 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 {
diff --git a/icalproxy.go b/icalproxy.go
index 9ca1b33..60a9bac 100644
--- a/icalproxy.go
+++ b/icalproxy.go
@@ -16,7 +16,7 @@ func main() {
16 printConfig(&cfg) 16 printConfig(&cfg)
17 17
18 handler := handler{ 18 handler := handler{
19 calURL: url.URL(cfg.CalendarURL), 19 calURL: url.URL(cfg.CalendarURL.v),
20 ignore: cfg.Ignore, 20 ignore: cfg.Ignore,
21 tokens: cfg.UserTokens, 21 tokens: cfg.UserTokens,
22 } 22 }