➕ add the multi-call server
This exe can act as both a PTTH and PTTH_QUIC end server. It's only 17 MB, which is a big improvement over the 15 + 15 for shipping both servers as their own exesmain
parent
97fc2c74d4
commit
f44613540e
|
@ -1202,6 +1202,18 @@ dependencies = [
|
||||||
"tokio",
|
"tokio",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ptth_multi_call_server"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"ptth_server",
|
||||||
|
"quic_demo",
|
||||||
|
"tokio",
|
||||||
|
"tracing",
|
||||||
|
"tracing-subscriber",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ptth_quic_client_gui"
|
name = "ptth_quic_client_gui"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
pub use std::{
|
pub use std::{
|
||||||
|
ffi::OsString,
|
||||||
io::Write,
|
io::Write,
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
time::{Duration, Instant},
|
time::{Duration, Instant},
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
[package]
|
||||||
|
name = "ptth_multi_call_server"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["Trish"]
|
||||||
|
edition = "2018"
|
||||||
|
license = "AGPL-3.0"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
anyhow = "1.0.38"
|
||||||
|
ptth_server = { path = "../ptth_server" }
|
||||||
|
quic_demo = { path = "../../prototypes/quic_demo" }
|
||||||
|
tokio = { version = "1.8.1", features = ["full"] }
|
||||||
|
tracing-subscriber = "0.2.16"
|
||||||
|
tracing = "0.1.25"
|
|
@ -0,0 +1,51 @@
|
||||||
|
use std::{
|
||||||
|
iter::FromIterator,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum Subcommand {
|
||||||
|
PtthServer,
|
||||||
|
PtthQuicEndServer,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn parse_subcommand (name: &str) -> Option <Subcommand>
|
||||||
|
{
|
||||||
|
if name.ends_with ("ptth_server") || name.ends_with ("ptth_server.exe")
|
||||||
|
{
|
||||||
|
Some (Subcommand::PtthServer)
|
||||||
|
}
|
||||||
|
else if name.ends_with ("ptth_quic_end_server") || name.ends_with ("ptth_quic_end_server.exe")
|
||||||
|
{
|
||||||
|
Some (Subcommand::PtthQuicEndServer)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::main]
|
||||||
|
async fn main () -> anyhow::Result <()> {
|
||||||
|
tracing_subscriber::fmt::init ();
|
||||||
|
|
||||||
|
let args = Vec::from_iter (std::env::args_os ());
|
||||||
|
|
||||||
|
let arg_0 = args [0].to_str ().expect ("exe name should be valid UTF-8");
|
||||||
|
match parse_subcommand (arg_0) {
|
||||||
|
Some (Subcommand::PtthServer) => return ptth_server::executable::main (&args).await,
|
||||||
|
Some (Subcommand::PtthQuicEndServer) => return quic_demo::executable_end_server::main (&args).await,
|
||||||
|
_ => (),
|
||||||
|
}
|
||||||
|
|
||||||
|
let arg_1 = match args.get (1) {
|
||||||
|
Some (x) => x,
|
||||||
|
None => anyhow::bail! ("Subcommand must be the first argument if it's not the exe name"),
|
||||||
|
};
|
||||||
|
|
||||||
|
let arg_1 = arg_1.to_str ().expect ("subcommand should be valid UTF-8");
|
||||||
|
match parse_subcommand (arg_1) {
|
||||||
|
Some (Subcommand::PtthServer) => return ptth_server::executable::main (&args [1..]).await,
|
||||||
|
Some (Subcommand::PtthQuicEndServer) => return quic_demo::executable_end_server::main (&args [1..]).await,
|
||||||
|
_ => (),
|
||||||
|
}
|
||||||
|
|
||||||
|
anyhow::bail! ("Subcommand should be provided in exe name or first argument, e.g. `./ptth_multi_call_server ptth_server`");
|
||||||
|
}
|
|
@ -1,10 +1,12 @@
|
||||||
#![warn (clippy::pedantic)]
|
use std::{
|
||||||
|
iter::FromIterator,
|
||||||
|
};
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main () -> anyhow::Result <()> {
|
async fn main () -> anyhow::Result <()> {
|
||||||
tracing_subscriber::fmt::init ();
|
tracing_subscriber::fmt::init ();
|
||||||
|
|
||||||
let args = std::env::args_os ();
|
let args = Vec::from_iter (std::env::args_os ());
|
||||||
|
|
||||||
ptth_server::executable::main (args).await
|
ptth_server::executable::main (&args).await
|
||||||
}
|
}
|
||||||
|
|
|
@ -490,7 +490,7 @@ pub mod executable {
|
||||||
prelude::*,
|
prelude::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub async fn main (args: std::env::ArgsOs) -> anyhow::Result <()> {
|
pub async fn main (args: &[OsString]) -> anyhow::Result <()> {
|
||||||
let opt = Opt::from_iter (args);
|
let opt = Opt::from_iter (args);
|
||||||
let asset_root = opt.asset_root;
|
let asset_root = opt.asset_root;
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
|
use std::{
|
||||||
|
iter::FromIterator,
|
||||||
|
};
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main () -> anyhow::Result <()> {
|
async fn main () -> anyhow::Result <()> {
|
||||||
tracing_subscriber::fmt::init ();
|
tracing_subscriber::fmt::init ();
|
||||||
|
|
||||||
let args = std::env::args_os ();
|
let args = Vec::from_iter (std::env::args_os ());
|
||||||
|
|
||||||
quic_demo::executable_end_server::main (args).await
|
quic_demo::executable_end_server::main (&args).await
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ struct Opt {
|
||||||
cert_url: Option <String>,
|
cert_url: Option <String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn main (args: std::env::ArgsOs) -> anyhow::Result <()> {
|
pub async fn main (args: &[OsString]) -> anyhow::Result <()> {
|
||||||
let opt = Arc::new (Opt::from_iter (args));
|
let opt = Arc::new (Opt::from_iter (args));
|
||||||
|
|
||||||
let server_cert = match opt.cert_url.as_ref () {
|
let server_cert = match opt.cert_url.as_ref () {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
pub use std::{
|
pub use std::{
|
||||||
collections::*,
|
collections::*,
|
||||||
|
ffi::OsString,
|
||||||
net::SocketAddr,
|
net::SocketAddr,
|
||||||
sync::{
|
sync::{
|
||||||
Arc,
|
Arc,
|
||||||
|
|
Loading…
Reference in New Issue