Starting new Projects While Others aren't even Done... Sorry :)
I was bored, but still did not want to post the link to the onion service, which resulted in my searching for a new project idea. Since I set as a goal to really learn Rust, I wanted to build the next project in it (if it is not by far easier with another tool).
Having not that much experience with Rust yet, I aimed for quite beginner projects, which are useful for building core skills.
The list of potential next contenders includes:
- Snake
- Port Scanner
- TCP-Chat Application (Client & Server)
- CLI Calculator
- (I was searching for a really good, extensive one fitting my needs exactly for a long time, might be unrealistic for me to make such a big project, however)
- Extension features could include: functions, working with units, live fetched data (–> units like BTC Price in EUR, etc)
I currently lean towards building a port scanner first as a fun side project and then starting the rather large project of building the calculator which actually fits my needs. (Currently, as the calculator of choice, I use SpeedCrunch, but sometimes, I find it to have rather poor documentation and be quite unintuitive)
Having started the project of a tcp-port scanner, I found that it is actually quite easy to get a working prototype (which, of course, is not optimized at all). To optimize it now (with threads) I need to extend my own threading package (tokio “replacement”) to give me output when each thread finishes.
Actually, never mind. I will simply learn to use tokio, I think that might be the best use of my time, especially since I think implementing a good input-output system for a multi-threaded-pool is still a bit over my head... So just sticking with tokio for now.
Update: Okay, multi threaded small application using tokio is done, it was actually surprisingly easy (I guess that's what you get when you use actual good libraries / crates). The code is quite unsurprising and quite short (I expected it to be a much larger project than it finally turned out to be, but whatever...
use std::net::TcpStream;
use tokio;
async fn test_port(host: &str, port: u32) -> bool {
match TcpStream::connect(format!{"{host}:{port}"}) {
Ok(_) => true,
Err(_) => false,
}
}
#[tokio::main]
async fn main() {
let mut port_handles = vec![];
for port in 0..5000 {
port_handles.push((tokio::spawn(test_port("192.168.178.1", port)), port));
}
let mut open_ports = vec![];
for handle in port_handles {
let port = handle.1;
match handle.0.await.unwrap() {
true => {open_ports.push(port)},
_ => {},
}
}
println!{"{:?}", open_ports};
}