You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But aside from that, is a-ok. For file transfer, and 32+ player games, we need path MTU discovery.
Otherwise, combine with igd for UPnP
use igd::{search_gateway, Gateway};
use std::net::Ipv4Addr;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Search for the gateway
let gateway = search_gateway(Default::default())?;
// The local address to map (usually your computer's local IP)
let local_addr = Ipv4Addr::new(192, 168, 1, 100); // Replace with your actual local IP
// The external port you want to open
let external_port = 12345;
// The internal port you want to map to (can be the same as external_port)
let internal_port = 12345;
// The protocol (TCP or UDP)
let protocol = igd::PortMappingProtocol::TCP;
// The lease duration in seconds (0 for indefinite)
let lease_duration = 0;
// The description for this port mapping
let description = "My Rust Application";
// Add the port mapping
gateway.add_port(protocol, external_port, (local_addr, internal_port), lease_duration, description)?;
println!("Port {} opened successfully", external_port);
Ok(())
}
Needs some header size optimization, like here: https://github.com/TimonPost/laminar/blob/e8ffb26a915bb6ac3c8d959031d63f8a776e763c/src/packet/header/standard_header.rs#L88
But aside from that, is a-ok. For file transfer, and 32+ player games, we need path MTU discovery.
Otherwise, combine with
igd
for UPnPand with a port of MLAPI.Puncher to Rust
The text was updated successfully, but these errors were encountered: