logout and port forwarding
This commit is contained in:
		| @@ -1,7 +1,10 @@ | ||||
| use std::env; | ||||
| use std::{env, net::Ipv4Addr}; | ||||
|  | ||||
| use color_eyre::Result; | ||||
| use connectbox::ConnectBox; | ||||
| use connectbox::{ | ||||
|     models::{PortForwardEntry, PortForwardProtocol}, | ||||
|     ConnectBox, PortForwardAction, | ||||
| }; | ||||
|  | ||||
| #[tokio::main(flavor = "current_thread")] | ||||
| async fn main() -> Result<()> { | ||||
| @@ -14,8 +17,32 @@ async fn main() -> Result<()> { | ||||
|     let connect_box = ConnectBox::new(ip, code, true)?; | ||||
|     connect_box.login().await?; | ||||
|  | ||||
|     let devices = connect_box.get_devices().await?; | ||||
|     println!("{devices:#?}"); | ||||
|     connect_box | ||||
|         .edit_port_forwards(|v| { | ||||
|             if v.local_ip == Ipv4Addr::new(192, 168, 0, 180) { | ||||
|                 PortForwardAction::Delete | ||||
|             } else { | ||||
|                 PortForwardAction::Keep | ||||
|             } | ||||
|         }) | ||||
|         .await?; | ||||
|  | ||||
|     let pf = PortForwardEntry { | ||||
|         id: 0, | ||||
|         local_ip: "192.168.0.180".parse().unwrap(), | ||||
|         start_port: 25565, | ||||
|         end_port: 25565, | ||||
|         start_port_in: 25565, | ||||
|         end_port_in: 25565, | ||||
|         protocol: PortForwardProtocol::Both, | ||||
|         enable: true, | ||||
|     }; | ||||
|     connect_box.add_port_forward(&pf).await?; | ||||
|  | ||||
|     let portforwards = connect_box.port_forwards().await?; | ||||
|     println!("{portforwards:#?}"); | ||||
|  | ||||
|     connect_box.logout().await?; | ||||
|  | ||||
|     Ok(()) | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user