From 2f5ce0b1948b5bdbe2df50d3a447cb4d6ded8b2e Mon Sep 17 00:00:00 2001 From: Dennis Schwerdel Date: Wed, 24 Jun 2020 15:28:16 +0200 Subject: [PATCH] Add default port for peers --- CHANGELOG.md | 2 +- rustfmt.toml | 4 +++- src/cloud.rs | 7 +++++-- src/config.rs | 1 + src/types.rs | 2 +- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fd9225..df07a20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/rustfmt.toml b/rustfmt.toml index 49a3e5c..8d19d96 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -14,4 +14,6 @@ wrap_comments = true overflow_delimited_expr = true blank_lines_upper_bound = 2 normalize_doc_attributes = true -inline_attribute_width = 50 \ No newline at end of file +inline_attribute_width = 50 +edition = "2018" +reorder_impl_items = true \ No newline at end of file diff --git a/src/cloud.rs b/src/cloud.rs index 88865e5..bb354dd 100644 --- a/src/cloud.rs +++ b/src/cloud.rs @@ -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 GenericCloud addrs, Err(err) => { diff --git a/src/config.rs b/src/config.rs index ce09a76..5474c21 100644 --- a/src/config.rs +++ b/src/config.rs @@ -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 { diff --git a/src/types.rs b/src/types.rs index 51dcb21..27c19cd 100644 --- a/src/types.rs +++ b/src/types.rs @@ -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;