From 2ea4584c973ab3b02119dfa2b134f4274614e82c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ken-H=C3=A5vard=20Lieng?= Date: Tue, 16 Jun 2020 01:22:23 +0200 Subject: [PATCH] Add auto_ctcp config option --- commands/dispatch.go | 1 + config.default.toml | 10 +++++++--- config/config.go | 1 + pkg/irc/client.go | 2 ++ pkg/irc/internal.go | 6 ++++-- server/irc.go | 2 ++ 6 files changed, 17 insertions(+), 5 deletions(-) diff --git a/commands/dispatch.go b/commands/dispatch.go index 0018c4c7..7d699396 100644 --- a/commands/dispatch.go +++ b/commands/dispatch.go @@ -112,6 +112,7 @@ func init() { viper.BindPFlags(rootCmd.PersistentFlags()) viper.BindPFlags(rootCmd.Flags()) + viper.SetDefault("auto_ctcp", true) viper.SetDefault("verify_certificates", true) viper.SetDefault("https.enabled", true) viper.SetDefault("https.port", 443) diff --git a/config.default.toml b/config.default.toml index 2f0cc937..f69168ed 100644 --- a/config.default.toml +++ b/config.default.toml @@ -3,6 +3,10 @@ address = "" port = 80 # Hex encode the users IP and use it as the ident hexIP = false +# Automatically reply to common CTCP messages +auto_ctcp = true +# Verify the certificate chain presented by the IRC server, if this check fails +# the user will be able to choose to still connect verify_certificates = true # Defaults for the client connect form @@ -63,11 +67,11 @@ secret = "" [dcc] # Receive files through DCC, the user gets to choose if they want to accept the file, -# the file then gets streamed to the user +# the file download then gets proxied to the user enabled = true [dcc.autoget] -# Instead of streaming the file to the user, dispatch automatically downloads +# Instead of proxying the file download directly to the user, dispatch automatically downloads # DCC files and sends a download link to the user once its done enabled = false # Delete the file after the user has downloaded it once @@ -75,7 +79,7 @@ delete = true # Delete the file after a certain time period of inactivity, not implemented yet delete_after = "30m" -# Strict-Transport-Security +# HTTP Strict-Transport-Security [https.hsts] enabled = false max_age = 31536000 diff --git a/config/config.go b/config/config.go index 58863ec7..ca6a15e0 100644 --- a/config/config.go +++ b/config/config.go @@ -13,6 +13,7 @@ type Config struct { Port string Dev bool HexIP bool + AutoCTCP bool `mapstructure:"auto_ctcp"` VerifyCertificates bool `mapstructure:"verify_certificates"` Headers map[string]string Defaults Defaults diff --git a/pkg/irc/client.go b/pkg/irc/client.go index eec27c1e..95d529fd 100644 --- a/pkg/irc/client.go +++ b/pkg/irc/client.go @@ -25,6 +25,8 @@ type Config struct { Account string Password string + // Automatically reply to common CTCP messages + AutoCTCP bool // Version is the reply to VERSION and FINGER CTCP messages Version string // Source is the reply to SOURCE CTCP messages diff --git a/pkg/irc/internal.go b/pkg/irc/internal.go index 0460e080..8ee44aa4 100644 --- a/pkg/irc/internal.go +++ b/pkg/irc/internal.go @@ -58,8 +58,10 @@ func (c *Client) handleMessage(msg *Message) { msg.meta = c.state.renameUser(msg.Sender, msg.LastParam()) case PRIVMSG: - if ctcp := msg.ToCTCP(); ctcp != nil { - c.handleCTCP(ctcp, msg) + if c.Config.AutoCTCP { + if ctcp := msg.ToCTCP(); ctcp != nil { + c.handleCTCP(ctcp, msg) + } } case MODE: diff --git a/server/irc.go b/server/irc.go index 329a710d..a24e35d9 100644 --- a/server/irc.go +++ b/server/irc.go @@ -30,7 +30,9 @@ func createNickInUseHandler(i *irc.Client, state *State) func(string) string { func connectIRC(network *storage.Network, state *State, srcIP []byte) *irc.Client { cfg := state.srv.Config() + ircCfg := network.IRCConfig() + ircCfg.AutoCTCP = cfg.AutoCTCP if ircCfg.TLS { ircCfg.TLSConfig = &tls.Config{