more progress on friends
This commit is contained in:
parent
1b802ff33f
commit
7918e54487
19 changed files with 320 additions and 205 deletions
|
|
@ -16,11 +16,8 @@ async-trait = "0.1.88"
|
|||
typenum = "1.18.0"
|
||||
once_cell = "1.21.3"
|
||||
rnex-core = { path = "../rnex-core", version = "0.1.1" }
|
||||
proxy-common = {path = "../proxy-common"}
|
||||
cfg-if = "1.0.4"
|
||||
|
||||
[[bin]]
|
||||
name = "proxy_insecure"
|
||||
path = "src/executables/proxy_insecure.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "proxy_secure"
|
||||
path = "src/executables/proxy_secure.rs"
|
||||
[features]
|
||||
prudpv1 = []
|
||||
|
|
|
|||
|
|
@ -1 +1,3 @@
|
|||
pub mod common;
|
||||
pub mod common;
|
||||
pub mod proxy_insecure;
|
||||
pub mod proxy_secure;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use crate::executables::common::{EDGE_NODE_HOLDER, FORWARD_DESTINATION};
|
||||
use crate::prudp::router::Router;
|
||||
use crate::prudp::unsecure::Unsecure;
|
||||
use log::error;
|
||||
use prudpv1::executables::common::{EDGE_NODE_HOLDER, FORWARD_DESTINATION};
|
||||
use prudpv1::prudp::router::Router;
|
||||
use prudpv1::prudp::unsecure::Unsecure;
|
||||
use rnex_core::common::setup;
|
||||
use rnex_core::executables::common::{OWN_IP_PRIVATE, OWN_IP_PUBLIC, SERVER_PORT};
|
||||
use rnex_core::prudp::virtual_port::VirtualPort;
|
||||
|
|
@ -20,8 +20,7 @@ use tokio::net::TcpStream;
|
|||
use tokio::task;
|
||||
use tokio::time::sleep;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
pub async fn start() {
|
||||
setup();
|
||||
|
||||
let conn = tokio::net::TcpStream::connect(&*EDGE_NODE_HOLDER)
|
||||
|
|
|
|||
|
|
@ -1,48 +1,56 @@
|
|||
use rnex_core::reggie::UnitPacketRead;
|
||||
use rnex_core::reggie::UnitPacketWrite;
|
||||
use rnex_core::rmc::structures::RmcSerialize;
|
||||
use std::net::SocketAddrV4;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use crate::executables::common::{EDGE_NODE_HOLDER, FORWARD_DESTINATION};
|
||||
use crate::prudp::router::Router;
|
||||
use crate::prudp::secure::Secure;
|
||||
use log::error;
|
||||
use tokio::net::TcpStream;
|
||||
use tokio::task;
|
||||
use tokio::time::sleep;
|
||||
use prudpv1::executables::common::{FORWARD_DESTINATION, EDGE_NODE_HOLDER};
|
||||
use prudpv1::prudp::router::Router;
|
||||
use prudpv1::prudp::secure::Secure;
|
||||
use rnex_core::common::setup;
|
||||
use rnex_core::executables::common::{OWN_IP_PRIVATE, OWN_IP_PUBLIC, SECURE_SERVER_ACCOUNT, SERVER_PORT};
|
||||
use rnex_core::executables::common::{
|
||||
OWN_IP_PRIVATE, OWN_IP_PUBLIC, SECURE_SERVER_ACCOUNT, SERVER_PORT,
|
||||
};
|
||||
use rnex_core::prudp::virtual_port::VirtualPort;
|
||||
use rnex_core::reggie::EdgeNodeHolderConnectOption::Register;
|
||||
use rnex_core::reggie::RemoteEdgeNodeHolder;
|
||||
use rnex_core::rmc::protocols::{new_rmc_gateway_connection, OnlyRemote};
|
||||
use rnex_core::reggie::UnitPacketRead;
|
||||
use rnex_core::reggie::UnitPacketWrite;
|
||||
use rnex_core::rmc::protocols::{OnlyRemote, new_rmc_gateway_connection};
|
||||
use rnex_core::rmc::structures::RmcSerialize;
|
||||
use rnex_core::rnex_proxy_common::ConnectionInitData;
|
||||
use rnex_core::util::SplittableBufferConnection;
|
||||
use std::net::SocketAddrV4;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use tokio::net::TcpStream;
|
||||
use tokio::task;
|
||||
use tokio::time::sleep;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
pub async fn start() {
|
||||
setup();
|
||||
|
||||
let conn = tokio::net::TcpStream::connect(&*EDGE_NODE_HOLDER).await.unwrap();
|
||||
let conn = tokio::net::TcpStream::connect(&*EDGE_NODE_HOLDER)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let conn: SplittableBufferConnection = conn.into();
|
||||
|
||||
conn.send(Register(SocketAddrV4::new(*OWN_IP_PUBLIC, *SERVER_PORT)).to_data().unwrap()).await;
|
||||
|
||||
let conn = new_rmc_gateway_connection(conn, |r| Arc::new(OnlyRemote::<RemoteEdgeNodeHolder>::new(r)));
|
||||
|
||||
conn.send(
|
||||
Register(SocketAddrV4::new(*OWN_IP_PUBLIC, *SERVER_PORT))
|
||||
.to_data()
|
||||
.unwrap(),
|
||||
)
|
||||
.await;
|
||||
|
||||
let conn = new_rmc_gateway_connection(conn, |r| {
|
||||
Arc::new(OnlyRemote::<RemoteEdgeNodeHolder>::new(r))
|
||||
});
|
||||
|
||||
let (router_secure, _) = Router::new(SocketAddrV4::new(*OWN_IP_PRIVATE, *SERVER_PORT))
|
||||
.await
|
||||
.expect("unable to start router");
|
||||
|
||||
let mut socket_secure = router_secure
|
||||
.add_socket(VirtualPort::new(1, 10), Secure(
|
||||
"6f599f81",
|
||||
SECURE_SERVER_ACCOUNT.clone()
|
||||
))
|
||||
.add_socket(
|
||||
VirtualPort::new(1, 10),
|
||||
Secure("6f599f81", SECURE_SERVER_ACCOUNT.clone()),
|
||||
)
|
||||
.await
|
||||
.expect("unable to add socket");
|
||||
|
||||
|
|
@ -55,8 +63,7 @@ async fn main() {
|
|||
};
|
||||
|
||||
task::spawn(async move {
|
||||
let mut stream
|
||||
= match TcpStream::connect(*FORWARD_DESTINATION).await {
|
||||
let mut stream = match TcpStream::connect(*FORWARD_DESTINATION).await {
|
||||
Ok(v) => v,
|
||||
Err(e) => {
|
||||
error!("unable to connect: {}", e);
|
||||
|
|
@ -64,16 +71,21 @@ async fn main() {
|
|||
}
|
||||
};
|
||||
|
||||
if let Err(e) = stream.send_buffer(&ConnectionInitData{
|
||||
prudpsock_addr: conn.socket_addr,
|
||||
pid: conn.user_id
|
||||
}.to_data().unwrap()).await{
|
||||
if let Err(e) = stream
|
||||
.send_buffer(
|
||||
&ConnectionInitData {
|
||||
prudpsock_addr: conn.socket_addr,
|
||||
pid: conn.user_id,
|
||||
}
|
||||
.to_data()
|
||||
.unwrap(),
|
||||
)
|
||||
.await
|
||||
{
|
||||
error!("error connecting to backend: {}", e);
|
||||
return;
|
||||
};
|
||||
|
||||
|
||||
|
||||
loop {
|
||||
tokio::select! {
|
||||
data = conn.recv() => {
|
||||
|
|
@ -94,7 +106,7 @@ async fn main() {
|
|||
return;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
if conn.send(data).await == None{
|
||||
return;
|
||||
}
|
||||
|
|
@ -106,6 +118,6 @@ async fn main() {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
drop(conn);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,2 +1,14 @@
|
|||
pub mod prudp;
|
||||
pub mod executables;
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(feature = "prudpv1")]{
|
||||
use proxy_common::{ProxyStartupParam, setup_edge_node_connection};
|
||||
pub mod executables;
|
||||
pub mod prudp;
|
||||
pub async fn start_secure(param: ProxyStartupParam) {
|
||||
executables::proxy_secure::start();
|
||||
}
|
||||
|
||||
pub async fn start_insecure(param: ProxyStartupParam) {
|
||||
executables::proxy_insecure::start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ pub fn read_secure_connection_data(data: &[u8], act: &Account) -> Option<([u8; 3
|
|||
|
||||
let ticket_data = &mut ticket_data[0..ticket_data_size - 0x10];
|
||||
|
||||
let server_key = derive_key(act.pid, act.kerbros_password);
|
||||
let server_key = derive_key(act.pid, &act.kerbros_password[..]);
|
||||
|
||||
let mut rc4: StreamCipherCoreWrapper<Rc4Core<U16>> =
|
||||
Rc4::new_from_slice(&server_key).expect("unable to init rc4 keystream");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue