Add transparent tcp proxy on linux
This commit is contained in:
parent
fb8742ef14
commit
33ca736a73
5 changed files with 77 additions and 28 deletions
|
@ -10,11 +10,13 @@ use once_cell::sync::Lazy;
|
|||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashSet;
|
||||
use std::io::{Error, IoSlice};
|
||||
use std::net::{IpAddr, SocketAddr};
|
||||
use std::pin::Pin;
|
||||
use std::task::{Context, Poll};
|
||||
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
|
||||
use tokio::net::TcpStream;
|
||||
use tokio_rustls::client::TlsStream;
|
||||
use url::Host;
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
|
@ -36,6 +38,7 @@ impl JwtTunnelConfig {
|
|||
LocalProtocol::Socks5 => LocalProtocol::Tcp,
|
||||
LocalProtocol::ReverseTcp => LocalProtocol::ReverseTcp,
|
||||
LocalProtocol::ReverseUdp { .. } => tunnel.local_protocol,
|
||||
LocalProtocol::TProxyTcp => LocalProtocol::Tcp,
|
||||
},
|
||||
r: tunnel.remote.0.to_string(),
|
||||
rp: tunnel.remote.1,
|
||||
|
@ -141,3 +144,10 @@ impl ManageConnection for WsClientConfig {
|
|||
conn.is_none()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_host_port(addr: SocketAddr) -> (Host, u16) {
|
||||
match addr.ip() {
|
||||
IpAddr::V4(ip) => (Host::Ipv4(ip), addr.port()),
|
||||
IpAddr::V6(ip) => (Host::Ipv6(ip), addr.port()),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ async fn from_query(
|
|||
|
||||
let local_srv = (Host::parse(&jwt.claims.r)?, jwt.claims.rp);
|
||||
let bind = format!("{}:{}", local_srv.0, local_srv.1);
|
||||
let listening_server = tcp::run_server(bind.parse()?);
|
||||
let listening_server = tcp::run_server(bind.parse()?, false);
|
||||
let tcp = run_listening_server(&local_srv, SERVERS.deref(), listening_server).await?;
|
||||
let (local_rx, local_tx) = tcp.into_split();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue