15 march works with app
This commit is contained in:
+10
-12
@@ -5,16 +5,14 @@ use netrunner_client::tun::{
|
||||
routing::{reset_platform_routing, setup_platform_routing},
|
||||
tun::Tun,
|
||||
};
|
||||
use netrunner_core::{
|
||||
logger_init,
|
||||
proxy::{connection::connection::ConnectionRole, network::Network},
|
||||
};
|
||||
use netrunner_core::proxy::{connection::connection::ConnectionRole, network::Network};
|
||||
use netrunner_logger::{error, info};
|
||||
use smoltcp::{iface::Config, phy::DeviceCapabilities};
|
||||
use tracing::{error, info};
|
||||
use tokio_util::sync::CancellationToken;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
logger_init();
|
||||
netrunner_logger::Logger::init();
|
||||
info!("Initializing NetRunner Stack...");
|
||||
let tun_device = Tun::create(|config| {
|
||||
config
|
||||
@@ -26,7 +24,7 @@ async fn main() {
|
||||
})
|
||||
.expect("Failed to initialize TUN device");
|
||||
let remote_address: String = "62.60.244.156:443".into();
|
||||
setup_platform_routing(&remote_address).expect("Failed to setup routing");
|
||||
setup_platform_routing(&remote_address);
|
||||
|
||||
info!("TUN interface is UP: 10.0.0.1/24");
|
||||
|
||||
@@ -41,14 +39,14 @@ async fn main() {
|
||||
"0.0.0.0".into(),
|
||||
8080,
|
||||
ConnectionRole::Client,
|
||||
Some(remote_address),
|
||||
Some(remote_address.clone()),
|
||||
);
|
||||
|
||||
let proxy_ip = network.get_self_local_address();
|
||||
|
||||
tokio::spawn(async move {
|
||||
info!("Network thread started");
|
||||
network.run().await;
|
||||
network.run(CancellationToken::new()).await;
|
||||
});
|
||||
|
||||
let mut engine = Engine::new(config, caps, proxy_ip);
|
||||
@@ -60,7 +58,6 @@ async fn main() {
|
||||
|
||||
info!("Engine starting process loop...");
|
||||
|
||||
// 3. Используем select для перехвата сигнала завершения
|
||||
let ctrl_c = tokio::signal::ctrl_c();
|
||||
|
||||
tokio::select! {
|
||||
@@ -72,9 +69,10 @@ async fn main() {
|
||||
}
|
||||
}
|
||||
|
||||
// 4. ГАРАНТИРОВАННЫЙ СБРОС
|
||||
info!("Restoring system routing...");
|
||||
if let Err(e) = reset_platform_routing() {
|
||||
let addr: std::net::SocketAddr = remote_address.parse().expect("Invalid address format");
|
||||
let proxy_ip = addr.ip().to_string();
|
||||
if let Err(e) = reset_platform_routing(Some(&proxy_ip)) {
|
||||
error!("Failed to reset routing: {}", e);
|
||||
} else {
|
||||
info!("System routing restored successfully.");
|
||||
|
||||
Reference in New Issue
Block a user