Simple Chat
- 5 Devlogs
- 20 Total hours
A TUI-based chat client for local networks, featuring encryption and host configuration (slightly) similar to ssh
A TUI-based chat client for local networks, featuring encryption and host configuration (slightly) similar to ssh
After a (way too long) pause, I’m finally working on Simple Chat again. I’ve added a packet enum, which wraps all possible kinds of data communication.
Basically, now everything that’s being sent has the same interface: serialize and deserialize. You don’t need to worry about what is in this packet, just serialize it, encrypt it and it works.
This means handshakes aren’t loose bytes being sent between client and server and held together by pure hopes and dream (im praying somebody gets the reference), but instead a proper packet, which can also now be encrypted.
Previously, there was also a big design flaw. If no message was being sent, you couldn’t tell if the others were just not sending anything or had already (uncleanly) disconnected. The TCP stream looked the same in both scenarios. Because of this, I’ve added a Packet::Heartbeat type. It contains no data, and if it gets received by any party, (almost) nothing happens. It’s sole purpose is to keep the stream alive.
Now with this, lets say we’re the server: a client doesn’t send a heartbeat twice. We now know that they’ve likely crashed or not properly disconnected in some other way. Because of this, we can now kick them instead of keeping a connection live.
I’ve rewritten the server using Tokio instead of Threads for improved performance and less server-side overhead.
It utilizes Rust’s async implementation with futures to create a much more lightweight alternative to threads. Basically, you can summon multiple tasks and instead of them being full threads with seperate 8MB stacks and so on, they have way less context switching overhead and a much smaller stack per instance.
In the initial handshake, the client provides its name to the server. If the server receives a message with the wrong name from that client, it will replace the name with the originally given one.
I’m still working on finishing up encryption for all messages and the initial handshake.
So… it kinda works????
The client AND server, the TUI, the new message structs and all of that work now.
Chat, System)SystemMessages to broadcast client connect/disconnect events~/.lan-chat)