Make TLS work.
This commit is contained in:
parent
55fc4c7260
commit
cb88f3c3b3
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
31
src/main.zig
31
src/main.zig
|
@ -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;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue