From 35398ed0be2baac69978432f4ef4304f15d4b53e Mon Sep 17 00:00:00 2001 From: Benny Morrison Date: Thu, 14 Mar 2019 04:14:36 -0400 Subject: moved config block to a function to keep it at the top of the file --- main.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index ef324a7..a865c47 100644 --- a/main.go +++ b/main.go @@ -3,11 +3,14 @@ package main import ( "crypto/tls" "log" + "net" "gopkg.in/irc.v3" ) -func main() { +func setConfs() (bool, irc.ClientConfig, tls.Config) { + //set this to false if you need + useTLS := true // set all the necessities // also specifies the initial channel @@ -34,13 +37,24 @@ func main() { } // set up the tls params for the connection + // see: https://golang.org/pkg/crypto/tls/#Config tlsconfig := tls.Config{ InsecureSkipVerify: false, //set to true if you want to be dumb RootCAs: nil, //use the OS's root CAs PreferServerCipherSuites: true, //use the server's cipher list } + return useTLS, config, tlsconfig +} - conn, err := tls.Dial("tcp", "irc.tilde.chat:6697", &tlsconfig) +func main() { + useTLS, config, tlsconfig := setConfs() + + switch useTLS { + case true: + conn, err := tls.Dial("tcp", "irc.tilde.chat:6697", &tlsconfig) + case false: + conn, err := net.Dial("tcp", "irc.tilde.chat:6667") + } if err != nil { log.Fatalln(err) } -- cgit 1.4.1-2-gfad0