mirror of
https://github.com/MeexReay/sRAC.git
synced 2025-05-06 13:18:03 +03:00
some fixes and improvements
This commit is contained in:
parent
71946809b7
commit
5296399231
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/target
|
7
Cargo.lock
generated
Normal file
7
Cargo.lock
generated
Normal 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"
|
@ -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
|
||||||
|
|
||||||
|
10
README.md
10
README.md
@ -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
|
||||||
|
```
|
@ -1,4 +0,0 @@
|
|||||||
host: 127.0.0.1:42666
|
|
||||||
|
|
||||||
threadpool: 10
|
|
||||||
timeout: 5 # in seconds
|
|
28
src/main.rs
28
src/main.rs
@ -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);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user