Merge remote-tracking branch 'origin/mr/156'
This commit is contained in:
commit
08267147ec
|
@ -95,7 +95,6 @@ pub struct TorAddr {
|
||||||
/// The target host.
|
/// The target host.
|
||||||
host: Host,
|
host: Host,
|
||||||
/// The target port number.
|
/// The target port number.
|
||||||
// TODO: reject port 0.
|
|
||||||
port: u16,
|
port: u16,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,10 +246,14 @@ impl IntoTorAddr for &str {
|
||||||
let (host, port) = self.rsplit_once(':').ok_or(TorAddrError::NoPort)?;
|
let (host, port) = self.rsplit_once(':').ok_or(TorAddrError::NoPort)?;
|
||||||
let host = host.parse()?;
|
let host = host.parse()?;
|
||||||
let port = port.parse().map_err(|_| TorAddrError::BadPort)?;
|
let port = port.parse().map_err(|_| TorAddrError::BadPort)?;
|
||||||
|
if port == 0 {
|
||||||
|
Err(TorAddrError::BadPort)
|
||||||
|
} else {
|
||||||
Ok(TorAddr { host, port })
|
Ok(TorAddr { host, port })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl IntoTorAddr for String {
|
impl IntoTorAddr for String {
|
||||||
fn into_tor_addr(self) -> Result<TorAddr, TorAddrError> {
|
fn into_tor_addr(self) -> Result<TorAddr, TorAddrError> {
|
||||||
|
|
Loading…
Reference in New Issue