Use common interface request response
This commit is contained in:
Generated
+1
@@ -7593,6 +7593,7 @@ dependencies = [
|
||||
"ip_network",
|
||||
"ip_network_table",
|
||||
"log",
|
||||
"nym-service-providers-common",
|
||||
"nym-sphinx",
|
||||
"nym-task",
|
||||
"nym-wireguard-types",
|
||||
|
||||
@@ -35,5 +35,8 @@ tap.workspace = true
|
||||
thiserror.workspace = true
|
||||
tokio = { workspace = true, features = ["rt-multi-thread", "net", "io-util"] }
|
||||
|
||||
# WIP(JON) we'll move this when we move the tun stuff to its own crate
|
||||
nym-service-providers-common = { path = "../../service-providers/common" }
|
||||
|
||||
[target.'cfg(target_os = "linux")'.dependencies]
|
||||
tokio-tun = "0.9.0"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use std::time::Duration;
|
||||
|
||||
use nym_service_providers_common::interface;
|
||||
use tokio::sync::mpsc::{
|
||||
self,
|
||||
error::{SendError, SendTimeoutError, TrySendError},
|
||||
@@ -81,14 +82,23 @@ pub(crate) fn tun_task_response_channel() -> (TunTaskResponseTx, TunTaskResponse
|
||||
)
|
||||
}
|
||||
|
||||
pub type IpPacketRouterRequest = interface::Request<TaggedIpPacket>;
|
||||
pub type IpPacketRouterResponse = interface::Response<IpPacket>;
|
||||
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
pub struct TaggedPacket {
|
||||
pub struct TaggedIpPacket {
|
||||
pub packet: bytes::Bytes,
|
||||
pub return_address: nym_sphinx::addressing::clients::Recipient,
|
||||
pub return_mix_hops: Option<u8>,
|
||||
pub return_mix_delays: Option<f64>,
|
||||
}
|
||||
|
||||
impl TaggedPacket {
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
pub struct IpPacket {
|
||||
pub packet: bytes::Bytes,
|
||||
}
|
||||
|
||||
impl TaggedIpPacket {
|
||||
pub fn from_message(
|
||||
message: &nym_sphinx::receiver::ReconstructedMessage,
|
||||
) -> Result<Self, bincode::Error> {
|
||||
|
||||
@@ -17,7 +17,7 @@ use nym_sdk::{
|
||||
};
|
||||
use nym_sphinx::receiver::ReconstructedMessage;
|
||||
use nym_task::{connections::TransmissionLane, TaskClient, TaskHandle};
|
||||
use nym_wireguard::tun_task_channel::TaggedPacket;
|
||||
use nym_wireguard::tun_task_channel::TaggedIpPacket;
|
||||
use request_filter::RequestFilter;
|
||||
|
||||
use crate::config::BaseClientConfig;
|
||||
@@ -254,7 +254,7 @@ impl IpPacketRouter {
|
||||
reconstructed.sender_tag
|
||||
);
|
||||
|
||||
let tagged_packet = TaggedPacket::from_message(&reconstructed)
|
||||
let tagged_packet = TaggedIpPacket::from_message(&reconstructed)
|
||||
.map_err(|err| IpPacketRouterError::FailedToDeserializeTaggedPacket { source: err })?;
|
||||
|
||||
// We don't forward packets that we are not able to parse. BUT, there might be a good
|
||||
|
||||
Reference in New Issue
Block a user