mirror of https://github.com/dswd/vpncloud.git
Allow default port for peers
This commit is contained in:
parent
46c8407db9
commit
f210f75a25
10
src/cloud.rs
10
src/cloud.rs
|
@ -373,8 +373,14 @@ impl<D: Device, P: Protocol, S: Socket, TS: TimeSource> GenericCloud<D, P, S, TS
|
||||||
// Resolve entries anew
|
// Resolve entries anew
|
||||||
if let Some((ref address, ref mut next_resolve)) = entry.address {
|
if let Some((ref address, ref mut next_resolve)) = entry.address {
|
||||||
if *next_resolve <= now {
|
if *next_resolve <= now {
|
||||||
if let Ok(addrs) = resolve(address as &str) {
|
match resolve(address as &str) {
|
||||||
entry.resolved = addrs;
|
Ok(addrs) => entry.resolved = addrs,
|
||||||
|
Err(_) => {
|
||||||
|
match resolve(&format!("{}:{}", address, DEFAULT_PORT)) {
|
||||||
|
Ok(addrs) => entry.resolved = addrs,
|
||||||
|
Err(err) => warn!("Failed to resolve {}: {}", address, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
*next_resolve = now + RESOLVE_INTERVAL;
|
*next_resolve = now + RESOLVE_INTERVAL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,8 @@ use crate::error::Error;
|
||||||
#[cfg(not(target_os = "linux"))] use time;
|
#[cfg(not(target_os = "linux"))] use time;
|
||||||
|
|
||||||
use signal::{trap::Trap, Signal};
|
use signal::{trap::Trap, Signal};
|
||||||
use std::time::Instant;
|
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
|
use std::time::Instant;
|
||||||
|
|
||||||
|
|
||||||
pub type Duration = u32;
|
pub type Duration = u32;
|
||||||
|
@ -218,9 +218,8 @@ pub fn get_internal_ip() -> Ipv4Addr {
|
||||||
|
|
||||||
#[allow(unknown_lints, clippy::needless_pass_by_value)]
|
#[allow(unknown_lints, clippy::needless_pass_by_value)]
|
||||||
pub fn resolve<Addr: ToSocketAddrs + fmt::Debug>(addr: Addr) -> Result<SmallVec<[SocketAddr; 3]>, Error> {
|
pub fn resolve<Addr: ToSocketAddrs + fmt::Debug>(addr: Addr) -> Result<SmallVec<[SocketAddr; 3]>, Error> {
|
||||||
let addrs = addr.to_socket_addrs().map_err(|_| Error::NameUnresolvable(format!("{:?}", addr)))?;
|
let mut addrs =
|
||||||
// Remove duplicates in addrs (why are there duplicates???)
|
addr.to_socket_addrs().map_err(|_| Error::NameUnresolvable(format!("{:?}", addr)))?.collect::<SmallVec<_>>();
|
||||||
let mut addrs = addrs.collect::<SmallVec<_>>();
|
|
||||||
// Try IPv4 first as it usually is faster
|
// Try IPv4 first as it usually is faster
|
||||||
addrs.sort_by_key(|addr| {
|
addrs.sort_by_key(|addr| {
|
||||||
match *addr {
|
match *addr {
|
||||||
|
@ -228,6 +227,7 @@ pub fn resolve<Addr: ToSocketAddrs + fmt::Debug>(addr: Addr) -> Result<SmallVec<
|
||||||
SocketAddr::V6(_) => 6
|
SocketAddr::V6(_) => 6
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// Remove duplicates in addrs (why are there duplicates???)
|
||||||
addrs.dedup();
|
addrs.dedup();
|
||||||
Ok(addrs)
|
Ok(addrs)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue