Compare commits

..

12 Commits

Author SHA1 Message Date
Dennis Schwerdel 32abf1a34c Typo 2019-03-02 01:13:35 +01:00
Dennis Schwerdel aa715b8c1d Merge branch 'ZpmFred-master' 2019-03-02 01:13:08 +01:00
Dennis Schwerdel 7fdc0ef49d Modified rpm build process 2019-03-02 01:12:42 +01:00
Dennis Schwerdel 87635ca07f Merge branch 'master' into ZpmFred-master 2019-03-02 00:51:05 +01:00
Dennis Schwerdel 3cc40ff8d1 Updates 2019-03-02 00:50:55 +01:00
Dennis Schwerdel f2e6a1ef7b Clippy 2019-03-01 23:25:42 +01:00
Dennis Schwerdel 706d205ff1 Edition 2018 2019-03-01 23:12:19 +01:00
Dennis Schwerdel a6825504a5 Merge branch 'master' of https://github.com/ZpmFred/vpncloud into ZpmFred-master 2019-03-01 17:08:23 +01:00
ZpmFred 05b359fd1f
More detailed rpm build doc 2019-03-01 16:11:53 +01:00
ZpmFred 51c2cc5eb0
CentOS case fix 2019-03-01 15:57:01 +01:00
ZpmFred 312276229e
rpm package doc 2019-03-01 15:54:32 +01:00
ZpmFred d24354c5eb
rpm build 2019-02-28 15:39:41 +01:00
20 changed files with 300 additions and 236 deletions

44
.rpm/vpncloud.spec Normal file
View File

@ -0,0 +1,44 @@
%define __spec_install_post %{nil}
%define __os_install_post %{_dbpath}/brp-compress
%define debug_package %{nil}
Name: vpncloud
Summary: Peer-to-peer VPN
Version: @@VERSION@@
Release: 1
License: GPL-3.0
Group: Applications/System
Source0: %{name}-%{version}.tar.gz
URL: https://vpncloud.ddswd.de
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
%description
%{summary}
%prep
%setup -q
%install
rm -rf %{buildroot}
mkdir -p %{buildroot}
mkdir -p %{buildroot}/etc/vpncloud
mkdir -p %{buildroot}/lib/systemd/system
mkdir -p %{buildroot}/usr/share/man/man1
cp %{buildroot}/../../../../../assets/example.net.disabled %{buildroot}/etc/vpncloud/example.net.disabled
cp %{buildroot}/../../../../../assets/vpncloud@.service %{buildroot}/lib/systemd/system/vpncloud@.service
cp %{buildroot}/../../../../../target/vpncloud.1.gz %{buildroot}/usr/share/man/man1/vpncloud.1.gz
cp -a * %{buildroot}
%clean
rm -rf %{buildroot}
%files
/etc/vpncloud
/etc/vpncloud/example.net.disabled
/usr/bin/vpncloud
/lib/systemd/system/vpncloud@.service
/usr/share/man/man1/vpncloud.1.gz
%defattr(-,root,root,-)
%{_bindir}/*

View File

@ -5,7 +5,12 @@ This project follows [semantic versioning](http://semver.org).
### UNRELEASED ### UNRELEASED
- [added] Added ability to publish small beacons for rendezvous - [added] Added ability to publish small beacons for rendezvous
- [added] Added build chain for packages
- [added] Added more tests
- [changed] Allow to build binary without manpage - [changed] Allow to build binary without manpage
- [changed] Rust edition 2018
- [changed] Rust version 1.33.0
- [changed] Updated dependencies
- [fixed] Fixed bug that could cause repeated initialization messages - [fixed] Fixed bug that could cause repeated initialization messages
### v0.9.1 (2019-02-16) ### v0.9.1 (2019-02-16)

158
Cargo.lock generated
View File

@ -1,6 +1,6 @@
[[package]] [[package]]
name = "aho-corasick" name = "aho-corasick"
version = "0.6.9" version = "0.6.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -13,13 +13,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "backtrace" name = "backtrace"
version = "0.3.13" version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -29,8 +29,8 @@ name = "backtrace-sys"
version = "0.1.28" version = "0.1.28"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"cc 1.0.29 (registry+https://github.com/rust-lang/crates.io-index)", "cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -70,7 +70,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.0.29" version = "1.0.30"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
@ -91,7 +91,7 @@ name = "daemonize"
version = "0.3.0" version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -99,10 +99,10 @@ name = "docopt"
version = "1.0.2" version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
"strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -116,7 +116,7 @@ name = "failure"
version = "0.1.5" version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"backtrace 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", "backtrace 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
"failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -127,7 +127,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.27 (registry+https://github.com/rust-lang/crates.io-index)",
"synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -193,12 +193,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "lazy_static" name = "lazy_static"
version = "1.2.0" version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.48" version = "0.2.49"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
@ -246,7 +246,7 @@ version = "0.2.33"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -256,9 +256,9 @@ version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"cc 1.0.29 (registry+https://github.com/rust-lang/crates.io-index)", "cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)",
"void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -289,7 +289,7 @@ name = "num_cpus"
version = "1.10.0" version = "1.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -323,7 +323,7 @@ name = "rand"
version = "0.3.23" version = "0.3.23"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -333,7 +333,7 @@ version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
@ -345,14 +345,14 @@ version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_jitter 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand_jitter 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_os 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand_os 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_pcg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -400,7 +400,7 @@ name = "rand_jitter"
version = "0.1.3" version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -412,7 +412,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
@ -420,11 +420,11 @@ dependencies = [
[[package]] [[package]]
name = "rand_pcg" name = "rand_pcg"
version = "0.1.1" version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -453,7 +453,7 @@ name = "regex"
version = "0.2.11" version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "aho-corasick 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)",
"memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"regex-syntax 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "regex-syntax 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
"thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
@ -462,10 +462,10 @@ dependencies = [
[[package]] [[package]]
name = "regex" name = "regex"
version = "1.1.0" version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "aho-corasick 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)",
"memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"regex-syntax 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "regex-syntax 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
@ -501,9 +501,9 @@ name = "ring"
version = "0.14.6" version = "0.14.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"cc 1.0.29 (registry+https://github.com/rust-lang/crates.io-index)", "cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)",
"spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
@ -514,45 +514,24 @@ name = "rustc-demangle"
version = "0.1.13" version = "0.1.13"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "rustc_version"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "safemem" name = "safemem"
version = "0.3.0" version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "semver"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "semver-parser"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.87" version = "1.0.89"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.87" version = "1.0.89"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.27 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -562,7 +541,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"dtoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "dtoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"linked-hash-map 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "linked-hash-map 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
"yaml-rust 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "yaml-rust 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -571,7 +550,7 @@ name = "signal"
version = "0.6.0" version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)",
"nix 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "nix 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -582,11 +561,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "smallvec" name = "smallvec"
version = "0.6.8" version = "0.6.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "spin" name = "spin"
@ -600,7 +576,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "syn" name = "syn"
version = "0.15.26" version = "0.15.27"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
@ -615,7 +591,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.27 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -625,7 +601,7 @@ version = "3.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)",
"remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -637,7 +613,7 @@ name = "thread_local"
version = "0.3.6" version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -645,7 +621,7 @@ name = "time"
version = "0.1.42" version = "0.1.42"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -686,7 +662,7 @@ name = "unicode-normalization"
version = "0.1.8" version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"smallvec 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -694,14 +670,6 @@ name = "unicode-xid"
version = "0.1.0" version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "unreachable"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "untrusted" name = "untrusted"
version = "0.6.2" version = "0.6.2"
@ -737,19 +705,19 @@ name = "vpncloud"
version = "0.9.1" version = "0.9.1"
dependencies = [ dependencies = [
"base-62 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "base-62 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"cc 1.0.29 (registry+https://github.com/rust-lang/crates.io-index)", "cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)",
"daemonize 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "daemonize 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"docopt 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "docopt 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"igd 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "igd 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_yaml 0.8.8 (registry+https://github.com/rust-lang/crates.io-index)", "serde_yaml 0.8.8 (registry+https://github.com/rust-lang/crates.io-index)",
"signal 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "signal 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"siphasher 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "siphasher 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -802,16 +770,16 @@ dependencies = [
] ]
[metadata] [metadata]
"checksum aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9a933f4e58658d7b12defcf96dc5c720f20832deebe3e0a19efd3b6aaeeb9e" "checksum aho-corasick 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "81ce3d38065e618af2d7b77e10c5ad9a069859b4be3c2250f674af3840d9c8a5"
"checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799" "checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799"
"checksum backtrace 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)" = "b5b493b66e03090ebc4343eb02f94ff944e0cbc9ac6571491d170ba026741eb5" "checksum backtrace 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "cd5a90e2b463010cd0e0ce9a11d4a9d5d58d9f41d4a6ba3dcaf9e68b466e88b4"
"checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6"
"checksum base-62 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f28ebd71b3e708e895b83ec2d35c6e2ef96e34945706bf4d73826354e84f89b2" "checksum base-62 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f28ebd71b3e708e895b83ec2d35c6e2ef96e34945706bf4d73826354e84f89b2"
"checksum base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "489d6c0ed21b11d038c31b6ceccca973e65d73ba3bd8ecb9a2babf5546164643" "checksum base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "489d6c0ed21b11d038c31b6ceccca973e65d73ba3bd8ecb9a2babf5546164643"
"checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d"
"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12"
"checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb" "checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb"
"checksum cc 1.0.29 (registry+https://github.com/rust-lang/crates.io-index)" = "4390a3b5f4f6bce9c1d0c00128379df433e53777fdd30e92f16a529332baec4e" "checksum cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)" = "d01c69d08ff207f231f07196e30f84c70f1c815b04f980f8b7b01ff01f05eb92"
"checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4" "checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4"
"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
"checksum daemonize 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4093d27eb267d617f03c2ee25d4c3ca525b89a76154001954a11984508ffbde5" "checksum daemonize 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4093d27eb267d617f03c2ee25d4c3ca525b89a76154001954a11984508ffbde5"
@ -826,8 +794,8 @@ dependencies = [
"checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" "checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e"
"checksum igd 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "356a0dc23a4fa0f8ce4777258085d00a01ea4923b2efd93538fc44bf5e1bda76" "checksum igd 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "356a0dc23a4fa0f8ce4777258085d00a01ea4923b2efd93538fc44bf5e1bda76"
"checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" "checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a"
"checksum lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a374c89b9db55895453a74c1e38861d9deec0b01b405a82516e9d5de4820dea1" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14"
"checksum libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)" = "e962c7641008ac010fa60a7dfdc1712449f29c44ef2d4702394aea943ee75047" "checksum libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)" = "413f3dfc802c5dc91dc570b05125b6cda9855edfaa9825c9849807876376e70e"
"checksum linked-hash-map 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "70fb39025bc7cdd76305867c4eccf2f2dcf6e9a57f5b21a93e1c2d86cd03ec9e" "checksum linked-hash-map 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "70fb39025bc7cdd76305867c4eccf2f2dcf6e9a57f5b21a93e1c2d86cd03ec9e"
"checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" "checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b"
"checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6"
@ -854,30 +822,27 @@ dependencies = [
"checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" "checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08"
"checksum rand_jitter 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b9ea758282efe12823e0d952ddb269d2e1897227e464919a554f2a03ef1b832" "checksum rand_jitter 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b9ea758282efe12823e0d952ddb269d2e1897227e464919a554f2a03ef1b832"
"checksum rand_os 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b7c690732391ae0abafced5015ffb53656abfaec61b342290e5eb56b286a679d" "checksum rand_os 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b7c690732391ae0abafced5015ffb53656abfaec61b342290e5eb56b286a679d"
"checksum rand_pcg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "086bd09a33c7044e56bb44d5bdde5a60e7f119a9e95b0775f545de759a32fe05" "checksum rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44"
"checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" "checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c"
"checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
"checksum redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)" = "423e376fffca3dfa06c9e9790a9ccd282fafb3cc6e6397d01dbf64f9bacc6b85" "checksum redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)" = "423e376fffca3dfa06c9e9790a9ccd282fafb3cc6e6397d01dbf64f9bacc6b85"
"checksum regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9329abc99e39129fcceabd24cf5d85b4671ef7c29c50e972bc5afe32438ec384" "checksum regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9329abc99e39129fcceabd24cf5d85b4671ef7c29c50e972bc5afe32438ec384"
"checksum regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "37e7cbbd370869ce2e8dff25c7018702d10b21a20ef7135316f8daecd6c25b7f" "checksum regex 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "53ee8cfdddb2e0291adfb9f13d31d3bbe0a03c9a402c01b1e24188d86c35b24f"
"checksum regex-syntax 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7d707a4fa2637f2dca2ef9fd02225ec7661fe01a53623c1e6515b6916511f7a7" "checksum regex-syntax 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7d707a4fa2637f2dca2ef9fd02225ec7661fe01a53623c1e6515b6916511f7a7"
"checksum regex-syntax 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8c2f35eedad5295fdf00a63d7d4b238135723f92b434ec06774dad15c7ab0861" "checksum regex-syntax 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8c2f35eedad5295fdf00a63d7d4b238135723f92b434ec06774dad15c7ab0861"
"checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5"
"checksum ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)" = "426bc186e3e95cac1e4a4be125a4aca7e84c2d616ffc02244eef36e2a60a093c" "checksum ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)" = "426bc186e3e95cac1e4a4be125a4aca7e84c2d616ffc02244eef36e2a60a093c"
"checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619" "checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619"
"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
"checksum safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dca453248a96cb0749e36ccdfe2b0b4e54a61bfef89fb97ec621eb8e0a93dd9" "checksum safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dca453248a96cb0749e36ccdfe2b0b4e54a61bfef89fb97ec621eb8e0a93dd9"
"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)" = "92514fb95f900c9b5126e32d020f5c6d40564c27a5ea6d1d7d9f157a96623560"
"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)" = "bb6eabf4b5914e88e24eea240bb7c9f9a2cbc1bbbe8d961d381975ec3c6b806c"
"checksum serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)" = "2e20fde37801e83c891a2dc4ebd3b81f0da4d1fb67a9e0a2a3b921e2536a58ee"
"checksum serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)" = "633e97856567e518b59ffb2ad7c7a4fd4c5d91d9c7f32dd38a27b2bf7e8114ea"
"checksum serde_yaml 0.8.8 (registry+https://github.com/rust-lang/crates.io-index)" = "0887a8e097a69559b56aa2526bf7aff7c3048cf627dff781f0b56a6001534593" "checksum serde_yaml 0.8.8 (registry+https://github.com/rust-lang/crates.io-index)" = "0887a8e097a69559b56aa2526bf7aff7c3048cf627dff781f0b56a6001534593"
"checksum signal 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "106428d9d96840ecdec5208c13ab8a4e28c38da1e0ccf2909fb44e41b992f897" "checksum signal 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "106428d9d96840ecdec5208c13ab8a4e28c38da1e0ccf2909fb44e41b992f897"
"checksum siphasher 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9913c75df657d84a03fa689c016b0bb2863ff0b497b26a8d6e9703f8d5df03a8" "checksum siphasher 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9913c75df657d84a03fa689c016b0bb2863ff0b497b26a8d6e9703f8d5df03a8"
"checksum smallvec 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "88aea073965ab29f6edb5493faf96ad662fb18aa9eeb186a3b7057951605ed15" "checksum smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c4488ae950c49d403731982257768f48fada354a5203fe81f9bb6f43ca9002be"
"checksum spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44363f6f51401c34e7be73db0db371c04705d35efbe9f7d6082e03a921a32c55" "checksum spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44363f6f51401c34e7be73db0db371c04705d35efbe9f7d6082e03a921a32c55"
"checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550"
"checksum syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)" = "f92e629aa1d9c827b2bb8297046c1ccffc57c99b947a680d3ccff1f136a3bee9" "checksum syn 0.15.27 (registry+https://github.com/rust-lang/crates.io-index)" = "525bd55255f03c816e5d7f615587bd13030c7103354fadb104993dcee6a788ec"
"checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" "checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015"
"checksum tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "b86c784c88d98c801132806dadd3819ed29d8600836c4088e855cdf3e178ed8a" "checksum tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "b86c784c88d98c801132806dadd3819ed29d8600836c4088e855cdf3e178ed8a"
"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b"
@ -889,7 +854,6 @@ dependencies = [
"checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5"
"checksum unicode-normalization 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "141339a08b982d942be2ca06ff8b076563cbe223d1befd5450716790d44e2426" "checksum unicode-normalization 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "141339a08b982d942be2ca06ff8b076563cbe223d1befd5450716790d44e2426"
"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
"checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56"
"checksum untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "55cd1f4b4e96b46aeb8d4855db4a7a9bd96eeeb5c6a1ab54593328761642ce2f" "checksum untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "55cd1f4b4e96b46aeb8d4855db4a7a9bd96eeeb5c6a1ab54593328761642ce2f"
"checksum url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" "checksum url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a"
"checksum utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "796f7e48bef87609f7ade7e06495a87d5cd06c7866e6a5cbfceffc558a243737" "checksum utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "796f7e48bef87609f7ade7e06495a87d5cd06c7866e6a5cbfceffc558a243737"

View File

@ -9,6 +9,7 @@ homepage = "https://vpncloud.ddswd.de"
repository = "https://github.com/dswd/vpncloud" repository = "https://github.com/dswd/vpncloud"
keywords = ["vpn", "p2p", "tun", "tap", "network"] keywords = ["vpn", "p2p", "tun", "tap", "network"]
readme = "README.md" readme = "README.md"
edition = "2018"
[dependencies] [dependencies]
time = "0.1" time = "0.1"
@ -39,7 +40,6 @@ tempfile = "3"
[features] [features]
default = [] default = []
bench = [] bench = []
system-libsodium = []
[profile.release] [profile.release]
lto = true lto = true
@ -65,3 +65,9 @@ assets = [
["assets/vpncloud@.service", "/lib/systemd/system/vpncloud@.service", "644"], ["assets/vpncloud@.service", "/lib/systemd/system/vpncloud@.service", "644"],
["target/vpncloud.1.gz", "/usr/share/man/man1/vpncloud.1.gz", "644"] ["target/vpncloud.1.gz", "/usr/share/man/man1/vpncloud.1.gz", "644"]
] ]
[package.metadata.rpm.cargo]
buildflags = ["--release"]
[package.metadata.rpm.targets]
vpncloud = { path = "/usr/bin/vpncloud" }

View File

@ -74,6 +74,19 @@ Debian packages can be built using [cargo-deb](https://github.com/mmstick/cargo-
There is a [VpnCloud package for Arch Linux](https://aur.archlinux.org/packages/vpncloud/) There is a [VpnCloud package for Arch Linux](https://aur.archlinux.org/packages/vpncloud/)
thanks to Oscar Rainford (fourbytes). thanks to Oscar Rainford (fourbytes).
#### CentOS 7 (maybe other RPM based)
CentOS 7 .rpm package can be built using [cargo-rpm](https://github.com/RustRPM/cargo-rpm): ``cargo rpm``
On an CentOS 7:
1. Install the required build environment (on CentOS 7)
$> yum groupinstall -y 'Development Tools'
2. Build the software
$> cargo rpm build
rpm will be situated in `target/release/rpmbuild/RPMS/`
### Contributions welcome ### Contributions welcome
There are several areas in which still some work has to be done and where There are several areas in which still some work has to be done and where

View File

@ -9,7 +9,7 @@ RUN useradd -ms /bin/bash user
USER user USER user
WORKDIR /home/user WORKDIR /home/user
ENV RUST=1.32.0 ENV RUST=1.33.0
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain ${RUST} RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain ${RUST}

24
builder/Dockerfile-rpm Normal file
View File

@ -0,0 +1,24 @@
FROM centos:latest
RUN yum groupinstall -y 'Development Tools'
RUN useradd -ms /bin/bash user
USER user
WORKDIR /home/user
ENV RUST=1.33.0
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain ${RUST}
ENV PATH=/home/user/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
RUN rustup target add i686-unknown-linux-gnu \
&& rustup target add armv7-unknown-linux-gnueabihf
RUN cargo install cargo-rpm \
&& rm -rf /home/user/.cargo/{git,tmp,registry}
VOLUME /home/user/.cargo/tmp
VOLUME /home/user/.cargo/git
VOLUME /home/user/.cargo/registry

View File

@ -30,3 +30,10 @@ cp ../target/debian/vpncloud_${VERSION}_amd64.deb ../dist/vpncloud_${VERSION}_am
# arm7hf deb # arm7hf deb
docker_cmd deb 'cd code && cargo deb --target armv7-unknown-linux-gnueabihf' docker_cmd deb 'cd code && cargo deb --target armv7-unknown-linux-gnueabihf'
cp ../target/armv7-unknown-linux-gnueabihf/debian/vpncloud_${VERSION}_armhf.deb ../dist/vpncloud_${VERSION}_armhf.deb cp ../target/armv7-unknown-linux-gnueabihf/debian/vpncloud_${VERSION}_armhf.deb ../dist/vpncloud_${VERSION}_armhf.deb
docker build --rm -f=Dockerfile-rpm -t vpncloud-builder-rpm .
# x86_64 rpm
docker_cmd rpm 'cd code && cargo rpm build'
cp ../target/release/rpmbuild/RPMS/x86_64/vpncloud-${VERSION}-1.x86_64.rpm ../dist/vpncloud_${VERSION}.x86_64.rpm

View File

@ -31,7 +31,7 @@ fn base_62_sanitize(data: &str) -> String {
} }
fn sha512(data: &[u8]) -> Vec<u8> { fn sha512(data: &[u8]) -> Vec<u8> {
digest::digest(&digest::SHA512, data).as_ref().iter().map(|b| *b).collect() digest::digest(&digest::SHA512, data).as_ref().to_vec()
} }
struct FutureResult<T> { struct FutureResult<T> {
@ -72,6 +72,7 @@ impl<TS: TimeSource> BeaconSerializer<TS> {
sha512(&data) sha512(&data)
} }
#[allow(clippy::needless_range_loop)]
fn mask_with_keystream(&self, data: &mut [u8], type_: u8, seed: u8) { fn mask_with_keystream(&self, data: &mut [u8], type_: u8, seed: u8) {
let mut iter = 0; let mut iter = 0;
let mut mask = self.get_keystream(type_, seed, iter); let mut mask = self.get_keystream(type_, seed, iter);
@ -209,9 +210,9 @@ impl<TS: TimeSource> BeaconSerializer<TS> {
pub fn write_to_file<P: AsRef<Path>>(&self, peers: &[SocketAddr], path: P) -> Result<(), io::Error> { pub fn write_to_file<P: AsRef<Path>>(&self, peers: &[SocketAddr], path: P) -> Result<(), io::Error> {
let beacon = self.encode(peers); let beacon = self.encode(peers);
debug!("Beacon: {}", beacon); debug!("Beacon: {}", beacon);
let mut f = try!(File::create(&path)); let mut f = File::create(&path)?;
try!(writeln!(&mut f, "{}", beacon)); writeln!(&mut f, "{}", beacon)?;
try!(fs::set_permissions(&path, Permissions::from_mode(0o644))); fs::set_permissions(&path, Permissions::from_mode(0o644))?;
Ok(()) Ok(())
} }
@ -221,9 +222,9 @@ impl<TS: TimeSource> BeaconSerializer<TS> {
let end = self.end(); let end = self.end();
let beacon = format!("{}{}{}", begin, data, end); let beacon = format!("{}{}{}", begin, data, end);
debug!("Calling beacon command: {}", cmd); debug!("Calling beacon command: {}", cmd);
let process = try!(Command::new("sh").args(&["-c", cmd]) let process = Command::new("sh").args(&["-c", cmd])
.env("begin", begin).env("data", data).env("end", end).env("beacon", beacon) .env("begin", begin).env("data", data).env("end", end).env("beacon", beacon)
.stdout(Stdio::piped()).stderr(Stdio::piped()).spawn()); .stdout(Stdio::piped()).stderr(Stdio::piped()).spawn()?;
thread::spawn(move || { thread::spawn(move || {
let output = process.wait_with_output().expect("Failed to wait on child"); let output = process.wait_with_output().expect("Failed to wait on child");
if !output.status.success() { if !output.status.success() {
@ -256,9 +257,9 @@ impl<TS: TimeSource> BeaconSerializer<TS> {
} }
pub fn read_from_file<P: AsRef<Path>>(&self, path: P, ttl_hours: Option<u16>) -> Result<Vec<SocketAddr>, io::Error> { pub fn read_from_file<P: AsRef<Path>>(&self, path: P, ttl_hours: Option<u16>) -> Result<Vec<SocketAddr>, io::Error> {
let mut f = try!(File::open(&path)); let mut f = File::open(&path)?;
let mut contents = String::new(); let mut contents = String::new();
try!(f.read_to_string(&mut contents)); f.read_to_string(&mut contents)?;
Ok(self.decode(&contents, ttl_hours)) Ok(self.decode(&contents, ttl_hours))
} }
@ -266,9 +267,9 @@ impl<TS: TimeSource> BeaconSerializer<TS> {
let begin = self.begin(); let begin = self.begin();
let end = self.end(); let end = self.end();
debug!("Calling beacon command: {}", cmd); debug!("Calling beacon command: {}", cmd);
let process = try!(Command::new("sh").args(&["-c", cmd]) let process = Command::new("sh").args(&["-c", cmd])
.env("begin", begin).env("end", end) .env("begin", begin).env("end", end)
.stdout(Stdio::piped()).stderr(Stdio::piped()).spawn()); .stdout(Stdio::piped()).stderr(Stdio::piped()).spawn()?;
let this = self.clone(); let this = self.clone();
thread::spawn(move || { thread::spawn(move || {
let output = process.wait_with_output().expect("Failed to wait on child"); let output = process.wait_with_output().expect("Failed to wait on child");
@ -301,7 +302,7 @@ impl<TS: TimeSource> BeaconSerializer<TS> {
#[cfg(test)] use std::str::FromStr; #[cfg(test)] use std::str::FromStr;
#[cfg(test)] use std::time::Duration; #[cfg(test)] use std::time::Duration;
#[cfg(test)] use tempfile; #[cfg(test)] use tempfile;
#[cfg(test)] use ::util::MockTimeSource; #[cfg(test)] use crate::util::MockTimeSource;
#[test] #[test]
fn encode() { fn encode() {

View File

@ -87,7 +87,7 @@ impl<TS: TimeSource> PeerList<TS> {
#[inline] #[inline]
pub fn is_connected<Addr: ToSocketAddrs+fmt::Debug>(&self, addr: Addr) -> Result<bool, Error> { pub fn is_connected<Addr: ToSocketAddrs+fmt::Debug>(&self, addr: Addr) -> Result<bool, Error> {
for addr in try!(resolve(&addr)) { for addr in resolve(&addr)? {
if self.contains_addr(&addr) { if self.contains_addr(&addr) {
return Ok(true); return Ok(true);
} }
@ -143,7 +143,7 @@ impl<TS: TimeSource> PeerList<TS> {
#[inline] #[inline]
pub fn get_node_id(&self, addr: &SocketAddr) -> Option<NodeId> { pub fn get_node_id(&self, addr: &SocketAddr) -> Option<NodeId> {
self.addresses.get(addr).map(|n| *n) self.addresses.get(addr).cloned()
} }
#[inline] #[inline]
@ -181,10 +181,10 @@ impl<TS: TimeSource> PeerList<TS> {
#[inline] #[inline]
fn write_out<W: Write>(&self, out: &mut W) -> Result<(), io::Error> { fn write_out<W: Write>(&self, out: &mut W) -> Result<(), io::Error> {
try!(writeln!(out, "Peers:")); writeln!(out, "Peers:")?;
let now = TS::now(); let now = TS::now();
for (addr, data) in &self.peers { for (addr, data) in &self.peers {
try!(writeln!(out, " - {} (ttl: {} s)", addr, data.timeout-now)); writeln!(out, " - {} (ttl: {} s)", addr, data.timeout-now)?;
} }
Ok(()) Ok(())
} }
@ -230,6 +230,7 @@ pub struct GenericCloud<D: Device, P: Protocol, T: Table, S: Socket, TS: TimeSou
} }
impl<D: Device, P: Protocol, T: Table, S: Socket, TS: TimeSource> GenericCloud<D, P, T, S, TS> { impl<D: Device, P: Protocol, T: Table, S: Socket, TS: TimeSource> GenericCloud<D, P, T, S, TS> {
#[allow(clippy::too_many_arguments)]
pub fn new(config: &Config, device: D, table: T, pub fn new(config: &Config, device: D, table: T,
learning: bool, broadcast: bool, addresses: Vec<Range>, learning: bool, broadcast: bool, addresses: Vec<Range>,
crypto: Crypto, port_forwarding: Option<PortForwarding> crypto: Crypto, port_forwarding: Option<PortForwarding>
@ -271,7 +272,7 @@ impl<D: Device, P: Protocol, T: Table, S: Socket, TS: TimeSource> GenericCloud<D
_dummy_ts: PhantomData _dummy_ts: PhantomData
}; };
res.initialize(); res.initialize();
return res res
} }
#[inline] #[inline]
@ -292,15 +293,15 @@ impl<D: Device, P: Protocol, T: Table, S: Socket, TS: TimeSource> GenericCloud<D
let msg_data = encode(msg, &mut self.buffer_out, self.magic, &mut self.crypto); let msg_data = encode(msg, &mut self.buffer_out, self.magic, &mut self.crypto);
for addr in self.peers.peers.keys() { for addr in self.peers.peers.keys() {
self.traffic.count_out_traffic(*addr, msg_data.len()); self.traffic.count_out_traffic(*addr, msg_data.len());
let mut socket = match *addr { let socket = match *addr {
SocketAddr::V4(_) => &mut self.socket4, SocketAddr::V4(_) => &mut self.socket4,
SocketAddr::V6(_) => &mut self.socket6 SocketAddr::V6(_) => &mut self.socket6
}; };
try!(match socket.send(msg_data, *addr) { match socket.send(msg_data, *addr) {
Ok(written) if written == msg_data.len() => Ok(()), Ok(written) if written == msg_data.len() => Ok(()),
Ok(_) => Err(Error::Socket("Sent out truncated packet", io::Error::new(io::ErrorKind::Other, "truncated"))), Ok(_) => Err(Error::Socket("Sent out truncated packet", io::Error::new(io::ErrorKind::Other, "truncated"))),
Err(e) => Err(Error::Socket("IOError when sending", e)) Err(e) => Err(Error::Socket("IOError when sending", e))
}) }?
} }
Ok(()) Ok(())
} }
@ -336,7 +337,7 @@ impl<D: Device, P: Protocol, T: Table, S: Socket, TS: TimeSource> GenericCloud<D
/// Returns an IOError if the underlying system call fails /// Returns an IOError if the underlying system call fails
#[allow(dead_code)] #[allow(dead_code)]
pub fn address(&self) -> io::Result<(SocketAddr, SocketAddr)> { pub fn address(&self) -> io::Result<(SocketAddr, SocketAddr)> {
Ok((try!(self.socket4.address()), try!(self.socket6.address()))) Ok((self.socket4.address()?, self.socket6.address()?))
} }
/// Returns the number of peers /// Returns the number of peers
@ -367,7 +368,7 @@ impl<D: Device, P: Protocol, T: Table, S: Socket, TS: TimeSource> GenericCloud<D
/// Returns an `Error::SocketError` if the given address is a name that failed to resolve to /// Returns an `Error::SocketError` if the given address is a name that failed to resolve to
/// actual addresses. /// actual addresses.
fn is_own_address<Addr: ToSocketAddrs+fmt::Debug>(&self, addr: Addr) -> Result<bool, Error> { fn is_own_address<Addr: ToSocketAddrs+fmt::Debug>(&self, addr: Addr) -> Result<bool, Error> {
for addr in try!(resolve(&addr)) { for addr in resolve(&addr)? {
if self.own_addresses.contains(&addr) { if self.own_addresses.contains(&addr) {
return Ok(true); return Ok(true);
} }
@ -384,14 +385,14 @@ impl<D: Device, P: Protocol, T: Table, S: Socket, TS: TimeSource> GenericCloud<D
/// # Errors /// # Errors
/// This method returns `Error::NameError` if the address is a name that fails to resolve. /// This method returns `Error::NameError` if the address is a name that fails to resolve.
pub fn connect<Addr: ToSocketAddrs+fmt::Debug+Clone>(&mut self, addr: Addr) -> Result<(), Error> { pub fn connect<Addr: ToSocketAddrs+fmt::Debug+Clone>(&mut self, addr: Addr) -> Result<(), Error> {
if try!(self.peers.is_connected(addr.clone())) || try!(self.is_own_address(addr.clone())) { if self.peers.is_connected(addr.clone())? || self.is_own_address(addr.clone())? {
return Ok(()) return Ok(())
} }
debug!("Connecting to {:?}", addr); debug!("Connecting to {:?}", addr);
let subnets = self.addresses.clone(); let subnets = self.addresses.clone();
let node_id = self.node_id; let node_id = self.node_id;
// Send a message to each resolved address // Send a message to each resolved address
for a in try!(resolve(&addr)) { for a in resolve(&addr)? {
// Ignore error this time // Ignore error this time
let mut msg = Message::Init(0, node_id, subnets.clone()); let mut msg = Message::Init(0, node_id, subnets.clone());
self.send_msg(a, &mut msg).ok(); self.send_msg(a, &mut msg).ok();
@ -449,7 +450,7 @@ impl<D: Device, P: Protocol, T: Table, S: Socket, TS: TimeSource> GenericCloud<D
let peers = self.peers.subset(peer_num); let peers = self.peers.subset(peer_num);
// ...and send them to all peers // ...and send them to all peers
let mut msg = Message::Peers(peers); let mut msg = Message::Peers(peers);
try!(self.broadcast_msg(&mut msg)); self.broadcast_msg(&mut msg)?;
// Reschedule for next update // Reschedule for next update
self.next_peerlist = now + Time::from(self.update_freq); self.next_peerlist = now + Time::from(self.update_freq);
} }
@ -458,11 +459,11 @@ impl<D: Device, P: Protocol, T: Table, S: Socket, TS: TimeSource> GenericCloud<D
if entry.next > now { if entry.next > now {
continue continue
} }
try!(self.connect(&entry.resolved as &[SocketAddr])); self.connect(&entry.resolved as &[SocketAddr])?;
} }
for entry in &mut self.reconnect_peers { for entry in &mut self.reconnect_peers {
// Schedule for next second if node is connected // Schedule for next second if node is connected
if try!(self.peers.is_connected(&entry.resolved as &[SocketAddr])) { if self.peers.is_connected(&entry.resolved as &[SocketAddr])? {
entry.tries = 0; entry.tries = 0;
entry.timeout = 1; entry.timeout = 1;
entry.next = now + 1; entry.next = now + 1;
@ -494,19 +495,19 @@ impl<D: Device, P: Protocol, T: Table, S: Socket, TS: TimeSource> GenericCloud<D
} }
if self.next_stats_out < now { if self.next_stats_out < now {
// Write out the statistics // Write out the statistics
try!(self.write_out_stats().map_err(|err| Error::File("Failed to write stats file", err))); self.write_out_stats().map_err(|err| Error::File("Failed to write stats file", err))?;
self.next_stats_out = now + STATS_INTERVAL; self.next_stats_out = now + STATS_INTERVAL;
self.traffic.period(Some(60)); self.traffic.period(Some(60));
} }
if let Some(peers) = self.beacon_serializer.get_cmd_results() { if let Some(peers) = self.beacon_serializer.get_cmd_results() {
debug!("Loaded beacon with peers: {:?}", peers); debug!("Loaded beacon with peers: {:?}", peers);
for peer in peers { for peer in peers {
try!(self.connect_sock(peer)); self.connect_sock(peer)?;
} }
} }
if self.next_beacon < now { if self.next_beacon < now {
try!(self.store_beacon()); self.store_beacon()?;
try!(self.load_beacon()); self.load_beacon()?;
self.next_beacon = now + Time::from(self.config.beacon_interval); self.next_beacon = now + Time::from(self.config.beacon_interval);
} }
Ok(()) Ok(())
@ -517,9 +518,9 @@ impl<D: Device, P: Protocol, T: Table, S: Socket, TS: TimeSource> GenericCloud<D
if let Some(ref path) = self.config.beacon_store { if let Some(ref path) = self.config.beacon_store {
let peers: Vec<_> = self.own_addresses.choose_multiple(&mut thread_rng(),3).cloned().collect(); let peers: Vec<_> = self.own_addresses.choose_multiple(&mut thread_rng(),3).cloned().collect();
if path.starts_with('|') { if path.starts_with('|') {
try!(self.beacon_serializer.write_to_cmd(&peers, &path[1..]).map_err(|e| Error::Beacon("Failed to call beacon command", e))); self.beacon_serializer.write_to_cmd(&peers, &path[1..]).map_err(|e| Error::Beacon("Failed to call beacon command", e))?;
} else { } else {
try!(self.beacon_serializer.write_to_file(&peers, &path).map_err(|e| Error::Beacon("Failed to write beacon to file", e))); self.beacon_serializer.write_to_file(&peers, &path).map_err(|e| Error::Beacon("Failed to write beacon to file", e))?;
} }
} }
Ok(()) Ok(())
@ -530,17 +531,17 @@ impl<D: Device, P: Protocol, T: Table, S: Socket, TS: TimeSource> GenericCloud<D
let peers; let peers;
if let Some(ref path) = self.config.beacon_load { if let Some(ref path) = self.config.beacon_load {
if path.starts_with('|') { if path.starts_with('|') {
try!(self.beacon_serializer.read_from_cmd(&path[1..], Some(50)).map_err(|e| Error::Beacon("Failed to call beacon command", e))); self.beacon_serializer.read_from_cmd(&path[1..], Some(50)).map_err(|e| Error::Beacon("Failed to call beacon command", e))?;
return Ok(()) return Ok(())
} else { } else {
peers = try!(self.beacon_serializer.read_from_file(&path, Some(50)).map_err(|e| Error::Beacon("Failed to read beacon from file", e))); peers = self.beacon_serializer.read_from_file(&path, Some(50)).map_err(|e| Error::Beacon("Failed to read beacon from file", e))?;
} }
} else { } else {
return Ok(()) return Ok(())
} }
debug!("Loaded beacon with peers: {:?}", peers); debug!("Loaded beacon with peers: {:?}", peers);
for peer in peers { for peer in peers {
try!(self.connect_sock(peer)); self.connect_sock(peer)?;
} }
Ok(()) Ok(())
} }
@ -549,14 +550,14 @@ impl<D: Device, P: Protocol, T: Table, S: Socket, TS: TimeSource> GenericCloud<D
fn write_out_stats(&mut self) -> Result<(), io::Error> { fn write_out_stats(&mut self) -> Result<(), io::Error> {
if self.config.stats_file.is_none() { return Ok(()) } if self.config.stats_file.is_none() { return Ok(()) }
debug!("Writing out stats"); debug!("Writing out stats");
let mut f = try!(File::create(self.config.stats_file.as_ref().unwrap())); let mut f = File::create(self.config.stats_file.as_ref().unwrap())?;
try!(self.peers.write_out(&mut f)); self.peers.write_out(&mut f)?;
try!(writeln!(&mut f)); writeln!(&mut f)?;
try!(self.table.write_out(&mut f)); self.table.write_out(&mut f)?;
try!(writeln!(&mut f)); writeln!(&mut f)?;
try!(self.traffic.write_out(&mut f)); self.traffic.write_out(&mut f)?;
try!(writeln!(&mut f)); writeln!(&mut f)?;
try!(fs::set_permissions(self.config.stats_file.as_ref().unwrap(), Permissions::from_mode(0o644))); fs::set_permissions(self.config.stats_file.as_ref().unwrap(), Permissions::from_mode(0o644))?;
Ok(()) Ok(())
} }
@ -577,26 +578,26 @@ impl<D: Device, P: Protocol, T: Table, S: Socket, TS: TimeSource> GenericCloud<D
/// - with `Error::ParseError` if the payload data failed to parse /// - with `Error::ParseError` if the payload data failed to parse
/// - with `Error::SocketError` if sending a message fails /// - with `Error::SocketError` if sending a message fails
pub fn handle_interface_data(&mut self, payload: &mut [u8], start: usize, end: usize) -> Result<(), Error> { pub fn handle_interface_data(&mut self, payload: &mut [u8], start: usize, end: usize) -> Result<(), Error> {
let (src, dst) = try!(P::parse(&payload[start..end])); let (src, dst) = P::parse(&payload[start..end])?;
debug!("Read data from interface: src: {}, dst: {}, {} bytes", src, dst, end-start); debug!("Read data from interface: src: {}, dst: {}, {} bytes", src, dst, end-start);
self.traffic.count_out_payload(dst, src, end-start); self.traffic.count_out_payload(dst, src, end-start);
match self.table.lookup(&dst) { match self.table.lookup(&dst) {
Some(addr) => { // Peer found for destination Some(addr) => { // Peer found for destination
debug!("Found destination for {} => {}", dst, addr); debug!("Found destination for {} => {}", dst, addr);
try!(self.send_msg(addr, &mut Message::Data(payload, start, end))); self.send_msg(addr, &mut Message::Data(payload, start, end))?;
if !self.peers.contains_addr(&addr) { if !self.peers.contains_addr(&addr) {
// If the peer is not actually connected, remove the entry in the table and try // If the peer is not actually connected, remove the entry in the table and try
// to reconnect. // to reconnect.
warn!("Destination for {} not found in peers: {}", dst, addr); warn!("Destination for {} not found in peers: {}", dst, addr);
self.table.remove(&dst); self.table.remove(&dst);
try!(self.connect_sock(addr)); self.connect_sock(addr)?;
} }
}, },
None => { None => {
if self.broadcast { if self.broadcast {
debug!("No destination for {} found, broadcasting", dst); debug!("No destination for {} found, broadcasting", dst);
let mut msg = Message::Data(payload, start, end); let mut msg = Message::Data(payload, start, end);
try!(self.broadcast_msg(&mut msg)); self.broadcast_msg(&mut msg)?;
} else { } else {
debug!("No destination for {} found, dropping", dst); debug!("No destination for {} found, dropping", dst);
} }
@ -642,7 +643,7 @@ impl<D: Device, P: Protocol, T: Table, S: Socket, TS: TimeSource> GenericCloud<D
debug!("Received {:?} from {}", msg, peer); debug!("Received {:?} from {}", msg, peer);
match msg { match msg {
Message::Data(payload, start, end) => { Message::Data(payload, start, end) => {
let (src, dst) = try!(P::parse(&payload[start..end])); let (src, dst) = P::parse(&payload[start..end])?;
debug!("Writing data to device: {} bytes", end-start); debug!("Writing data to device: {} bytes", end-start);
self.traffic.count_in_payload(src, dst, end-start); self.traffic.count_in_payload(src, dst, end-start);
if let Err(e) = self.device.write(&mut payload[..end], start) { if let Err(e) = self.device.write(&mut payload[..end], start) {
@ -658,14 +659,14 @@ impl<D: Device, P: Protocol, T: Table, S: Socket, TS: TimeSource> GenericCloud<D
Message::Peers(peers) => { Message::Peers(peers) => {
// Connect to sender if not connected // Connect to sender if not connected
if !self.peers.contains_addr(&peer) { if !self.peers.contains_addr(&peer) {
try!(self.connect_sock(peer)); self.connect_sock(peer)?;
} }
if let Some(node_id) = self.peers.get_node_id(&peer) { if let Some(node_id) = self.peers.get_node_id(&peer) {
self.peers.make_primary(node_id, peer); self.peers.make_primary(node_id, peer);
} }
// Connect to all peers in the message // Connect to all peers in the message
for p in &peers { for p in &peers {
try!(self.connect_sock(*p)); self.connect_sock(*p)?;
} }
// Refresh peer // Refresh peer
self.peers.refresh(&peer); self.peers.refresh(&peer);
@ -689,11 +690,11 @@ impl<D: Device, P: Protocol, T: Table, S: Socket, TS: TimeSource> GenericCloud<D
if stage == 0 { if stage == 0 {
let own_addrs = self.addresses.clone(); let own_addrs = self.addresses.clone();
let own_node_id = self.node_id; let own_node_id = self.node_id;
try!(self.send_msg(peer, &mut Message::Init(stage+1, own_node_id, own_addrs))); self.send_msg(peer, &mut Message::Init(stage+1, own_node_id, own_addrs))?;
} }
// Send peers in any case // Send peers in any case
let peers = self.peers.as_vec(); let peers = self.peers.as_vec();
try!(self.send_msg(peer, &mut Message::Peers(peers))); self.send_msg(peer, &mut Message::Peers(peers))?;
}, },
Message::Close => { Message::Close => {
self.peers.remove(&peer); self.peers.remove(&peer);
@ -715,7 +716,7 @@ impl<D: Device, P: Protocol, T: Table, S: Socket, TS: TimeSource> GenericCloud<D
fn handle_socket_data(&mut self, src: SocketAddr, data: &mut [u8]) { fn handle_socket_data(&mut self, src: SocketAddr, data: &mut [u8]) {
let size = data.len(); let size = data.len();
if let Err(e) = decode(data, self.magic, &mut self.crypto).and_then(|msg| { if let Err(e) = decode(data, self.magic, &self.crypto).and_then(|msg| {
self.traffic.count_in_traffic(src, size); self.traffic.count_in_traffic(src, size);
self.handle_net_message(src, msg) self.handle_net_message(src, msg)
}) { }) {

View File

@ -107,7 +107,7 @@ impl TunTapDevice {
if type_ == Type::Dummy { if type_ == Type::Dummy {
return Self::dummy(ifname, path, type_); return Self::dummy(ifname, path, type_);
} }
let fd = try!(fs::OpenOptions::new().read(true).write(true).open(path)); let fd = fs::OpenOptions::new().read(true).write(true).open(path)?;
// Add trailing \0 to interface name // Add trailing \0 to interface name
let mut ifname_string = String::with_capacity(32); let mut ifname_string = String::with_capacity(32);
ifname_string.push_str(ifname); ifname_string.push_str(ifname);
@ -156,7 +156,7 @@ impl TunTapDevice {
#[allow(dead_code)] #[allow(dead_code)]
pub fn dummy(ifname: &str, path: &str, type_: Type) -> io::Result<Self> { pub fn dummy(ifname: &str, path: &str, type_: Type) -> io::Result<Self> {
Ok(TunTapDevice{ Ok(TunTapDevice{
fd: try!(fs::OpenOptions::new().create(true).read(true).write(true).open(path)), fd: fs::OpenOptions::new().create(true).read(true).write(true).open(path)?,
ifname: ifname.to_string(), ifname: ifname.to_string(),
type_ type_
}) })
@ -218,7 +218,7 @@ impl Device for TunTapDevice {
} }
fn read(&mut self, mut buffer: &mut [u8]) -> Result<(usize, usize), Error> { fn read(&mut self, mut buffer: &mut [u8]) -> Result<(usize, usize), Error> {
let read = try!(self.fd.read(&mut buffer).map_err(|e| Error::TunTapDev("Read error", e))); let read = self.fd.read(&mut buffer).map_err(|e| Error::TunTapDev("Read error", e))?;
let (start, read) = self.correct_data_after_read(&mut buffer, 0, read); let (start, read) = self.correct_data_after_read(&mut buffer, 0, read);
Ok((start, read)) Ok((start, read))
} }
@ -248,7 +248,7 @@ pub struct MockDevice {
impl MockDevice { impl MockDevice {
pub fn new() -> Self { pub fn new() -> Self {
Self { outbound: VecDeque::new(), inbound: VecDeque::new() } Default::default()
} }
pub fn put_inbound(&mut self, data: Vec<u8>) { pub fn put_inbound(&mut self, data: Vec<u8>) {
@ -288,6 +288,12 @@ impl Device for MockDevice {
} }
} }
impl Default for MockDevice {
fn default() -> Self {
Self { outbound: VecDeque::new(), inbound: VecDeque::new() }
}
}
impl AsRawFd for MockDevice { impl AsRawFd for MockDevice {
#[inline] #[inline]
fn as_raw_fd(&self) -> RawFd { fn as_raw_fd(&self) -> RawFd {

View File

@ -49,8 +49,8 @@ impl Protocol for Frame {
dst[2..8].copy_from_slice(dst_data); dst[2..8].copy_from_slice(dst_data);
Ok((Address{data: src, len: 8}, Address{data: dst, len: 8})) Ok((Address{data: src, len: 8}, Address{data: dst, len: 8}))
} else { } else {
let src = try!(Address::read_from_fixed(src_data, 6)); let src = Address::read_from_fixed(src_data, 6)?;
let dst = try!(Address::read_from_fixed(dst_data, 6)); let dst = Address::read_from_fixed(dst_data, 6)?;
Ok((src, dst)) Ok((src, dst))
} }
} }
@ -105,9 +105,9 @@ impl<TS: TimeSource> Table for SwitchTable<TS> {
/// Write out the table /// Write out the table
fn write_out<W: Write>(&self, out: &mut W) -> Result<(), io::Error> { fn write_out<W: Write>(&self, out: &mut W) -> Result<(), io::Error> {
let now = TS::now(); let now = TS::now();
try!(writeln!(out, "Switch table:")); writeln!(out, "Switch table:")?;
for (addr, val) in &self.table { for (addr, val) in &self.table {
try!(writeln!(out, " - {} => {} (ttl: {} s)", addr, val.address, val.timeout - now)); writeln!(out, " - {} => {} (ttl: {} s)", addr, val.address, val.timeout - now)?;
} }
Ok(()) Ok(())
} }

View File

@ -34,16 +34,16 @@ impl Protocol for Packet {
if data.len() < 20 { if data.len() < 20 {
return Err(Error::Parse("Truncated IPv4 header")); return Err(Error::Parse("Truncated IPv4 header"));
} }
let src = try!(Address::read_from_fixed(&data[12..], 4)); let src = Address::read_from_fixed(&data[12..], 4)?;
let dst = try!(Address::read_from_fixed(&data[16..], 4)); let dst = Address::read_from_fixed(&data[16..], 4)?;
Ok((src, dst)) Ok((src, dst))
}, },
6 => { 6 => {
if data.len() < 40 { if data.len() < 40 {
return Err(Error::Parse("Truncated IPv6 header")); return Err(Error::Parse("Truncated IPv6 header"));
} }
let src = try!(Address::read_from_fixed(&data[8..], 16)); let src = Address::read_from_fixed(&data[8..], 16)?;
let dst = try!(Address::read_from_fixed(&data[24..], 16)); let dst = Address::read_from_fixed(&data[24..], 16)?;
Ok((src, dst)) Ok((src, dst))
}, },
_ => Err(Error::Parse("Invalid version")) _ => Err(Error::Parse("Invalid version"))
@ -149,10 +149,10 @@ impl Table for RoutingTable {
/// Write out the table /// Write out the table
fn write_out<W: Write>(&self, out: &mut W) -> Result<(), io::Error> { fn write_out<W: Write>(&self, out: &mut W) -> Result<(), io::Error> {
try!(writeln!(out, "Routing table:")); writeln!(out, "Routing table:")?;
for entries in self.0.values() { for entries in self.0.values() {
for entry in entries { for entry in entries {
try!(writeln!(out, " - {}/{} => {}", entry.bytes, entry.prefix_len, entry.address)); writeln!(out, " - {}/{} => {}", entry.bytes, entry.prefix_len, entry.address)?;
} }
} }
Ok(()) Ok(())

View File

@ -5,22 +5,8 @@
#![cfg_attr(feature = "bench", feature(test))] #![cfg_attr(feature = "bench", feature(test))]
#[macro_use] extern crate log; #[macro_use] extern crate log;
extern crate time;
extern crate docopt;
#[macro_use] extern crate serde_derive; #[macro_use] extern crate serde_derive;
extern crate serde;
extern crate serde_yaml;
extern crate signal;
extern crate libc;
extern crate rand;
extern crate fnv;
extern crate net2;
extern crate yaml_rust;
extern crate igd;
extern crate siphasher;
extern crate daemonize;
extern crate ring;
extern crate base_62;
#[cfg(test)] extern crate tempfile; #[cfg(test)] extern crate tempfile;
#[cfg(feature = "bench")] extern crate test; #[cfg(feature = "bench")] extern crate test;
@ -51,15 +37,15 @@ use std::path::Path;
use std::io::{self, Write}; use std::io::{self, Write};
use std::net::UdpSocket; use std::net::UdpSocket;
use device::{TunTapDevice, Device, Type}; use crate::device::{TunTapDevice, Device, Type};
use ethernet::SwitchTable; use crate::ethernet::SwitchTable;
use ip::RoutingTable; use crate::ip::RoutingTable;
use types::{Mode, Range, Protocol, HeaderMagic, Error}; use crate::types::{Mode, Range, Protocol, HeaderMagic, Error};
use cloud::GenericCloud; use crate::cloud::GenericCloud;
use crypto::{Crypto, CryptoMethod}; use crate::crypto::{Crypto, CryptoMethod};
use port_forwarding::PortForwarding; use crate::port_forwarding::PortForwarding;
use util::{Duration, SystemTimeSource}; use crate::util::{Duration, SystemTimeSource};
use config::Config; use crate::config::Config;
const VERSION: u8 = 1; const VERSION: u8 = 1;
@ -109,7 +95,7 @@ struct DualLogger {
impl DualLogger { impl DualLogger {
pub fn new<P: AsRef<Path>>(path: Option<P>) -> Result<Self, io::Error> { pub fn new<P: AsRef<Path>>(path: Option<P>) -> Result<Self, io::Error> {
if let Some(path) = path { if let Some(path) = path {
let file = try!(File::create(path)); let file = File::create(path)?;
Ok(DualLogger{file: Mutex::new(Some(file))}) Ok(DualLogger{file: Mutex::new(Some(file))})
} else { } else {
Ok(DualLogger{file: Mutex::new(None)}) Ok(DualLogger{file: Mutex::new(None)})

View File

@ -6,11 +6,11 @@ use libc;
use std::os::unix::io::RawFd; use std::os::unix::io::RawFd;
use std::io; use std::io;
use device::Device; use crate::device::Device;
use super::WaitResult; use super::WaitResult;
use ::device::Type; use crate::device::Type;
use net::Socket; use crate::net::Socket;
pub struct EpollWait { pub struct EpollWait {
poll_fd: RawFd, poll_fd: RawFd,

View File

@ -73,7 +73,7 @@ fn msg6_put<P: Protocol, T: Table>(node: &mut TestNode<P, T>, from: SocketAddr,
} }
fn simulate<P: Protocol, T: Table>(nodes: &mut [(&mut TestNode<P, T>, SocketAddr)]) { fn simulate<P: Protocol, T: Table>(nodes: &mut [(&mut TestNode<P, T>, SocketAddr)]) {
for (ref mut node, ref from_addr) in nodes.iter_mut() { for (ref mut node, ref _from_addr) in nodes.iter_mut() {
while node.device().has_inbound() { while node.device().has_inbound() {
node.trigger_device_event(); node.trigger_device_event();
} }

View File

@ -105,18 +105,18 @@ impl TrafficStats {
#[inline] #[inline]
pub fn write_out<W: Write>(&self, out: &mut W) -> Result<(), io::Error> { pub fn write_out<W: Write>(&self, out: &mut W) -> Result<(), io::Error> {
try!(writeln!(out, "Peer traffic:")); writeln!(out, "Peer traffic:")?;
let mut peers: Vec<_> = self.get_peer_traffic().collect(); let mut peers: Vec<_> = self.get_peer_traffic().collect();
peers.sort_unstable_by_key(|(_, data)| (data.out_bytes + data.in_bytes)); peers.sort_unstable_by_key(|(_, data)| (data.out_bytes + data.in_bytes));
for (addr, data) in peers.iter().rev() { for (addr, data) in peers.iter().rev() {
try!(writeln!(out, " - {}: in={}/s, out={}/s", addr, Bytes(data.in_bytes/60), Bytes(data.out_bytes/60))); writeln!(out, " - {}: in={}/s, out={}/s", addr, Bytes(data.in_bytes/60), Bytes(data.out_bytes/60))?;
} }
try!(writeln!(out)); writeln!(out)?;
try!(writeln!(out, "Payload traffic:")); writeln!(out, "Payload traffic:")?;
let mut payload: Vec<_> = self.get_payload_traffic().collect(); let mut payload: Vec<_> = self.get_payload_traffic().collect();
payload.sort_unstable_by_key(|(_, data)| (data.out_bytes + data.in_bytes)); payload.sort_unstable_by_key(|(_, data)| (data.out_bytes + data.in_bytes));
for ((remote, local), data) in payload.iter().rev() { for ((remote, local), data) in payload.iter().rev() {
try!(writeln!(out, " - {} <-> {}: in={}/s, out={}/s", remote, local, Bytes(data.in_bytes/60), Bytes(data.out_bytes/60))); writeln!(out, " - {} <-> {}: in={}/s, out={}/s", remote, local, Bytes(data.in_bytes/60), Bytes(data.out_bytes/60))?;
} }
Ok(()) Ok(())
} }

View File

@ -29,7 +29,7 @@ impl Address {
return Err(Error::Parse("Address too short")); return Err(Error::Parse("Address too short"));
} }
let len = data[0] as usize; let len = data[0] as usize;
let addr = try!(Address::read_from_fixed(&data[1..], len)); let addr = Address::read_from_fixed(&data[1..], len)?;
Ok((addr, len + 1)) Ok((addr, len + 1))
} }
@ -121,7 +121,7 @@ impl FromStr for Address {
if parts.len() == 6 { if parts.len() == 6 {
let mut bytes = [0; 16]; let mut bytes = [0; 16];
for i in 0..6 { for i in 0..6 {
bytes[i] = try!(u8::from_str_radix(parts[i], 16).map_err(|_| Error::Parse("Failed to parse mac"))); bytes[i] = u8::from_str_radix(parts[i], 16).map_err(|_| Error::Parse("Failed to parse mac"))?;
} }
return Ok(Address{data: bytes, len: 6}); return Ok(Address{data: bytes, len: 6});
} }
@ -139,7 +139,7 @@ pub struct Range {
impl Range { impl Range {
#[inline] #[inline]
pub fn read_from(data: &[u8]) -> Result<(Range, usize), Error> { pub fn read_from(data: &[u8]) -> Result<(Range, usize), Error> {
let (address, read) = try!(Address::read_from(data)); let (address, read) = Address::read_from(data)?;
if data.len() < read + 1 { if data.len() < read + 1 {
return Err(Error::Parse("Range too short")); return Err(Error::Parse("Range too short"));
} }
@ -164,9 +164,9 @@ impl FromStr for Range {
Some(pos) => pos, Some(pos) => pos,
None => return Err(Error::Parse("Invalid range format")) None => return Err(Error::Parse("Invalid range format"))
}; };
let prefix_len = try!(u8::from_str(&text[pos+1..]) let prefix_len = u8::from_str(&text[pos+1..])
.map_err(|_| Error::Parse("Failed to parse prefix length"))); .map_err(|_| Error::Parse("Failed to parse prefix length"))?;
let base = try!(Address::from_str(&text[..pos])); let base = Address::from_str(&text[..pos])?;
Ok(Range{base, prefix_len}) Ok(Range{base, prefix_len})
} }
} }
@ -207,16 +207,16 @@ impl fmt::Display for Mode {
} }
pub trait Table { pub trait Table {
fn learn(&mut self, Address, Option<u8>, SocketAddr); fn learn(&mut self, _: Address, _: Option<u8>, _: SocketAddr);
fn lookup(&mut self, &Address) -> Option<SocketAddr>; fn lookup(&mut self, _: &Address) -> Option<SocketAddr>;
fn housekeep(&mut self); fn housekeep(&mut self);
fn write_out<W: Write>(&self, out: &mut W) -> Result<(), io::Error>; fn write_out<W: Write>(&self, out: &mut W) -> Result<(), io::Error>;
fn remove(&mut self, &Address) -> bool; fn remove(&mut self, _: &Address) -> bool;
fn remove_all(&mut self, &SocketAddr); fn remove_all(&mut self, _: &SocketAddr);
} }
pub trait Protocol: Sized { pub trait Protocol: Sized {
fn parse(&[u8]) -> Result<(Address, Address), Error>; fn parse(_: &[u8]) -> Result<(Address, Address), Error>;
} }
#[derive(Debug)] #[derive(Debug)]
@ -278,10 +278,10 @@ fn address_decode_encode() {
#[test] #[test]
fn address_eq() { fn address_eq() {
assert!(Address::read_from_fixed(&[1,2,3,4], 4).unwrap() == Address::read_from_fixed(&[1,2,3,4], 4).unwrap()); assert_eq!(Address::read_from_fixed(&[1,2,3,4], 4).unwrap(), Address::read_from_fixed(&[1,2,3,4], 4).unwrap());
assert!(Address::read_from_fixed(&[1,2,3,4], 4).unwrap() != Address::read_from_fixed(&[1,2,3,5], 4).unwrap()); assert_ne!(Address::read_from_fixed(&[1,2,3,4], 4).unwrap(), Address::read_from_fixed(&[1,2,3,5], 4).unwrap());
assert!(Address::read_from_fixed(&[1,2,3,4], 3).unwrap() == Address::read_from_fixed(&[1,2,3,5], 3).unwrap()); assert_eq!(Address::read_from_fixed(&[1,2,3,4], 3).unwrap(), Address::read_from_fixed(&[1,2,3,5], 3).unwrap());
assert!(Address::read_from_fixed(&[1,2,3,4], 3).unwrap() != Address::read_from_fixed(&[1,2,3,4], 4).unwrap()); assert_ne!(Address::read_from_fixed(&[1,2,3,4], 3).unwrap(), Address::read_from_fixed(&[1,2,3,4], 4).unwrap());
} }
#[test] #[test]

View File

@ -71,14 +71,14 @@ impl<'a> fmt::Debug for Message<'a> {
match *self { match *self {
Message::Data(_, start, end) => write!(formatter, "Data({} bytes)", end-start), Message::Data(_, start, end) => write!(formatter, "Data({} bytes)", end-start),
Message::Peers(ref peers) => { Message::Peers(ref peers) => {
try!(write!(formatter, "Peers [")); write!(formatter, "Peers [")?;
let mut first = true; let mut first = true;
for p in peers { for p in peers {
if !first { if !first {
try!(write!(formatter, ", ")); write!(formatter, ", ")?;
} }
first = false; first = false;
try!(write!(formatter, "{}", p)); write!(formatter, "{}", p)?;
} }
write!(formatter, "]") write!(formatter, "]")
}, },
@ -91,7 +91,7 @@ impl<'a> fmt::Debug for Message<'a> {
#[allow(unknown_lints,clippy::needless_range_loop)] #[allow(unknown_lints,clippy::needless_range_loop)]
pub fn decode<'a>(data: &'a mut [u8], magic: HeaderMagic, crypto: &Crypto) -> Result<Message<'a>, Error> { pub fn decode<'a>(data: &'a mut [u8], magic: HeaderMagic, crypto: &Crypto) -> Result<Message<'a>, Error> {
let mut end = data.len(); let mut end = data.len();
let (header, mut pos) = try!(TopHeader::read_from(&data[..end])); let (header, mut pos) = TopHeader::read_from(&data[..end])?;
if header.magic != magic { if header.magic != magic {
return Err(Error::WrongHeaderMagic(header.magic)); return Err(Error::WrongHeaderMagic(header.magic));
} }
@ -107,7 +107,7 @@ pub fn decode<'a>(data: &'a mut [u8], magic: HeaderMagic, crypto: &Crypto) -> Re
let (before, after) = data.split_at_mut(pos); let (before, after) = data.split_at_mut(pos);
let (nonce, crypto_data) = after.split_at_mut(len); let (nonce, crypto_data) = after.split_at_mut(len);
pos += len; pos += len;
end = try!(crypto.decrypt(crypto_data, nonce, &before[..TopHeader::size()])) + pos; end = crypto.decrypt(crypto_data, nonce, &before[..TopHeader::size()])? + pos;
} }
assert_eq!(end, data.len()-crypto.additional_bytes()); assert_eq!(end, data.len()-crypto.additional_bytes());
} }
@ -169,7 +169,7 @@ pub fn decode<'a>(data: &'a mut [u8], magic: HeaderMagic, crypto: &Crypto) -> Re
pos += 1; pos += 1;
let mut addrs = Vec::with_capacity(count); let mut addrs = Vec::with_capacity(count);
for _ in 0..count { for _ in 0..count {
let (range, read) = try!(Range::read_from(&data[pos..end])); let (range, read) = Range::read_from(&data[pos..end])?;
pos += read; pos += read;
addrs.push(range); addrs.push(range);
} }
@ -183,6 +183,12 @@ pub fn decode<'a>(data: &'a mut [u8], magic: HeaderMagic, crypto: &Crypto) -> Re
#[allow(unknown_lints,clippy::needless_range_loop)] #[allow(unknown_lints,clippy::needless_range_loop)]
pub fn encode<'a>(msg: &'a mut Message, mut buf: &'a mut [u8], magic: HeaderMagic, crypto: &mut Crypto) -> &'a mut [u8] { pub fn encode<'a>(msg: &'a mut Message, mut buf: &'a mut [u8], magic: HeaderMagic, crypto: &mut Crypto) -> &'a mut [u8] {
let header_type = match msg {
Message::Data(_, _, _) => 0,
Message::Peers(_) => 1,
Message::Init(_, _, _) => 2,
Message::Close => 3
};
let mut start = 64; let mut start = 64;
let mut end = 64; let mut end = 64;
match *msg { match *msg {
@ -250,12 +256,7 @@ pub fn encode<'a>(msg: &'a mut Message, mut buf: &'a mut [u8], magic: HeaderMagi
start -= crypto.nonce_bytes(); start -= crypto.nonce_bytes();
let mut header = TopHeader::default(); let mut header = TopHeader::default();
header.magic = magic; header.magic = magic;
header.msgtype = match *msg { header.msgtype = header_type;
Message::Data(_, _, _) => 0,
Message::Peers(_) => 1,
Message::Init(_, _, _) => 2,
Message::Close => 3
};
header.crypto_method = crypto.method(); header.crypto_method = crypto.method();
start -= TopHeader::size(); start -= TopHeader::size();
header.write_to(&mut buf[start..]); header.write_to(&mut buf[start..]);
@ -273,17 +274,17 @@ pub fn encode<'a>(msg: &'a mut Message, mut buf: &'a mut [u8], magic: HeaderMagi
impl<'a> PartialEq for Message<'a> { impl<'a> PartialEq for Message<'a> {
fn eq(&self, other: &Message) -> bool { fn eq(&self, other: &Message) -> bool {
match self { match *self {
&Message::Data(ref data1, start1, end1) => if let &Message::Data(ref data2, start2, end2) = other { Message::Data(ref data1, start1, end1) => if let Message::Data(ref data2, start2, end2) = *other {
data1[start1..end1] == data2[start2..end2] data1[start1..end1] == data2[start2..end2]
} else { false }, } else { false },
&Message::Peers(ref peers1) => if let &Message::Peers(ref peers2) = other { Message::Peers(ref peers1) => if let Message::Peers(ref peers2) = *other {
peers1 == peers2 peers1 == peers2
} else { false }, } else { false },
&Message::Init(step1, node_id1, ref ranges1) => if let &Message::Init(step2, node_id2, ref ranges2) = other { Message::Init(step1, node_id1, ref ranges1) => if let Message::Init(step2, node_id2, ref ranges2) = *other {
step1 == step2 && node_id1 == node_id2 && ranges1 == ranges2 step1 == step2 && node_id1 == node_id2 && ranges1 == ranges2
} else { false }, } else { false },
&Message::Close => if let &Message::Close = other { Message::Close => if let Message::Close = *other {
true true
} else { false } } else { false }
} }

View File

@ -117,7 +117,7 @@ macro_rules! try_fail {
#[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<Vec<SocketAddr>, Error> { pub fn resolve<Addr: ToSocketAddrs+fmt::Debug>(addr: Addr) -> Result<Vec<SocketAddr>, Error> {
let addrs = try!(addr.to_socket_addrs().map_err(|_| Error::Name(format!("{:?}", addr)))); let addrs = addr.to_socket_addrs().map_err(|_| Error::Name(format!("{:?}", addr)))?;
// Remove duplicates in addrs (why are there duplicates???) // Remove duplicates in addrs (why are there duplicates???)
let mut addrs = addrs.collect::<Vec<_>>(); let mut addrs = addrs.collect::<Vec<_>>();
// Try IPv4 first as it usually is faster // Try IPv4 first as it usually is faster
@ -177,9 +177,7 @@ pub struct CtrlC {
impl CtrlC { impl CtrlC {
pub fn new() -> Self { pub fn new() -> Self {
let dummy_time = Instant::now(); Default::default()
let trap = Trap::trap(&[Signal::SIGINT, Signal::SIGTERM, Signal::SIGQUIT]);
Self { dummy_time, trap }
} }
pub fn was_pressed(&self) -> bool { pub fn was_pressed(&self) -> bool {
@ -187,6 +185,14 @@ impl CtrlC {
} }
} }
impl Default for CtrlC {
fn default() -> Self {
let dummy_time = Instant::now();
let trap = Trap::trap(&[Signal::SIGINT, Signal::SIGTERM, Signal::SIGQUIT]);
Self { dummy_time, trap }
}
}
pub trait TimeSource: Sync + Copy + Send + 'static { pub trait TimeSource: Sync + Copy + Send + 'static {
fn now() -> Time; fn now() -> Time;