【问题标题】:Making a connection to IRC through SSL通过 SSL 连接到 IRC
【发布时间】:2014-10-23 15:13:53
【问题描述】:

谁能告诉我一个如何与 IRC 服务器建立 SSL 连接的示例?

我曾尝试阅读有关SslStreams 的信息,但我就是不明白。我可以在没有 SSL 的情况下使用这个连接到 IRC:

        sock.Connect(server, port);
        if (!sock.Connected) {
            Console.WriteLine("Failed to connect!");
            return;
        }
        input = new System.IO.StreamReader(sock.GetStream());
        output = new System.IO.StreamWriter(sock.GetStream());

        output.Write("USER " + nick + " 0 * :" + owner + "\r\n" + "NICK " + nick + "\r\n");
        output.Flush();

        //Process each line received from irc server
        for (buf = input.ReadLine(); ; buf = input.ReadLine()) {
            //Display received irc message
            //Console.WriteLine(buf);
            if (buf.Split(' ')[1] == "332") {
                Console.WriteLine(buf.Split(new char[] { ' ' }, 5)[4]);
            }
            //Send pong reply to any ping messages
            if (buf.StartsWith("PING ")) {
                output.Write(buf.Replace("PING", "PONG") + "\r\n"); output.Flush();
            }
            if (buf[0] != ':') continue;
            if (buf.Split(' ')[1] == "001") {
                output.Write(
                    "MODE " + nick + " \r\n" +
                    "JOIN " + chan + "\r\n"
                );
                output.Flush();
            }
        }
    }
}

【问题讨论】:

    标签: c# ssl irc


    【解决方案1】:

    试试这个:

    conn, err = tls.Dial("tcp", HOST+":"+PORT, &tls.Config{InsecureSkipVerify: true})
    

    【讨论】:

      猜你喜欢
      • 2019-06-04
      • 2014-07-17
      • 2012-08-30
      • 2014-06-17
      • 1970-01-01
      • 1970-01-01
      • 2011-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多