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

Use narrower type to fix possible panic with IPv6 address argument #6498

Merged
merged 1 commit into from
Sep 3, 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
3 changes: 1 addition & 2 deletions talpid-tunnel-config-client/examples/psk-exchange.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// Usage: ./psk-exchange <tuncfg_server_ip> <wireguard_public_key>
// e. g. ./psk-exchange 10.64.0.1 NkECLsf+VbZUjve7RVN6sE3NYUcYUmUn8qpFugqbXFk=

use std::net::IpAddr;
use talpid_types::net::wireguard::{PrivateKey, PublicKey};

#[tokio::main]
Expand All @@ -24,7 +23,7 @@ async fn main() {
let ephemeral_private_key = PrivateKey::new_from_random();

let ephemeral_peer = talpid_tunnel_config_client::request_ephemeral_peer(
IpAddr::V4(tuncfg_server_ip),
tuncfg_server_ip,
public_key, // Parent connection's public key.
ephemeral_private_key.public_key(),
true, // Whether to negotiate a "PQ-safe" PSK.
Expand Down
9 changes: 5 additions & 4 deletions talpid-tunnel-config-client/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use proto::PostQuantumRequestV1;
use std::fmt;
#[cfg(not(target_os = "ios"))]
use std::net::IpAddr;
#[cfg(not(target_os = "ios"))]
use std::net::SocketAddr;
#[cfg(not(target_os = "ios"))]
use std::net::{IpAddr, Ipv4Addr};
use talpid_types::net::wireguard::{PresharedKey, PublicKey};
#[cfg(not(target_os = "ios"))]
use tokio::net::TcpSocket;
Expand Down Expand Up @@ -189,7 +189,7 @@ pub async fn request_ephemeral_peer_with(
/// Negotiate a short-lived peer with a PQ-safe PSK or with DAITA enabled.
#[cfg(not(target_os = "ios"))]
pub async fn request_ephemeral_peer(
service_address: IpAddr,
service_address: Ipv4Addr,
parent_pubkey: PublicKey,
ephemeral_pubkey: PublicKey,
enable_post_quantum: bool,
Expand Down Expand Up @@ -245,8 +245,9 @@ fn xor_assign(dst: &mut [u8; 32], src: &[u8; 32]) {
}

#[cfg(not(target_os = "ios"))]
async fn new_client(addr: IpAddr) -> Result<RelayConfigService, Error> {
async fn new_client(addr: Ipv4Addr) -> Result<RelayConfigService, Error> {
let endpoint = Endpoint::from_static("tcp://0.0.0.0:0");
let addr = IpAddr::V4(addr);

let conn = endpoint
.connect_with_connector(service_fn(move |_| async move {
Expand Down
2 changes: 1 addition & 1 deletion talpid-wireguard/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ impl WireguardMonitor {
let ephemeral = tokio::time::timeout(
timeout,
talpid_tunnel_config_client::request_ephemeral_peer(
IpAddr::from(config.ipv4_gateway),
config.ipv4_gateway,
config.tunnel.private_key.public_key(),
wg_psk_pubkey,
enable_pq,
Expand Down
Loading