summaryrefslogtreecommitdiff
path: root/config.go
diff options
context:
space:
mode:
authordelthas <delthas@dille.cc>2022-11-22 11:06:27 +0100
committerdelthas <delthas@dille.cc>2022-11-22 11:06:27 +0100
commit68e1efcf0612c635ea186676559883e791552d30 (patch)
tree7cd2fbb5daba6ff48c7568d6c4cc4cc6a7a67afc /config.go
parentEnable receiving away updates for private buffers (diff)
Support irc URLs in the config addr
Fixes: https://todo.sr.ht/~taiite/senpai/106
Diffstat (limited to 'config.go')
-rw-r--r--config.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/config.go b/config.go
index 9ee6d09..0aab25a 100644
--- a/config.go
+++ b/config.go
@@ -3,6 +3,8 @@ package senpai
import (
"errors"
"fmt"
+ "net"
+ "net/url"
"os"
"os/exec"
"path"
@@ -140,6 +142,20 @@ func LoadConfigFile(filename string) (cfg Config, err error) {
if cfg.Real == "" {
cfg.Real = cfg.Nick
}
+ var u *url.URL
+ if u, err = url.Parse(cfg.Addr); err == nil && u.Scheme != "" {
+ switch u.Scheme {
+ case "ircs":
+ cfg.TLS = true
+ case "irc+insecure":
+ cfg.TLS = false
+ case "irc":
+ // Could be TLS or plaintext, keep TLS as is.
+ default:
+ return cfg, fmt.Errorf("invalid IRC addr scheme: %v", cfg.Addr)
+ }
+ cfg.Addr = net.JoinHostPort(u.Hostname(), u.Port())
+ }
return
}