generated from tipragot/rust
Automatic port forwarding using UPnP and invitation link system #27
|
@ -101,7 +101,7 @@ impl Connection {
|
||||||
let data = BASE64_URL_SAFE_NO_PAD
|
let data = BASE64_URL_SAFE_NO_PAD
|
||||||
.decode(connection_string)
|
.decode(connection_string)
|
||||||
.map_err(io::Error::other)?;
|
.map_err(io::Error::other)?;
|
||||||
if data.len() != 6 {
|
if data.len() != 22 {
|
||||||
return Err(io::Error::new(
|
return Err(io::Error::new(
|
||||||
io::ErrorKind::InvalidInput,
|
io::ErrorKind::InvalidInput,
|
||||||
format!("invalid connection string: {}", connection_string),
|
format!("invalid connection string: {}", connection_string),
|
||||||
|
@ -372,9 +372,10 @@ impl Listener {
|
||||||
/// Returns the connection string that can be used to connect to th
|
/// Returns the connection string that can be used to connect to th
|
||||||
/// listener.
|
/// listener.
|
||||||
pub fn connection_string(&self) -> String {
|
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.ip().octets());
|
||||||
data.extend(self.2.port().to_ne_bytes());
|
data.extend(self.2.port().to_ne_bytes());
|
||||||
|
data.extend(self.3);
|
||||||
BASE64_URL_SAFE_NO_PAD.encode(&data)
|
BASE64_URL_SAFE_NO_PAD.encode(&data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue