mirror of
https://github.com/creating2morrow/neveko.git
synced 2024-12-22 19:49:24 +00:00
handle multiple tunnel extraction
This commit is contained in:
parent
4e72ad028d
commit
b9b71c63ff
1 changed files with 16 additions and 10 deletions
|
@ -100,9 +100,14 @@ pub async fn start() {
|
||||||
let args = args::Args::parse();
|
let args = args::Args::parse();
|
||||||
let path = args.i2p_zero_dir;
|
let path = args.i2p_zero_dir;
|
||||||
let output = Command::new(format!("{}/router/bin/i2p-zero", path))
|
let output = Command::new(format!("{}/router/bin/i2p-zero", path))
|
||||||
.spawn()
|
.spawn();
|
||||||
.expect("i2p-zero failed to start");
|
match output {
|
||||||
debug!("{:?}", output.stdout);
|
Ok(child) => debug!("{:?}", child.stdout),
|
||||||
|
_=> {
|
||||||
|
warn!("i2p-zero not installed, manual tunnel creation required");
|
||||||
|
()
|
||||||
|
},
|
||||||
|
}
|
||||||
find_tunnels().await;
|
find_tunnels().await;
|
||||||
{
|
{
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
|
@ -153,13 +158,14 @@ pub fn get_destination() -> String {
|
||||||
};
|
};
|
||||||
if contents != utils::empty_string() {
|
if contents != utils::empty_string() {
|
||||||
let input = format!(r#"{contents}"#);
|
let input = format!(r#"{contents}"#);
|
||||||
let mut j: Tunnels = serde_json::from_str(&input).unwrap_or(Default::default());
|
let j: Tunnels = serde_json::from_str(&input).unwrap_or(Default::default());
|
||||||
let destination: String = j
|
let mut destination: String = utils::empty_string();
|
||||||
.tunnels
|
let tunnels: Vec<Tunnel> = j.tunnels;
|
||||||
.remove(0)
|
for tunnel in tunnels {
|
||||||
.dest
|
if tunnel.port == format!("{}", utils::get_app_port()) {
|
||||||
.ok_or(utils::empty_string())
|
destination = tunnel.dest.unwrap_or(utils::empty_string());
|
||||||
.unwrap_or(utils::empty_string());
|
}
|
||||||
|
}
|
||||||
return destination;
|
return destination;
|
||||||
}
|
}
|
||||||
utils::empty_string()
|
utils::empty_string()
|
||||||
|
|
Loading…
Reference in a new issue