diff options
author | delthas <delthas@dille.cc> | 2022-11-22 11:06:27 +0100 |
---|---|---|
committer | delthas <delthas@dille.cc> | 2022-11-22 11:06:27 +0100 |
commit | 68e1efcf0612c635ea186676559883e791552d30 (patch) | |
tree | 7cd2fbb5daba6ff48c7568d6c4cc4cc6a7a67afc /config.go | |
parent | Enable 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.go | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -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 } |