diff options
-rw-r--r-- | src/main.rs | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/src/main.rs b/src/main.rs index 9b9c9cf..1752d81 100644 --- a/src/main.rs +++ b/src/main.rs @@ -88,33 +88,31 @@ fn main() -> Result<()> { let (send_tx, send_rx) = mpsc::channel(); let send_rx = Arc::new(Mutex::new(send_rx)); - loop { - println!("connecting..."); + let send_tx2 = send_tx.clone(); + let tun2 = tun.clone(); - let clt = Client::new(config.clone())?; + thread::spawn(move || match tun2ppp(send_tx2, tun2) { + Ok(_) => {} + Err(e) => panic!("tun2ppp error: {}", e), + }); - let recv_rx2 = recv_rx.clone(); - let send_tx2 = send_tx.clone(); - let tun2 = tun.clone(); - let tun3 = tun.clone(); + thread::spawn(move || match ppp2tun(recv_rx, tun) { + Ok(_) => {} + Err(e) => panic!("ppp2tun error: {}", e), + }); - thread::spawn(move || match tun2ppp(send_tx2, tun2) { - Ok(_) => {} - Err(e) => panic!("tun2ppp error: {}", e), - }); + let (ipchange_tx, ipchange_rx) = mpsc::channel(); + thread::spawn(move || match write_config(ipchange_rx) { + Ok(_) => {} + Err(e) => panic!("write_config error: {}", e), + }); - thread::spawn(move || match ppp2tun(recv_rx2, tun3) { - Ok(_) => {} - Err(e) => panic!("ppp2tun error: {}", e), - }); + loop { + println!("connecting..."); - let (ipchange_tx, ipchange_rx) = mpsc::channel(); - thread::spawn(move || match write_config(ipchange_rx) { - Ok(_) => {} - Err(e) => panic!("write_config error: {}", e), - }); + let clt = Client::new(config.clone())?; - clt.run(recv_tx.clone(), send_rx.clone(), ipchange_tx)?; + clt.run(recv_tx.clone(), send_rx.clone(), ipchange_tx.clone())?; send_tx.send(None)?; println!("connection lost"); |