some fixes and improvements

This commit is contained in:
MeexReay 2025-04-14 16:48:00 +03:00
parent 71946809b7
commit 5296399231
6 changed files with 44 additions and 10 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/target

7
Cargo.lock generated Normal file
View File

@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "sRAC"
version = "0.1.0"

View File

@ -55,9 +55,7 @@ Client sends:
Server sends: Server sends:
- `0x00` if successful or `0x01` if the username is already taken - `0x01` if the username is already taken
*legacy servers send nothing on successful registration*
## Sending authorized messages ## Sending authorized messages

View File

@ -1,2 +1,10 @@
# sRAC # sRAC
server for RAC simple server for RAC
## Usage
```bash
git clone https://github.com/MeexReay/sRAC
cd sRAC
cargo run 127.0.0.1:42666
```

View File

@ -1,4 +0,0 @@
host: 127.0.0.1:42666
threadpool: 10
timeout: 5 # in seconds

View File

@ -1,3 +1,27 @@
fn main() { use std::{env::args, error::Error, io::Read, net::{TcpListener, TcpStream}, thread};
println!("Hello, world!");
fn accept_stream(mut stream: TcpStream) -> Result<(), Box<dyn Error>> {
let mut buf = vec![0; 4096];
stream.read(&mut buf)?;
if buf[0]
Ok(())
}
fn main() {
let addr = args().skip(1).next().expect("needs at least 1 argument (host:port)");
let listener = TcpListener::bind(&addr).expect("error trying bind to the provided addr");
println!("Server started on {}", &addr);
for stream in listener.incoming() {
let Ok(stream) = stream else { continue };
thread::spawn(move || {
let _ = accept_stream(stream);
});
}
} }