Created upnp crate to port forward local ports
This commit is contained in:
parent
215bccb89c
commit
626c529000
6 changed files with 663 additions and 1 deletions
24
crates/upnp/examples/upnp-forward.rs
Normal file
24
crates/upnp/examples/upnp-forward.rs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
use librqbit_upnp::UpnpPortForwarder;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
tracing_subscriber::fmt::init();
|
||||
let args: Vec<String> = std::env::args().collect();
|
||||
if args.len() != 2 {
|
||||
eprintln!("Usage: {} <port>", args[0]);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let port: u16 = match args[1].parse() {
|
||||
Ok(p) => p,
|
||||
Err(_) => {
|
||||
eprintln!("Invalid port number: {}", args[1]);
|
||||
return Ok(());
|
||||
}
|
||||
};
|
||||
|
||||
let port_forwarder = UpnpPortForwarder::new(vec![port], None)?;
|
||||
|
||||
port_forwarder.run_forever().await;
|
||||
Ok(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue