about summary refs log tree commit diff
path: root/fun
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2021-05-22T13·56+0200
committertazjin <mail@tazj.in>2021-05-22T17·54+0000
commita7b168ec9a96d5fbd3aa4dc271f972e767e1758b (patch)
tree96bf89dec5832a218969d0231aaa2c6e901e5a75 /fun
parent1aad1d9beb8acb5c72c56abd97a4fbaa0c8ce72a (diff)
feat(clbot): Add a flag to disable TLS connections r/2603
The local bouncer on whitby does not use TLS.

Change-Id: Idf9c56f94129b0ddce620eb559082a8f2f088078
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3128
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
Diffstat (limited to 'fun')
-rw-r--r--fun/clbot/clbot.go16
1 files changed, 14 insertions, 2 deletions
diff --git a/fun/clbot/clbot.go b/fun/clbot/clbot.go
index bde8f1f994..914fa03705 100644
--- a/fun/clbot/clbot.go
+++ b/fun/clbot/clbot.go
@@ -6,6 +6,7 @@ import (
 	"flag"
 	"fmt"
 	"io/ioutil"
+	"net"
 	"os"
 	"os/signal"
 	"strings"
@@ -28,6 +29,7 @@ var (
 	gerritAuthKeyPath  = flag.String("gerrit_ssh_auth_key", "", "Gerrit SSH private key path")
 
 	ircServer    = flag.String("irc_server", "chat.freenode.net:7000", "IRC server to connect to")
+	ircTls       = flag.Bool("irc_tls", false, "Does the server connection need TLS?")
 	ircNick      = flag.String("irc_nick", "clbot", "Nick to use when connecting to IRC")
 	ircUser      = flag.String("irc_user", "clbot", "User string to use for IRC")
 	ircName      = flag.String("irc_name", "clbot", "Name string to use for IRC")
@@ -111,11 +113,21 @@ func runIRC(ctx context.Context, ircCfg irc.ClientConfig, sendMsg <-chan string)
 
 		(func() {
 			connectedStart := time.Now()
-			ircConn, err := tls.Dial("tcp", *ircServer, nil)
+
+			var ircConn net.Conn
+			var err error
+
+			if *ircTls {
+				ircConn, err = tls.Dial("tcp", *ircServer, nil)
+			} else {
+				ircConn, err = net.Dial("tcp", *ircServer)
+			}
+
 			if err != nil {
-				log.Errorf("connecting to IRC at tcp/%s: %v", *ircServer, err)
+				log.Errorf("connecting to IRC at tcp/%s (tls: %v): %v", *ircServer, *ircTls, err)
 				return
 			}
+
 			ircClient := irc.NewClient(ircConn, ircCfg)
 			ircClientCtx, cancel := context.WithCancel(ctx)
 			defer cancel()