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

VPN capabilities. #2526

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions core/gsb-api/src/api.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(non_snake_case)]
use crate::model::{
GsbApiError, ServiceListenResponse, ServicePath, ServiceRequest, ServiceResponse,
};
Expand Down Expand Up @@ -367,8 +368,7 @@ mod tests {

verify_delete_service(&mut api, &service_addr).await;
}

#[test_case(r#"{}"#, Frame::Close(Some(CloseReason {
#[test_case(r#"{}"#, Frame::Close(Some(CloseReason {
code: CloseCode::Policy,
description: Some("Failed to read response. Err: Missing root map. Err: Empty map".to_string()) }));
"Close when empty"
Expand Down
4 changes: 4 additions & 0 deletions core/vpn/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ tokio-stream = "0.1.6"
uuid = { version = "0.8", features = ["v4"] }

[features]
# Add log for outgoing and incoming packets for VPN RAW
# It includes transport bypassing smalltcp stack
trace-raw-packets = []
# Trace for VPN packets
packet-trace-enable = ["ya-packet-trace/enable"]
default = []

Expand Down
1 change: 1 addition & 0 deletions core/vpn/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(clippy::unit_arg)]
mod message;
mod network;
mod requestor;
Expand Down
36 changes: 28 additions & 8 deletions core/vpn/src/message.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::Result;
use actix::{Message, Recipient};
use futures::channel::mpsc;
use std::net::IpAddr;
use ya_client_model::net::*;
use ya_utils_networking::vpn::{
stack::{
Expand Down Expand Up @@ -42,24 +43,38 @@ pub struct RemoveNode {
pub struct GetConnections;

#[derive(Message)]
#[rtype(result = "Result<UserConnection>")]
pub struct Connect {
#[rtype(result = "Result<UserTcpConnection>")]
pub struct ConnectTcp {
pub protocol: Protocol,
pub address: String,
pub port: u16,
}

#[derive(Debug, Clone, Eq, Hash, PartialEq)]
pub struct RawSocketDesc {
pub src_addr: IpAddr,
pub dst_addr: IpAddr,
pub dst_id: String,
}

#[derive(Debug, Message)]
#[rtype(result = "Result<UserRawConnection>")]
pub struct ConnectRaw {
pub raw_socket_desc: RawSocketDesc,
}

#[derive(Debug, Message)]
#[rtype(result = "Result<()>")]
pub struct Disconnect {
pub struct DisconnectTcp {
pub desc: SocketDesc,
pub reason: DisconnectReason,
}

impl Disconnect {
pub fn new(desc: SocketDesc, reason: DisconnectReason) -> Self {
Self { desc, reason }
}
#[derive(Debug, Message)]
#[rtype(result = "Result<()>")]
pub struct DisconnectRaw {
pub raw_socket_desc: RawSocketDesc,
pub reason: DisconnectReason,
}

#[derive(Message)]
Expand All @@ -78,12 +93,17 @@ pub struct Shutdown;
pub struct DataSent;

#[derive(Debug)]
pub struct UserConnection {
pub struct UserTcpConnection {
pub vpn: Recipient<Packet>,
pub rx: mpsc::Receiver<Vec<u8>>,
pub stack_connection: Connection,
}

#[derive(Debug)]
pub struct UserRawConnection {
pub rx: mpsc::Receiver<Vec<u8>>,
}

#[derive(Clone, Debug)]
pub enum DisconnectReason {
SinkClosed,
Expand Down
Loading
Loading