renames and tauri app
This commit is contained in:
@@ -1,2 +1,4 @@
|
|||||||
/target
|
/target
|
||||||
things.txt
|
things.txt
|
||||||
|
/jniLibs
|
||||||
|
/app/node_modules
|
||||||
Vendored
+4
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"rust-analyzer.cargo.features": "all",
|
||||||
|
"rust-analyzer.linkedProjects": ["Cargo.toml"]
|
||||||
|
}
|
||||||
Generated
+3632
-51
File diff suppressed because it is too large
Load Diff
+3
-1
@@ -1,7 +1,9 @@
|
|||||||
[workspace]
|
[workspace]
|
||||||
members = [
|
members = [
|
||||||
"common",
|
"core",
|
||||||
"client",
|
"client",
|
||||||
"server",
|
"server",
|
||||||
|
"tools/uniffi-bindgen",
|
||||||
|
"app/src-tauri",
|
||||||
]
|
]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|||||||
@@ -4,11 +4,23 @@ REMOTE_USER = root
|
|||||||
REMOTE_PATH = /root/netr-core
|
REMOTE_PATH = /root/netr-core
|
||||||
SERVICE_NAME = netrunner-server
|
SERVICE_NAME = netrunner-server
|
||||||
|
|
||||||
.PHONY: build-client build-server deploy-server logs
|
.PHONY: debug-client debug-server build-android build-server deploy-server logs
|
||||||
|
|
||||||
|
debug-client:
|
||||||
|
@echo "--- Сборка клиента (Debug) ---"
|
||||||
|
cargo build --bin netrunner-client
|
||||||
|
@echo "--- Запуск клиента через sudo ---"
|
||||||
|
sudo ./target/debug/netrunner-client
|
||||||
|
|
||||||
|
debug-server:
|
||||||
|
@echo "--- Сборка сервера (Debug) ---"
|
||||||
|
cargo build --bin netrunner-server
|
||||||
|
@echo "--- Запуск сервера локально ---"
|
||||||
|
sudo ./target/debug/netrunner-server --port=4443 --host=0.0.0.0
|
||||||
|
|
||||||
# Сборка
|
# Сборка
|
||||||
build-client:
|
build-android:
|
||||||
cargo build --bin netrunner-client --release
|
cargo ndk -t arm64-v8a -o ./jniLibs build --release
|
||||||
|
|
||||||
build-server:
|
build-server:
|
||||||
cargo build --bin netrunner-server --release
|
cargo build --bin netrunner-server --release
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"name": "netrunner-app",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"private": true,
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"dev": "vite",
|
||||||
|
"build": "tsc && vite build",
|
||||||
|
"preview": "vite preview",
|
||||||
|
"tauri": "tauri"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@tauri-apps/api": "^2.0.0",
|
||||||
|
"@tauri-apps/plugin-shell": "^2.0.0",
|
||||||
|
"solid-js": "^1.8.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@tauri-apps/cli": "^2.0.0",
|
||||||
|
"typescript": "^5.0.0",
|
||||||
|
"vite": "^7.3.1",
|
||||||
|
"vite-plugin-solid": "^2.8.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
Generated
+1335
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,19 @@
|
|||||||
|
[package]
|
||||||
|
name = "app"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "netrunner-app"
|
||||||
|
path = "main.rs"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
tauri-build = { version = "2.0.0" }
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
netrunner-client = { path = "../../client" }
|
||||||
|
netrunner-core = { path = "../../core" }
|
||||||
|
tauri = { version = "2.0.0", features = [] }
|
||||||
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
fn main() {}
|
||||||
+8
-8
@@ -3,15 +3,12 @@ name = "netrunner-client"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[[example]]
|
|
||||||
name = "client_example"
|
|
||||||
path = "examples/client_example.rs"
|
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
crate-type = ["cdylib", "rlib"]
|
path = "src/lib.rs"
|
||||||
|
crate-type = ["cdylib", "rlib", "staticlib"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
netrunner-common = { path = "../common" } # Наша общая либа
|
netrunner-core = { path = "../core" }
|
||||||
smoltcp = { version = "0.12", default-features = false, features = [
|
smoltcp = { version = "0.12", default-features = false, features = [
|
||||||
"std",
|
"std",
|
||||||
"log",
|
"log",
|
||||||
@@ -25,9 +22,8 @@ smoltcp = { version = "0.12", default-features = false, features = [
|
|||||||
"socket-tcp-cubic",
|
"socket-tcp-cubic",
|
||||||
] }
|
] }
|
||||||
tokio = { version = "1.36", features = ["full"] }
|
tokio = { version = "1.36", features = ["full"] }
|
||||||
jni = "0.21"
|
|
||||||
bytes = "1.5"
|
bytes = "1.5"
|
||||||
android_logger = "0.13"
|
android_logger = "0.15.1"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
tun = { version = "0.8", features = ["async"] }
|
tun = { version = "0.8", features = ["async"] }
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
@@ -37,3 +33,7 @@ thiserror = "2.0"
|
|||||||
hickory-proto = "0.25.2"
|
hickory-proto = "0.25.2"
|
||||||
lru = "0.16.3"
|
lru = "0.16.3"
|
||||||
tokio-util = "0.7.18"
|
tokio-util = "0.7.18"
|
||||||
|
uniffi = { version = "0.31.0", features = ["tokio"] }
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
uniffi = { version = "0.31.0", features = ["build"] }
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
fn main() {
|
||||||
|
println!("cargo:rerun-if-changed=client.udl");
|
||||||
|
uniffi::generate_scaffolding("./client.udl").expect("Can't generate UniFFI files");
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
namespace netrunner {
|
||||||
|
};
|
||||||
|
|
||||||
|
interface SessionManager {
|
||||||
|
constructor();
|
||||||
|
Session start(string remote_address, optional i32 tun_fd);
|
||||||
|
};
|
||||||
|
|
||||||
|
interface Session {
|
||||||
|
void stop();
|
||||||
|
};
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
use netrunner_common::protocol::codec::socks::{SocksRequest, TargetAddress};
|
use netrunner_core::protocol::codec::socks::{SocksRequest, TargetAddress};
|
||||||
use smoltcp::iface::SocketHandle;
|
use smoltcp::iface::SocketHandle;
|
||||||
use smoltcp::socket::tcp;
|
use smoltcp::socket::tcp;
|
||||||
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
||||||
|
|||||||
@@ -1,2 +1,124 @@
|
|||||||
|
uniffi::setup_scaffolding!();
|
||||||
pub mod connections;
|
pub mod connections;
|
||||||
pub mod tun;
|
pub mod tun;
|
||||||
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
|
use netrunner_core::proxy::{connection::connection::ConnectionRole, network::Network};
|
||||||
|
use smoltcp::{iface::Config, phy::DeviceCapabilities};
|
||||||
|
use std::net::Ipv4Addr;
|
||||||
|
use std::sync::OnceLock;
|
||||||
|
use tokio::runtime::Runtime;
|
||||||
|
use tokio::sync::oneshot;
|
||||||
|
use tracing::info;
|
||||||
|
|
||||||
|
use crate::tun::{engine::Engine, tun::Tun};
|
||||||
|
|
||||||
|
static RUNTIME: OnceLock<Runtime> = OnceLock::new();
|
||||||
|
|
||||||
|
fn get_runtime() -> &'static Runtime {
|
||||||
|
RUNTIME.get_or_init(|| {
|
||||||
|
tokio::runtime::Builder::new_multi_thread()
|
||||||
|
.enable_all()
|
||||||
|
.build()
|
||||||
|
.expect("Failed to create tokio runtime")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// --- Обертка для Session ---
|
||||||
|
#[derive(uniffi::Object)]
|
||||||
|
pub struct Session {
|
||||||
|
shutdown_tx: Mutex<Option<oneshot::Sender<()>>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[uniffi::export]
|
||||||
|
impl Session {
|
||||||
|
pub fn stop(&self) {
|
||||||
|
let mut guard = self.shutdown_tx.lock().unwrap();
|
||||||
|
if let Some(tx) = guard.take() {
|
||||||
|
let _ = tx.send(());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Фабрика (SessionManager) ---
|
||||||
|
#[derive(uniffi::Object)]
|
||||||
|
pub struct SessionManager;
|
||||||
|
|
||||||
|
#[uniffi::constructor]
|
||||||
|
impl SessionManager {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[uniffi::export]
|
||||||
|
impl SessionManager {
|
||||||
|
pub fn start(&self, remote_address: String, tun_fd: Option<i32>) -> Arc<Session> {
|
||||||
|
let (tx, rx) = oneshot::channel();
|
||||||
|
let runtime = get_runtime();
|
||||||
|
runtime.spawn(async move {
|
||||||
|
info!("Starting VPN session...");
|
||||||
|
|
||||||
|
let tun_device = if let Some(fd) = tun_fd {
|
||||||
|
info!("Using provided FD for TUN: {}", fd);
|
||||||
|
Tun::from_android_fd(fd).expect("Failed to init TUN from FD")
|
||||||
|
} else {
|
||||||
|
info!("Creating TUN device manually");
|
||||||
|
Tun::create(|config| {
|
||||||
|
config
|
||||||
|
.tun_name("tun0")
|
||||||
|
.address((10, 0, 0, 1))
|
||||||
|
// ... настройки ...
|
||||||
|
.up();
|
||||||
|
})
|
||||||
|
.expect("Failed to init TUN")
|
||||||
|
};
|
||||||
|
|
||||||
|
tun_device.setup_routing();
|
||||||
|
tun_device.setup_dns_redirection();
|
||||||
|
|
||||||
|
// 2. Инициализация сети
|
||||||
|
let config = Config::new(smoltcp::wire::HardwareAddress::Ip);
|
||||||
|
let mut caps = DeviceCapabilities::default();
|
||||||
|
caps.max_transmission_unit = 1500;
|
||||||
|
caps.medium = smoltcp::phy::Medium::Ip;
|
||||||
|
|
||||||
|
let network = Network::new(
|
||||||
|
"0.0.0.0".into(),
|
||||||
|
8080,
|
||||||
|
ConnectionRole::Client,
|
||||||
|
Some(remote_address),
|
||||||
|
);
|
||||||
|
|
||||||
|
let proxy_ip = network.get_self_local_address();
|
||||||
|
|
||||||
|
// Запускаем сетевой поток
|
||||||
|
let net_handle = tokio::spawn(async move {
|
||||||
|
network.run().await;
|
||||||
|
});
|
||||||
|
|
||||||
|
// 3. Инициализация Engine
|
||||||
|
let mut engine = Engine::new(config, caps, proxy_ip);
|
||||||
|
engine.set_any_ip(true);
|
||||||
|
engine.set_transparent_mode();
|
||||||
|
engine.set_default_gateway(Ipv4Addr::new(10, 0, 0, 2));
|
||||||
|
engine.activate();
|
||||||
|
|
||||||
|
// 4. Главный цикл с поддержкой остановки
|
||||||
|
tokio::select! {
|
||||||
|
_ = engine.run(tun_device) => {
|
||||||
|
info!("Engine loop finished naturally.");
|
||||||
|
}
|
||||||
|
_ = rx => {
|
||||||
|
info!("Shutdown signal received. Cleaning up...");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
net_handle.abort();
|
||||||
|
info!("VPN session stopped.");
|
||||||
|
});
|
||||||
|
|
||||||
|
Arc::new(Session {
|
||||||
|
shutdown_tx: Mutex::new(Some(tx)),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
use std::net::Ipv4Addr;
|
use std::net::Ipv4Addr;
|
||||||
|
|
||||||
use netrunner_client::{tun::engine::Engine, tun::tun::Tun};
|
use netrunner_client::{tun::engine::Engine, tun::tun::Tun};
|
||||||
use netrunner_common::{
|
use netrunner_core::{
|
||||||
logger_init,
|
logger_init,
|
||||||
proxy::{connection::connection::ConnectionRole, network::Network},
|
proxy::{connection::connection::ConnectionRole, network::Network},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use netrunner_common::protocol::codec::socks::TargetAddress;
|
use netrunner_core::protocol::codec::socks::TargetAddress;
|
||||||
use smoltcp::{
|
use smoltcp::{
|
||||||
iface::{SocketHandle, SocketSet},
|
iface::{SocketHandle, SocketSet},
|
||||||
socket::{AnySocket, icmp, tcp, udp},
|
socket::{AnySocket, icmp, tcp, udp},
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ impl Tun {
|
|||||||
Ok((writer, reader))
|
Ok((writer, reader))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
pub fn setup_routing(&self) -> io::Result<()> {
|
pub fn setup_routing(&self) -> io::Result<()> {
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
@@ -84,6 +85,7 @@ impl Tun {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
pub fn setup_dns_redirection(&self) -> io::Result<()> {
|
pub fn setup_dns_redirection(&self) -> io::Result<()> {
|
||||||
// 1. Создаем временный файл resolv.conf
|
// 1. Создаем временный файл resolv.conf
|
||||||
// Мы говорим системе: "Твой DNS-сервер теперь 10.0.0.1" (твой TUN-IP)
|
// Мы говорим системе: "Твой DNS-сервер теперь 10.0.0.1" (твой TUN-IP)
|
||||||
@@ -97,4 +99,16 @@ impl Tun {
|
|||||||
info!("DNS перенаправлен на 10.0.0.1");
|
info!("DNS перенаправлен на 10.0.0.1");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "android")]
|
||||||
|
pub fn setup_routing(&self) -> io::Result<()> {
|
||||||
|
info!("Skipping routing setup on Android (handled by VpnService)");
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "android")]
|
||||||
|
pub fn setup_dns_redirection(&self) -> io::Result<()> {
|
||||||
|
info!("Skipping DNS setup on Android (handled by VpnService)");
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "netrunner-common"
|
name = "netrunner-core"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
@@ -93,5 +93,6 @@ impl StreamHandler {
|
|||||||
|
|
||||||
async fn on_close(&self, stream_id: u32) {
|
async fn on_close(&self, stream_id: u32) {
|
||||||
self.muxer.dispatch_to_local(stream_id, Bytes::new()).await;
|
self.muxer.dispatch_to_local(stream_id, Bytes::new()).await;
|
||||||
|
self.muxer.remove_stream(stream_id).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -4,6 +4,6 @@ version = "0.1.0"
|
|||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
netrunner-common = { path = "../common" }
|
netrunner-core = { path = "../core" }
|
||||||
tokio = { version = "1.36", features = ["full"] }
|
tokio = { version = "1.36", features = ["full"] }
|
||||||
clap = { version = "4.4", features = ["derive"] }
|
clap = { version = "4.4", features = ["derive"] }
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
use netrunner_common::{
|
use netrunner_core::{
|
||||||
logger_init,
|
logger_init,
|
||||||
proxy::{connection::connection::ConnectionRole, network::Network},
|
proxy::{connection::connection::ConnectionRole, network::Network},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
[package]
|
||||||
|
name = "my-bindgen-tool"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2024"
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "bindgen-tool"
|
||||||
|
path = "main.rs"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
uniffi = { version = "0.31.0", features = ["tokio", "cli"] }
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fn main() {
|
||||||
|
uniffi::uniffi_bindgen_main();
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user