Added port argument
This commit is contained in:
parent
80e2e4044c
commit
c79c72f909
2 changed files with 13 additions and 1 deletions
|
@ -4,4 +4,5 @@ version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
clap = { version = "4.5.31", features = ["derive"] }
|
||||||
time = { version = "0.3.37", features = ["formatting", "local-offset"] }
|
time = { version = "0.3.37", features = ["formatting", "local-offset"] }
|
||||||
|
|
13
src/main.rs
13
src/main.rs
|
@ -6,6 +6,15 @@ use std::net::{TcpListener, TcpStream};
|
||||||
use std::random;
|
use std::random;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use std::thread::{self, JoinHandle, sleep};
|
use std::thread::{self, JoinHandle, sleep};
|
||||||
|
use clap::Parser;
|
||||||
|
|
||||||
|
#[derive(Parser, Debug)]
|
||||||
|
#[command(version, about, long_about = None)]
|
||||||
|
struct Args {
|
||||||
|
/// Port to bind on.
|
||||||
|
#[arg(short, long, default_value_t = 7867)]
|
||||||
|
port: u16,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq)]
|
#[derive(Clone, PartialEq, Eq)]
|
||||||
enum UserStatus {
|
enum UserStatus {
|
||||||
|
@ -411,7 +420,9 @@ fn handle_client(mut stream: TcpStream, channel: Channel) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> std::io::Result<()> {
|
fn main() -> std::io::Result<()> {
|
||||||
let listener = TcpListener::bind("0.0.0.0:7867")?;
|
let args = Args::parse();
|
||||||
|
|
||||||
|
let listener = TcpListener::bind(format!("0.0.0.0:{}", args.port))?;
|
||||||
let channel: Channel = Arc::new(Mutex::new(UnwrappedChannel {
|
let channel: Channel = Arc::new(Mutex::new(UnwrappedChannel {
|
||||||
name: "Rawnetchat".to_string(),
|
name: "Rawnetchat".to_string(),
|
||||||
messages: vec![],
|
messages: vec![],
|
||||||
|
|
Loading…
Add table
Reference in a new issue