about summary refs log tree commit diff stats
path: root/main.go
diff options
context:
space:
mode:
authorBenny Morrison <benmorrison@ttm.sh>2019-03-14 04:14:36 -0400
committerBenny Morrison <benmorrison@ttm.sh>2019-03-14 04:14:36 -0400
commit35398ed0be2baac69978432f4ef4304f15d4b53e (patch)
treeb500588b83277765d16ec2991bc61e5aa2404193 /main.go
parent3e8bdbbff6ad95b3c06e6fe22035e0714fabcec9 (diff)
downloadgoofbot-35398ed0be2baac69978432f4ef4304f15d4b53e.tar.gz
moved config block to a function to keep it at the top of the file
Diffstat (limited to 'main.go')
-rw-r--r--main.go18
1 files 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)
 	}