~sircmpwn/hare-ssh

00c4c58fb744a7151249ed9a62ac37c966d6172b — Drew DeVault a month ago 450e585
net::ssh: further simplify client_read
1 files changed, 5 insertions(+), 16 deletions(-)

M net/ssh/client.ha
M net/ssh/client.ha => net/ssh/client.ha +5 -16
@@ 120,22 120,11 @@ export fn client_read(client: *client) (packet | io::EOF | error) = {
	// XXX: This function is probably useful both for clients and servers,
	// we could share it.

	let msglen = types::SIZE_MAX;
	if (len(client.rbuf) >= 5) {
		const pktlen = endian::begetu32(client.rbuf[..4]);
		const maclen = match (client.mac) {
		case null =>
			yield 0z;
		case let mac: *mac =>
			yield mac_digestsz(mac);
		};
		msglen = pktlen + maclen + 4;
		if (msglen >= MAX_PACKETSIZE) {
			return protoerror;
		};
	};
	if (msglen <= len(client.rbuf)) {
		return client_decode(client);
	match (client_decode(client)) {
	case errors::again =>
		yield;
	case let r: (packet | error) =>
		return r;
	};

	let buf: [os::BUFSIZ]u8 = [0...];