Add default port for peers

pull/68/head
Dennis Schwerdel 2 years ago
parent 6b30f9e77c
commit 2f5ce0b194
  1. 2
      CHANGELOG.md
  2. 4
      rustfmt.toml
  3. 7
      src/cloud.rs
  4. 1
      src/config.rs
  5. 2
      src/types.rs

@ -6,10 +6,10 @@ This project follows [semantic versioning](http://semver.org).
### UNRELEASED
- [added] Added crypto option AES128
- [added] Default port for peers
- [changed] Updated dependencies
- [fixed] Fixed keepalive for small timeouts
### v1.4.0 (2020-06-03)
- [added] Added option to listen on specified IP

@ -14,4 +14,6 @@ wrap_comments = true
overflow_delimited_expr = true
blank_lines_upper_bound = 2
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::{
beacon::BeaconSerializer,
config::{Config, DEFAULT_PEER_TIMEOUT},
config::{Config, DEFAULT_PEER_TIMEOUT, DEFAULT_PORT},
crypto::Crypto,
device::Device,
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
/// 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();
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) {
Ok(addrs) => addrs,
Err(err) => {

@ -21,6 +21,7 @@ use std::{
const HASH_PREFIX: &str = "hash:";
pub const DEFAULT_PEER_TIMEOUT: u16 = 600;
pub const DEFAULT_PORT: u16 = 3210;
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!((addr, 7), Address::read_from(&buf).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;
assert!(Address::read_from(&buf).is_err()); // Invalid address, too long
buf[0] = 5;

Loading…
Cancel
Save