Files
MeshPort/crates/meshport-socks/examples/local_bridge.rs
T
shenleiandClaude Haiku 5.5 2f185f914d Snapshot uncommitted work: proxy UI, sing-box integration, socks bridge
- Lab app: proxy panel, node editor, configuration and detail pages,
  responsive layout, and related tests
- Add meshport-socks crate and sing-box bridge scripts/docs
- Add singbox_flutter binding and meshport_client_core package
- FFI, VPN helper (unified mac path), and Android/macOS runner updates
- Docs for architecture, client runtime, UI design, and validation
- UI design output artifacts under outputs/ui

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-10-12 10:06:15 +09:00

44 lines
1.4 KiB
Rust

//! Run with an application-mode TOML file; never prints its credentials.
use anyhow::{Context, Result};
use meshport::Network;
use meshport_socks::{Bridge, Options};
use std::{
net::{Ipv4Addr, SocketAddrV4},
sync::Arc,
};
#[tokio::main]
async fn main() -> Result<()> {
let mut arguments = std::env::args().skip(1);
let path = arguments
.next()
.context("usage: local_bridge CONFIG.toml [PORT]")?;
let port = arguments
.next()
.map(|s| s.parse::<u16>())
.transpose()?
.unwrap_or(0);
anyhow::ensure!(arguments.next().is_none(), "too many arguments");
let config = std::fs::read_to_string(path).context("cannot read configuration")?;
let network = Arc::new(Network::start(&config).await?);
let result = async {
let mut bridge = Bridge::start(
network.clone(),
Options {
listen: SocketAddrV4::new(Ipv4Addr::LOCALHOST, port),
..Default::default()
},
)
.await?;
println!("MeshPort SOCKS5 IPv4 TCP/UDP: {}", bridge.local_addr());
println!("Waiting for Ctrl-C; engine startup does not guarantee remote reachability.");
let signal = tokio::signal::ctrl_c().await;
bridge.stop().await?;
signal?;
Ok::<_, anyhow::Error>(())
}
.await;
network.stop().await;
result
}