谁能给我一个如何与 IRC 服务器建立 SSL 连接的例子吗?
我曾尝试阅读有关 SslStream
的内容,但我就是不明白。我可以使用以下方法在没有 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();
}
}
}
}
最佳答案
试试这个:
conn, err = tls.Dial("tcp", HOST+":"+PORT, &tls.Config{InsecureSkipVerify: true})
关于c# - 通过 SSL 连接到 IRC,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26531374/