Skip to content
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
145 changes: 96 additions & 49 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ kanal = { version = "0.1.1", default-features = false }
c-ares = { version = "12.0", default-features = false }
c-ares-resolver = { version = "11.0", default-features = false }
c-ares-sys = { version = "11.0", default-features = false }
hickory-proto = { version = "0.25", default-features = false }
hickory-client = { version = "0.25", default-features = false }
hickory-proto = { version = "0.26.0", default-features = false }
hickory-net = { version = "0.26.0", default-features = false }
#
capnp-rpc = "0.25"
capnp = "0.25"
Expand Down
4 changes: 3 additions & 1 deletion lib/vey-hickory-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ rust-version.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
hickory-proto = { workspace = true, features = ["tokio"] }
anyhow.workspace = true
hickory-proto.workspace = true
hickory-net = { workspace = true, features = ["tokio"] }
futures-util.workspace = true
http.workspace = true
h2.workspace = true
Expand Down
7 changes: 4 additions & 3 deletions lib/vey-hickory-client/src/connect/quinn.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
/*
* SPDX-License-Identifier: Apache-2.0
* Copyright 2024-2025 ByteDance and/or its affiliates.
* Copyright 2026 VEY-OSS developers.
*/

use std::sync::Arc;

use hickory_proto::ProtoError;
use hickory_net::NetError;
use quinn::crypto::rustls::QuicClientConfig;
use quinn::{Connection, Endpoint, EndpointConfig, TokioRuntime};
use rustls::ClientConfig;

use vey_socket::UdpConnectInfo;

pub(crate) async fn quic_connect(
connect_info: UdpConnectInfo,
connect_info: &UdpConnectInfo,
mut tls_config: ClientConfig,
tls_name: &str,
alpn_protocol: &'static [u8],
) -> Result<Connection, ProtoError> {
) -> Result<Connection, NetError> {
let sock = connect_info.udp_connect()?;

let endpoint_config = EndpointConfig::default(); // TODO set max payload size
Expand Down
15 changes: 11 additions & 4 deletions lib/vey-hickory-client/src/connect/rustls.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
/*
* SPDX-License-Identifier: Apache-2.0
* Copyright 2024-2025 ByteDance and/or its affiliates.
* Copyright 2026 VEY-OSS developers.
*/

use std::sync::Arc;

use hickory_proto::ProtoError;
use anyhow::anyhow;
use rustls::ClientConfig;
use rustls_pki_types::ServerName;
use tokio::net::TcpStream;
Expand All @@ -19,15 +20,21 @@ pub(crate) async fn tls_connect(
mut tls_config: ClientConfig,
tls_name: ServerName<'static>,
alpn_protocol: &'static [u8],
) -> Result<TlsStream<TcpStream>, ProtoError> {
let tcp_stream = connect_info.tcp_connect().await?;
) -> anyhow::Result<TlsStream<TcpStream>> {
let tcp_stream = connect_info
.tcp_connect()
.await
.map_err(|e| anyhow!("tcp connect to {} failed: {e}", connect_info.server))?;

if tls_config.alpn_protocols.is_empty() {
tls_config.alpn_protocols = vec![alpn_protocol.to_vec()];
}

let tls_connector = TlsConnector::from(Arc::new(tls_config));
let tls_stream = tls_connector.connect(tls_name, tcp_stream).await?;
let tls_stream = tls_connector
.connect(tls_name, tcp_stream)
.await
.map_err(|e| anyhow!("tls handshake with {} failed: {e}", connect_info.server))?;

Ok(tls_stream)
}
Loading
Loading