Make TLS work.

This commit is contained in:
Kitteh 2021-06-05 09:32:04 +01:00
parent 55fc4c7260
commit cb88f3c3b3
2 changed files with 21 additions and 13 deletions

View file

@ -50,6 +50,7 @@ pub const Client = struct {
.cert_verifier = .none, .cert_verifier = .none,
.ciphersuites = tls.ciphersuites.all, .ciphersuites = tls.ciphersuites.all,
}, "quassel.owo.monster"); }, "quassel.owo.monster");
tlsConnected = true;
} }
} }
@ -137,8 +138,8 @@ pub const Client = struct {
try s.writeFrame(data); try s.writeFrame(data);
var varient = try s.readFrame(); var varient = try s.readFrame();
tlsAllowed = varient.QVariantMap.get("SupportSsl").?.Byte == 1;
prettyPrintQVariant(varient, 0); prettyPrintQVariant(varient, 0);
tlsAllowed = varient.QVariantMap.get("SupportSsl").?.Byte == 1;
freeQVariant(varient, s.allocator); freeQVariant(varient, s.allocator);
} }

View file

@ -18,18 +18,25 @@ pub fn main() !void {
std.debug.print("host={s} port={d}\n", .{ host, portInt }); std.debug.print("host={s} port={d}\n", .{ host, portInt });
var sock = try std.net.tcpConnectToHost(allocator, host, portInt);
var client = initClient(allocator, &sock);
try client.handshake();
try client.quassel_init_packet();
try client.quassel_login(username, password);
while (true) { while (true) {
client.read_quassel_packet() catch |err| { var sock = try std.net.tcpConnectToHost(allocator, host, portInt);
if (err == error.DecodeError) { var client = initClient(allocator, &sock);
std.debug.print("Decode Error.\n", .{}); try client.handshake();
} else { try client.quassel_init_packet();
return err; try client.quassel_login(username, password);
}
}; while (true) {
client.read_quassel_packet() catch |err| {
if (err == error.DecodeError) {
std.debug.print("Decode Error.\n", .{});
} else if (err == error.EndOfStream) {
std.debug.print("EOS.\n", .{});
std.time.sleep(1000 * std.time.ns_per_ms);
continue;
} else {
return err;
}
};
}
} }
} }