all repos — paprika @ 5e7478268e4bce3b6747afe20282d3bd2fe0a7a5

go rewrite of taigabot

add TLS support
Anthony DeDominic adedomin@gmail.com
Sun, 16 Jan 2022 12:23:17 -0500
commit

5e7478268e4bce3b6747afe20282d3bd2fe0a7a5

parent

1c51f1922297e7136d39f49dc2b7d002a25da1e4

1 files changed, 18 insertions(+), 7 deletions(-)

jump to
M main.gomain.go

@@ -1,6 +1,7 @@

package main import ( + "crypto/tls" "errors" "log" "net"

@@ -67,12 +68,6 @@ }

} func main() { - conn, err := net.Dial("tcp", config.C.Host) - if err != nil { - log.Fatal(err) - } - defer conn.Close() - ircConfig := irc.ClientConfig{ Nick: config.C.Nick, Pass: config.C.Pass,

@@ -81,13 +76,29 @@ Name: config.C.Nick,

Handler: irc.HandlerFunc(ircHandler), } + var err error database.DB.DB, err = database.Open() if err != nil { log.Fatal(err) } defer database.DB.Close() - client := irc.NewClient(conn, ircConfig) + var client *irc.Client + if !config.C.Tls { + conn, err := net.Dial("tcp", config.C.Host) + if err != nil { + log.Fatal(err) + } + defer conn.Close() + client = irc.NewClient(conn, ircConfig) + } else { + conn, err := tls.Dial("tcp", config.C.Host, nil) + if err != nil { + log.Fatal(err) + } + defer conn.Close() + client = irc.NewClient(conn, ircConfig) + } err = client.Run() if err != nil { log.Fatal(err)