about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorBenny Morrison <benmorrison@ttm.sh>2019-03-14 03:54:00 -0400
committerBenny Morrison <benmorrison@ttm.sh>2019-03-14 03:54:00 -0400
commit3e8bdbbff6ad95b3c06e6fe22035e0714fabcec9 (patch)
treea10816e25581e38cb78d9880142fbb92c44f3b33
parent4810fbc0d1f4d7788c344879afeb18c71692165d (diff)
downloadgoofbot-3e8bdbbff6ad95b3c06e6fe22035e0714fabcec9.tar.gz
tls connection to IRC server
-rw-r--r--main.go13
1 files changed, 10 insertions, 3 deletions
diff --git a/main.go b/main.go
index 006d3d0..ef324a7 100644
--- a/main.go
+++ b/main.go
@@ -1,8 +1,8 @@
 package main
 
 import (
+	"crypto/tls"
 	"log"
-	"net"
 
 	"gopkg.in/irc.v3"
 )
@@ -20,7 +20,7 @@ func main() {
 		Handler: irc.HandlerFunc(func(c *irc.Client, m *irc.Message) {
 			if m.Command == "001" {
 				// 001 = welcome
-				c.Write("JOIN #institute")
+				c.Write("JOIN #institute") //initial channel join
 			} else if m.Command == "PRIVMSG" && c.FromChannel(m) {
 				c.WriteMessage(&irc.Message{
 					Command: "PRIVMSG",
@@ -33,7 +33,14 @@ func main() {
 		}),
 	}
 
-	conn, err := net.Dial("tcp", "irc.tilde.chat:6697")
+	// set up the tls params for the connection
+	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
+	}
+
+	conn, err := tls.Dial("tcp", "irc.tilde.chat:6697", &tlsconfig)
 	if err != nil {
 		log.Fatalln(err)
 	}