mirror of https://github.com/dswd/vpncloud.git
Add default port for peers
This commit is contained in:
parent
6b30f9e77c
commit
2f5ce0b194
|
@ -6,10 +6,10 @@ This project follows [semantic versioning](http://semver.org).
|
||||||
### UNRELEASED
|
### UNRELEASED
|
||||||
|
|
||||||
- [added] Added crypto option AES128
|
- [added] Added crypto option AES128
|
||||||
|
- [added] Default port for peers
|
||||||
- [changed] Updated dependencies
|
- [changed] Updated dependencies
|
||||||
- [fixed] Fixed keepalive for small timeouts
|
- [fixed] Fixed keepalive for small timeouts
|
||||||
|
|
||||||
|
|
||||||
### v1.4.0 (2020-06-03)
|
### v1.4.0 (2020-06-03)
|
||||||
|
|
||||||
- [added] Added option to listen on specified IP
|
- [added] Added option to listen on specified IP
|
||||||
|
|
|
@ -15,3 +15,5 @@ overflow_delimited_expr = true
|
||||||
blank_lines_upper_bound = 2
|
blank_lines_upper_bound = 2
|
||||||
normalize_doc_attributes = true
|
normalize_doc_attributes = true
|
||||||
inline_attribute_width = 50
|
inline_attribute_width = 50
|
||||||
|
edition = "2018"
|
||||||
|
reorder_impl_items = true
|
|
@ -19,7 +19,7 @@ use rand::{prelude::*, random, thread_rng};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
beacon::BeaconSerializer,
|
beacon::BeaconSerializer,
|
||||||
config::{Config, DEFAULT_PEER_TIMEOUT},
|
config::{Config, DEFAULT_PEER_TIMEOUT, DEFAULT_PORT},
|
||||||
crypto::Crypto,
|
crypto::Crypto,
|
||||||
device::Device,
|
device::Device,
|
||||||
net::Socket,
|
net::Socket,
|
||||||
|
@ -364,8 +364,11 @@ impl<D: Device, P: Protocol, T: Table, S: Socket, TS: TimeSource> GenericCloud<D
|
||||||
///
|
///
|
||||||
/// This method adds a peer to the list of nodes to reconnect to. A periodic task will try to
|
/// This method adds a peer to the list of nodes to reconnect to. A periodic task will try to
|
||||||
/// connect to the peer if it is not already connected.
|
/// connect to the peer if it is not already connected.
|
||||||
pub fn add_reconnect_peer(&mut self, add: String) {
|
pub fn add_reconnect_peer(&mut self, mut add: String) {
|
||||||
let now = TS::now();
|
let now = TS::now();
|
||||||
|
if add.find(':').unwrap_or(0) <= add.find(']').unwrap_or(0) { // : not present or only in IPv6 address
|
||||||
|
add = format!("{}:{}", add, DEFAULT_PORT)
|
||||||
|
}
|
||||||
let resolved = match resolve(&add as &str) {
|
let resolved = match resolve(&add as &str) {
|
||||||
Ok(addrs) => addrs,
|
Ok(addrs) => addrs,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
|
|
@ -21,6 +21,7 @@ use std::{
|
||||||
|
|
||||||
const HASH_PREFIX: &str = "hash:";
|
const HASH_PREFIX: &str = "hash:";
|
||||||
pub const DEFAULT_PEER_TIMEOUT: u16 = 600;
|
pub const DEFAULT_PEER_TIMEOUT: u16 = 600;
|
||||||
|
pub const DEFAULT_PORT: u16 = 3210;
|
||||||
|
|
||||||
|
|
||||||
fn parse_listen(addr: &str) -> SocketAddr {
|
fn parse_listen(addr: &str) -> SocketAddr {
|
||||||
|
|
|
@ -293,7 +293,7 @@ fn address_decode_encode() {
|
||||||
assert_eq!(&buf[0..7], &[6, 0x78, 0x2d, 0x16, 0x05, 0x01, 0x02]);
|
assert_eq!(&buf[0..7], &[6, 0x78, 0x2d, 0x16, 0x05, 0x01, 0x02]);
|
||||||
assert_eq!((addr, 7), Address::read_from(&buf).unwrap());
|
assert_eq!((addr, 7), Address::read_from(&buf).unwrap());
|
||||||
assert_eq!(addr, Address::read_from_fixed(&buf[1..], 6).unwrap());
|
assert_eq!(addr, Address::read_from_fixed(&buf[1..], 6).unwrap());
|
||||||
assert!(Address::read_from(&buf[0..0]).is_err()); // Address too short
|
assert!(Address::read_from(&buf[0..1]).is_err()); // Address too short
|
||||||
buf[0] = 100;
|
buf[0] = 100;
|
||||||
assert!(Address::read_from(&buf).is_err()); // Invalid address, too long
|
assert!(Address::read_from(&buf).is_err()); // Invalid address, too long
|
||||||
buf[0] = 5;
|
buf[0] = 5;
|
||||||
|
|
Loading…
Reference in New Issue