Jelajahi Sumber

Merged tls into net.Conn.

Steve Thielemann 3 tahun lalu
induk
melakukan
e80a3c34c9
1 mengubah file dengan 15 tambahan dan 13 penghapusan
  1. 15 13
      irc-client.go

+ 15 - 13
irc-client.go

@@ -55,7 +55,6 @@ type IRCConfig struct {
 	RejoinDelay    int      `json: RejoinDelay`    // ms to rejoin
 	MyNick         string
 	Socket         net.Conn
-	TLSSocket      *tls.Conn
 	Reader         *bufio.Reader
 	ReadChannel    chan IRCMsg
 	ReadEvents     []string
@@ -101,12 +100,12 @@ func (Config *IRCConfig) Connect() bool {
 			tlsConfig.InsecureSkipVerify = true
 		}
 
-		Config.TLSSocket, err = tls.Dial("tcp", Config.Hostname+":"+strconv.Itoa(Config.Port), &tlsConfig)
+		Config.Socket, err = tls.Dial("tcp", Config.Hostname+":"+strconv.Itoa(Config.Port), &tlsConfig)
 		if err != nil {
 			log.Fatal("tls.Dial:", err)
 		}
 		// Config.Writer = bufio.NewWriter(Config.TLSSocket)
-		Config.Reader = bufio.NewReader(Config.TLSSocket)
+		Config.Reader = bufio.NewReader(Config.Socket)
 	} else {
 		Config.Socket, err = net.Dial("tcp", Config.Hostname+":"+strconv.Itoa(Config.Port))
 		if err != nil {
@@ -146,11 +145,13 @@ func (Config *IRCConfig) write(output string) error {
 	var err error
 	log.Println(">>", output)
 	output += "\r\n"
-	if Config.UseTLS {
-		_, err = Config.TLSSocket.Write([]byte(output))
-	} else {
-		_, err = Config.Socket.Write([]byte(output))
-	}
+	/*
+		if Config.UseTLS {
+			_, err = Config.TLSSocket.Write([]byte(output))
+		} else {
+	*/
+	_, err = Config.Socket.Write([]byte(output))
+
 	return err
 }
 
@@ -243,11 +244,12 @@ func (Config *IRCConfig) WriterRoutine() {
 }
 
 func (Config *IRCConfig) Close() {
-	if Config.UseTLS {
-		Config.TLSSocket.Close()
-	} else {
-		Config.Socket.Close()
-	}
+	/*
+		if Config.UseTLS {
+			Config.TLSSocket.Close()
+		} else {
+	*/
+	Config.Socket.Close()
 }
 
 func IRCParse(line string) []string {