Hack in SSL support

This commit is contained in:
lye 2012-03-18 16:51:13 -05:00
parent 67c1c92623
commit b62f72a746

35
irc.go
View File

@ -10,6 +10,7 @@ import (
"net"
"strings"
"time"
"crypto/tls"
)
const (
@ -166,15 +167,7 @@ func (i *IRCConnection) Loop() {
<-i.syncwriter
}
func (i *IRCConnection) Connect(server string) error {
i.server = server
fmt.Printf("Connecting to %s\n", i.server)
var err error
i.socket, err = net.Dial("tcp", i.server)
if err != nil {
return err
}
fmt.Printf("Connected to %s (%s)\n", i.server, i.socket.RemoteAddr())
func (i *IRCConnection) postConnect() error {
i.pread = make(chan string, 100)
i.pwrite = make(chan string, 100)
i.Error = make(chan error, 10)
@ -191,6 +184,30 @@ func (i *IRCConnection) Connect(server string) error {
return nil
}
func (i *IRCConnection) Connect(server string) error {
i.server = server
fmt.Printf("Connecting to %s\n", i.server)
var err error
i.socket, err = net.Dial("tcp", i.server)
if err != nil {
return err
}
fmt.Printf("Connected to %s (%s)\n", i.server, i.socket.RemoteAddr())
return i.postConnect()
}
func (i *IRCConnection) ConnectSSL(server string) error {
i.server = server
fmt.Printf("Connecting to %s over SSL\n", i.server)
var err error
i.socket, err = tls.Dial("tcp", i.server, nil)
if err != nil {
return err
}
fmt.Printf("Connected to %s (%s) over SSL\n", i.server, i.socket.RemoteAddr())
return i.postConnect()
}
func IRC(nick, user string) *IRCConnection {
irc := new(IRCConnection)
irc.registered = false