Skip to content

Commit

Permalink
Use IPR v7 consistently (#2305)
Browse files Browse the repository at this point in the history
* Use IPR v7 consistently

* Update to latest dorina
  • Loading branch information
octol authored Feb 28, 2025
1 parent f689a46 commit 8487642
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 92 deletions.
151 changes: 76 additions & 75 deletions nym-vpn-core/Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions nym-vpn-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ default-members = [
# For local development
# [patch."https://github.com/nymtech/nym"]
# nym-authenticator-requests = { path = "../../nym/common/authenticator-requests" }
# nym-api-requests = { path = "../../nym/nym-api/nym-api-requests" }
# nym-bandwidth-controller = { path = "../../nym/common/bandwidth-controller" }
# nym-bin-common = { path = "../../nym/common/bin-common" }
# nym-client-core = { path = "../../nym/common/client-core" }
Expand Down
6 changes: 2 additions & 4 deletions nym-vpn-core/crates/nym-gateway-probe/src/icmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use nym_connection_monitor::{
ConnectionStatusEvent, IcmpBeaconReply, Icmpv6BeaconReply,
};
use nym_gateway_directory::IpPacketRouterAddress;
use nym_ip_packet_requests::{codec::MultiIpPacketCodec, IpPair};
use nym_ip_packet_requests::{codec::MultiIpPacketCodec, v7::request::IpPacketRequest, IpPair};
use nym_mixnet_client::SharedMixnetClient;
use nym_sdk::mixnet::{InputMessage, Recipient};
use nym_task::connections::TransmissionLane;
Expand Down Expand Up @@ -73,9 +73,7 @@ pub async fn send_ping_v6(
}

fn create_input_message(recipient: Recipient, bundled_packets: Bytes) -> Result<InputMessage> {
let packet =
nym_ip_packet_requests::request::IpPacketRequest::new_data_request(bundled_packets)
.to_bytes()?;
let packet = IpPacketRequest::new_data_request(bundled_packets).to_bytes()?;

let lane = TransmissionLane::General;
let packet_type = None;
Expand Down
2 changes: 1 addition & 1 deletion nym-vpn-core/crates/nym-gateway-probe/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use nym_gateway_directory::{
use nym_ip_packet_client::IprClientConnect;
use nym_ip_packet_requests::{
codec::MultiIpPacketCodec,
response::{DataResponse, InfoLevel, IpPacketResponse, IpPacketResponseData},
v7::response::{DataResponse, InfoLevel, IpPacketResponse, IpPacketResponseData},
IpPair,
};
use nym_mixnet_client::SharedMixnetClient;
Expand Down
6 changes: 3 additions & 3 deletions nym-vpn-core/crates/nym-ip-packet-client/src/connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ use tokio_util::sync::CancellationToken;
use tracing::{debug, error};

use crate::{
error::{Error, Result},
helpers::check_ipr_message_version,
nym_ip_packet_requests_current::{
current::{
request::IpPacketRequest,
response::{
DynamicConnectResponse, DynamicConnectResponseReply, IpPacketResponse,
IpPacketResponseData, StaticConnectResponse, StaticConnectResponseReply,
},
},
error::{Error, Result},
helpers::check_ipr_message_version,
};

const IPR_CONNECT_TIMEOUT: Duration = Duration::from_secs(10);
Expand Down
4 changes: 1 addition & 3 deletions nym-vpn-core/crates/nym-ip-packet-client/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// Copyright 2024 - Nym Technologies SA <[email protected]>
// SPDX-License-Identifier: GPL-3.0-only

use crate::nym_ip_packet_requests_current::response::{
DynamicConnectFailureReason, StaticConnectFailureReason,
};
use crate::current::response::{DynamicConnectFailureReason, StaticConnectFailureReason};

#[derive(thiserror::Error, Debug)]
pub enum Error {
Expand Down
4 changes: 2 additions & 2 deletions nym-vpn-core/crates/nym-ip-packet-client/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ use std::cmp::Ordering;

use nym_sdk::mixnet::ReconstructedMessage;

use crate::{error::Result, nym_ip_packet_requests_current::VERSION as CURRENT_VERSION, Error};
use crate::{current::VERSION as CURRENT_VERSION, error::Result, Error};

pub(crate) fn check_ipr_message_version(message: &ReconstructedMessage) -> Result<()> {
// Assuing it's a IPR message, it will have a version as its first byte
// Assuming it's a IPR message, it will have a version as its first byte
if let Some(version) = message.message.first() {
match version.cmp(&CURRENT_VERSION) {
Ordering::Greater => Err(Error::ReceivedResponseWithNewVersion {
Expand Down
3 changes: 2 additions & 1 deletion nym-vpn-core/crates/nym-ip-packet-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ pub use connect::IprClientConnect;
pub use error::Error;
pub use listener::{IprListener, MixnetMessageOutcome};

pub(crate) use nym_ip_packet_requests::v7 as nym_ip_packet_requests_current;
// Re-export the currently used version
pub use nym_ip_packet_requests::v7 as current;
4 changes: 2 additions & 2 deletions nym-vpn-core/crates/nym-ip-packet-client/src/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ use tokio_util::codec::Decoder;
use tracing::{debug, error, info, warn};

use crate::{
helpers::check_ipr_message_version,
nym_ip_packet_requests_current::{
current::{
request::{IpPacketRequest, IpPacketRequestData},
response::{InfoLevel, IpPacketResponse, IpPacketResponseData},
},
helpers::check_ipr_message_version,
};

pub enum MixnetMessageOutcome {
Expand Down
2 changes: 1 addition & 1 deletion nym-vpn-core/crates/nym-vpn-lib/src/mixnet/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::result::Result;
use bytes::Bytes;
use futures::{channel::mpsc, StreamExt};
use nym_connection_monitor::{ConnectionMonitorTask, ConnectionStatusEvent};
use nym_ip_packet_requests::{codec::MultiIpPacketCodec, request::IpPacketRequest};
use nym_ip_packet_requests::{codec::MultiIpPacketCodec, v7::request::IpPacketRequest};
use nym_mixnet_client::SharedMixnetClient;
use nym_sdk::mixnet::{InputMessage, MixnetMessageSender, Recipient};
use nym_task::{connections::TransmissionLane, TaskClient, TaskManager};
Expand Down

0 comments on commit 8487642

Please sign in to comment.