Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial attempt to upgrade Quinn, unfortunately blocked on axum_server. #165

Merged
merged 10 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,218 changes: 753 additions & 465 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ members = [
]
resolver = "2"

[workspace.dependencies]
web-transport = "0.3"
env_logger = "0.11"
log = { version = "0.4", features = ["std"] }

# Use debug symbols in production until things are more stable
[profile.release]
debug = true
14 changes: 7 additions & 7 deletions moq-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors = ["Luke Curley"]
repository = "https://github.com/kixelated/moq-rs"
license = "MIT OR Apache-2.0"

version = "0.1.2"
version = "0.2.0"
edition = "2021"

keywords = ["quic", "http3", "webtransport", "media", "live"]
Expand All @@ -16,12 +16,12 @@ categories = ["multimedia", "network-programming", "web-programming"]

[dependencies]
# HTTP server
axum = "0.6"
hyper = { version = "0.14", features = ["full"] }
axum = "0.7"
hyper = { version = "1.4", features = ["full"] }
tokio = { version = "1", features = ["full"] }

# HTTP client
reqwest = { version = "0.11", features = ["json", "rustls-tls"] }
reqwest = { version = "0.12", features = ["json", "rustls-tls"] }

# JSON encoding
serde = "1"
Expand All @@ -31,13 +31,13 @@ serde_json = "1"
clap = { version = "4", features = ["derive"] }

# Database
redis = { version = "0.23", features = [
redis = { version = "0.25", features = [
"tokio-rustls-comp",
"connection-manager",
] }
url = { version = "2", features = ["serde"] }

# Error handling
log = "0.4"
env_logger = "0.9"
log = { workspace = true }
env_logger = { workspace = true }
thiserror = "1"
3 changes: 3 additions & 0 deletions moq-api/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ pub enum ApiError {

#[error("url error: {0}")]
Url(#[from] url::ParseError),

#[error("io error: {0}")]
Io(#[from] std::io::Error),
}
9 changes: 3 additions & 6 deletions moq-api/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ impl Server {

// Create the redis client.
let redis = redis::Client::open(self.config.redis)?;
let redis = redis
.get_tokio_connection_manager() // TODO get_tokio_connection_manager_with_backoff?
.await?;
let redis = redis.get_connection_manager().await?;

let app = Router::new()
.route(
Expand All @@ -57,9 +55,8 @@ impl Server {

log::info!("serving requests: bind={}", self.config.bind);

axum::Server::bind(&self.config.bind)
.serve(app.into_make_service())
.await?;
let listener = tokio::net::TcpListener::bind(&self.config.bind).await?;
axum::serve(listener, app.into_make_service()).await?;

Ok(())
}
Expand Down
11 changes: 3 additions & 8 deletions moq-clock/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ categories = ["multimedia", "network-programming", "web-programming"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
moq-native = { path = "../moq-native", version = "0.2" }
moq-native = { path = "../moq-native", version = "0.3" }
moq-transport = { path = "../moq-transport", version = "0.5" }

# QUIC
Expand All @@ -25,16 +25,11 @@ tokio = { version = "1", features = ["full"] }

# CLI, logging, error handling
clap = { version = "4", features = ["derive"] }
log = { version = "0.4", features = ["std"] }
env_logger = "0.9"
log = { workspace = true }
env_logger = { workspace = true }
anyhow = { version = "1", features = ["backtrace"] }
tracing = "0.1"
tracing-subscriber = "0.3"

# CLOCK STUFF
chrono = "0.4"

[build-dependencies]
clap = { version = "4", features = ["derive"] }
clap_mangen = "0.2"
url = "2"
8 changes: 4 additions & 4 deletions moq-dir/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ keywords = ["quic", "http3", "webtransport", "media", "live"]
categories = ["multimedia", "network-programming", "web-programming"]

[dependencies]
moq-native = { path = "../moq-native", version = "0.2" }
moq-native = { path = "../moq-native", version = "0.3" }
moq-transport = { path = "../moq-transport", version = "0.5" }

# QUIC
web-transport = "0.2"
web-transport = { workspace = true }
bytes = "1"

# Async stuff
Expand All @@ -30,7 +30,7 @@ anyhow = { version = "1", features = ["backtrace"] }
clap = { version = "4", features = ["derive"] }

# Logging
log = { version = "0.4", features = ["std"] }
env_logger = "0.9"
log = { workspace = true }
env_logger = { workspace = true }
tracing = "0.1"
tracing-subscriber = "0.3"
30 changes: 11 additions & 19 deletions moq-native/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,30 @@ authors = ["Luke Curley"]
repository = "https://github.com/kixelated/moq-rs"
license = "MIT OR Apache-2.0"

version = "0.2.2"
version = "0.3.0"
edition = "2021"

keywords = ["quic", "http3", "webtransport", "media", "live"]
categories = ["multimedia", "network-programming", "web-programming"]

[dependencies]
moq-transport = { path = "../moq-transport", version = "0.5" }
web-transport = "0.2"

# QUIC
quinn = "0.10"
web-transport-quinn = "0.2"
url = "2"

# Crypto
ring = "0.16"
rustls = { version = "0.21", features = ["dangerous_configuration"] }
rustls-pemfile = "1"
rustls-native-certs = "0.6"
web-transport = { workspace = true }
web-transport-quinn = "0.3"

rustls = { version = "0.23", features = ["ring"] }
rustls-pemfile = "2"
rustls-native-certs = "0.7"
quinn = { version = "0.11", features = ["ring"] }
ring = "0.17"
webpki = "0.22"

hex = "0.4"
url = "2"

# Async stuff
tokio = { version = "1", features = ["full"] }
futures = "0.3"

# Error handling
anyhow = { version = "1", features = ["backtrace"] }

# CLI
clap = { version = "4", features = ["derive"] }

# Logging
log = { version = "0.4", features = ["std"] }
26 changes: 18 additions & 8 deletions moq-native/src/quic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,18 @@ impl Endpoint {
transport.mtu_discovery_config(None); // Disable MTU discovery
let transport = Arc::new(transport);

let server_config = config.tls.server.map(|mut server| {
server.alpn_protocols = vec![web_transport_quinn::ALPN.to_vec(), moq_transport::setup::ALPN.to_vec()];
server.key_log = Arc::new(rustls::KeyLogFile::new());
let mut server_config = quinn::ServerConfig::with_crypto(Arc::new(server));
server_config.transport_config(transport.clone());
server_config
});
let mut server_config = None;

if let Some(mut config) = config.tls.server {
config.alpn_protocols = vec![web_transport_quinn::ALPN.to_vec(), moq_transport::setup::ALPN.to_vec()];
config.key_log = Arc::new(rustls::KeyLogFile::new());

let config: quinn::crypto::rustls::QuicServerConfig = config.try_into()?;
let mut config = quinn::ServerConfig::with_crypto(Arc::new(config));
config.transport_config(transport.clone());

server_config = Some(config);
}

// There's a bit more boilerplate to make a generic endpoint.
let runtime = quinn::default_runtime().context("no async runtime")?;
Expand Down Expand Up @@ -112,7 +117,9 @@ impl Server {
}
}

async fn accept_session(mut conn: quinn::Connecting) -> anyhow::Result<web_transport::Session> {
async fn accept_session(conn: quinn::Incoming) -> anyhow::Result<web_transport::Session> {
let mut conn = conn.accept()?;

let handshake = conn
.handshake_data()
.await?
Expand Down Expand Up @@ -184,7 +191,10 @@ impl Client {
"moqt" => moq_transport::setup::ALPN.to_vec(),
_ => anyhow::bail!("url scheme must be 'https' or 'moqt'"),
}];

config.key_log = Arc::new(rustls::KeyLogFile::new());

let config: quinn::crypto::rustls::QuicClientConfig = config.try_into()?;
let mut config = quinn::ClientConfig::new(Arc::new(config));
config.transport_config(self.transport.clone());

Expand Down
Loading
Loading