Automatic port forwarding using UPnP and invitation link system #27

Merged
CoCo_Sol merged 6 commits from upnp into main 2024-02-07 16:55:09 +00:00
Showing only changes of commit ddf5b38905 - Show all commits

View file

@ -101,7 +101,7 @@ impl Connection {
let data = BASE64_URL_SAFE_NO_PAD
.decode(connection_string)
.map_err(io::Error::other)?;
if data.len() != 6 {
if data.len() != 22 {
return Err(io::Error::new(
io::ErrorKind::InvalidInput,
format!("invalid connection string: {}", connection_string),
@ -372,9 +372,10 @@ impl Listener {
/// Returns the connection string that can be used to connect to th
/// listener.
pub fn connection_string(&self) -> String {
let mut data = Vec::with_capacity(24);
let mut data = Vec::with_capacity(22);
data.extend(self.2.ip().octets());
data.extend(self.2.port().to_ne_bytes());
data.extend(self.3);
BASE64_URL_SAFE_NO_PAD.encode(&data)
}
}