mirror of https://github.com/dswd/vpncloud.git
Cross-compiling for ARMv7, updated dependencies, silenced clippy warnings
This commit is contained in:
parent
f933db2dd9
commit
bebfc07ecd
|
@ -5,3 +5,4 @@ vpncloud-oldnodes
|
||||||
deb/vpncloud/vpncloud
|
deb/vpncloud/vpncloud
|
||||||
deb/vpncloud/vpncloud.1*
|
deb/vpncloud/vpncloud.1*
|
||||||
Stats.ods
|
Stats.ods
|
||||||
|
.sodium-build
|
||||||
|
|
|
@ -2,6 +2,12 @@
|
||||||
|
|
||||||
This project follows [semantic versioning](http://semver.org).
|
This project follows [semantic versioning](http://semver.org).
|
||||||
|
|
||||||
|
### UNRELEASED
|
||||||
|
|
||||||
|
- [changed] Updated dependencies
|
||||||
|
- [changed] Turned some clippy warnings off
|
||||||
|
- [changed] Cross-compiling for ARMv7
|
||||||
|
|
||||||
### v0.6.0 (2016-06-02)
|
### v0.6.0 (2016-06-02)
|
||||||
|
|
||||||
- [added] Exponential backoff for reconnect timeouts
|
- [added] Exponential backoff for reconnect timeouts
|
||||||
|
|
|
@ -3,18 +3,18 @@ name = "vpncloud"
|
||||||
version = "0.6.0"
|
version = "0.6.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aligned_alloc 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"aligned_alloc 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"docopt 0.6.80 (registry+https://github.com/rust-lang/crates.io-index)",
|
"docopt 0.6.81 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"epoll 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"epoll 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"fnv 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"fnv 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"gcc 0.3.28 (registry+https://github.com/rust-lang/crates.io-index)",
|
"gcc 0.3.28 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"net2 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)",
|
"net2 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"nix 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"nix 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"signal 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"signal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -32,15 +32,10 @@ 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 = [
|
||||||
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"winapi 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winapi 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "bitflags"
|
|
||||||
version = "0.3.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitflags"
|
name = "bitflags"
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
|
@ -53,7 +48,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "docopt"
|
name = "docopt"
|
||||||
version = "0.6.80"
|
version = "0.6.81"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"regex 0.1.71 (registry+https://github.com/rust-lang/crates.io-index)",
|
"regex 0.1.71 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -66,17 +61,17 @@ name = "epoll"
|
||||||
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 = [
|
||||||
"errno 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"errno 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "errno"
|
name = "errno"
|
||||||
version = "0.1.6"
|
version = "0.1.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"winapi 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winapi 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -101,12 +96,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.1.12"
|
version = "0.2.12"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "libc"
|
|
||||||
version = "0.2.11"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -119,37 +109,32 @@ name = "memchr"
|
||||||
version = "0.1.11"
|
version = "0.1.11"
|
||||||
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.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "net2"
|
name = "net2"
|
||||||
version = "0.2.23"
|
version = "0.2.24"
|
||||||
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.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"winapi 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winapi 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nix"
|
name = "nix"
|
||||||
version = "0.4.2"
|
version = "0.6.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"libc 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "nix"
|
|
||||||
version = "0.5.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -162,7 +147,7 @@ name = "rand"
|
||||||
version = "0.3.14"
|
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 = [
|
||||||
"libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -188,13 +173,25 @@ version = "0.3.19"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "signal"
|
name = "rustc_version"
|
||||||
version = "0.1.4"
|
version = "0.1.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
"semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"nix 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
]
|
||||||
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
|
[[package]]
|
||||||
|
name = "semver"
|
||||||
|
version = "0.1.20"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "signal"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"nix 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -208,7 +205,7 @@ version = "2.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -225,7 +222,7 @@ version = "0.1.35"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"winapi 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winapi 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -234,6 +231,11 @@ name = "utf8-ranges"
|
||||||
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"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "void"
|
||||||
|
version = "1.0.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi"
|
name = "winapi"
|
||||||
version = "0.2.7"
|
version = "0.2.7"
|
||||||
|
|
|
@ -17,7 +17,7 @@ rustc-serialize = "0.3"
|
||||||
log = "0.3"
|
log = "0.3"
|
||||||
epoll = "0.3"
|
epoll = "0.3"
|
||||||
signal = ">=0.1.4"
|
signal = ">=0.1.4"
|
||||||
nix = "0.5"
|
nix = "0.6"
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
aligned_alloc = "0.1"
|
aligned_alloc = "0.1"
|
||||||
rand = "0.3"
|
rand = "0.3"
|
||||||
|
|
26
build.rs
26
build.rs
|
@ -2,20 +2,34 @@ extern crate gcc;
|
||||||
extern crate pkg_config;
|
extern crate pkg_config;
|
||||||
|
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use std::path::Path;
|
use std::path::PathBuf;
|
||||||
use std::env;
|
use std::env;
|
||||||
|
use std::fs;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
if ! Path::new("libsodium/src/libsodium/.libs/libsodium.a").exists() {
|
|
||||||
let target = env::var("TARGET").unwrap();
|
let target = env::var("TARGET").unwrap();
|
||||||
Command::new("sh").arg("autogen.sh").current_dir("libsodium").status().unwrap();
|
let dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
|
||||||
|
let libsodium_dir = dir.join("libsodium");
|
||||||
|
let libsodium_target_dir = dir.join(".sodium-build").join(&target);
|
||||||
|
let libsodium_target_file = libsodium_target_dir.join("libsodium.a");
|
||||||
|
if ! libsodium_target_file.exists() {
|
||||||
|
fs::create_dir_all(&libsodium_target_dir).unwrap();
|
||||||
|
Command::new("make").arg("clean").current_dir(&libsodium_dir).status().unwrap();
|
||||||
|
Command::new("sh").arg("autogen.sh").current_dir(&libsodium_dir).status().unwrap();
|
||||||
let mut args = vec!["configure", "--host", &target];
|
let mut args = vec!["configure", "--host", &target];
|
||||||
if target.starts_with("i686-") {
|
if target.starts_with("i686-") {
|
||||||
args.extend(vec!["CFLAGS=-m32", "CXXFLAGS=-m32", "LDFLAGS=-m32"]);
|
args.extend(vec!["CFLAGS=-m32", "CXXFLAGS=-m32", "LDFLAGS=-m32"]);
|
||||||
}
|
}
|
||||||
Command::new("sh").args(&args).current_dir("libsodium").status().unwrap();
|
if target.ends_with("-musl") {
|
||||||
Command::new("make").current_dir("libsodium").status().unwrap();
|
args.extend(vec!["CC=musl-gcc"]);
|
||||||
|
}
|
||||||
|
if target == "armv7-unknown-linux-gnueabihf" {
|
||||||
|
args.extend(vec!["CC=arm-linux-gnueabihf-gcc"]);
|
||||||
|
}
|
||||||
|
Command::new("sh").args(&args).current_dir(&libsodium_dir).status().unwrap();
|
||||||
|
Command::new("make").current_dir(&libsodium_dir).status().unwrap();
|
||||||
|
fs::copy(libsodium_dir.join("src/libsodium/.libs/libsodium.a"), libsodium_target_file).unwrap();
|
||||||
}
|
}
|
||||||
gcc::Config::new().file("src/c/tuntap.c").include("src").compile("libtuntap.a");
|
gcc::Config::new().file("src/c/tuntap.c").include("src").compile("libtuntap.a");
|
||||||
println!("cargo:rustc-link-search={}", "libsodium/src/libsodium/.libs");
|
println!("cargo:rustc-link-search={}", libsodium_target_dir.to_str().unwrap());
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,12 +10,12 @@ use std::fmt;
|
||||||
use std::os::unix::io::AsRawFd;
|
use std::os::unix::io::AsRawFd;
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::hash::BuildHasherDefault;
|
use std::hash::BuildHasherDefault;
|
||||||
|
use std::time::Instant;
|
||||||
|
|
||||||
use fnv::FnvHasher;
|
use fnv::FnvHasher;
|
||||||
use epoll;
|
use epoll;
|
||||||
use nix::sys::signal::{SIGTERM, SIGQUIT, SIGINT};
|
use nix::sys::signal::{SIGTERM, SIGQUIT, SIGINT};
|
||||||
use signal::trap::Trap;
|
use signal::trap::Trap;
|
||||||
use time::SteadyTime;
|
|
||||||
use rand::{random, sample, thread_rng};
|
use rand::{random, sample, thread_rng};
|
||||||
use net2::UdpBuilder;
|
use net2::UdpBuilder;
|
||||||
|
|
||||||
|
@ -174,6 +174,7 @@ pub struct GenericCloud<P: Protocol> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<P: Protocol> GenericCloud<P> {
|
impl<P: Protocol> GenericCloud<P> {
|
||||||
|
#[allow(too_many_arguments)]
|
||||||
pub fn new(device: Device, listen: u16, network_id: Option<NetworkId>, table: Box<Table>,
|
pub fn new(device: Device, listen: u16, network_id: Option<NetworkId>, table: Box<Table>,
|
||||||
peer_timeout: Duration, learning: bool, broadcast: bool, addresses: Vec<Range>,
|
peer_timeout: Duration, learning: bool, broadcast: bool, addresses: Vec<Range>,
|
||||||
crypto: Crypto) -> Self {
|
crypto: Crypto) -> Self {
|
||||||
|
@ -439,8 +440,9 @@ impl<P: Protocol> GenericCloud<P> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(cyclomatic_complexity)]
|
||||||
pub fn run(&mut self) {
|
pub fn run(&mut self) {
|
||||||
let dummy_time = SteadyTime::now();
|
let dummy_time = Instant::now();
|
||||||
let trap = Trap::trap(&[SIGINT, SIGTERM, SIGQUIT]);
|
let trap = Trap::trap(&[SIGINT, SIGTERM, SIGQUIT]);
|
||||||
let epoll_handle = try_fail!(epoll::create1(0), "Failed to create epoll handle: {}");
|
let epoll_handle = try_fail!(epoll::create1(0), "Failed to create epoll handle: {}");
|
||||||
let socket4_fd = self.socket4.as_raw_fd();
|
let socket4_fd = self.socket4.as_raw_fd();
|
||||||
|
|
|
@ -180,11 +180,11 @@ impl Crypto {
|
||||||
pub fn nonce_bytes(&self) -> usize {
|
pub fn nonce_bytes(&self) -> usize {
|
||||||
match *self {
|
match *self {
|
||||||
Crypto::None => 0,
|
Crypto::None => 0,
|
||||||
Crypto::ChaCha20Poly1305{ref nonce, ..} => nonce.len(),
|
Crypto::ChaCha20Poly1305{ref nonce, ..} | Crypto::AES256GCM{ref nonce, ..} => nonce.len(),
|
||||||
Crypto::AES256GCM{ref nonce, ..} => nonce.len()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(match_same_arms)]
|
||||||
pub fn additional_bytes(&self) -> usize {
|
pub fn additional_bytes(&self) -> usize {
|
||||||
match *self {
|
match *self {
|
||||||
Crypto::None => 0,
|
Crypto::None => 0,
|
||||||
|
|
|
@ -108,6 +108,7 @@ impl fmt::Debug for Address {
|
||||||
impl FromStr for Address {
|
impl FromStr for Address {
|
||||||
type Err=Error;
|
type Err=Error;
|
||||||
|
|
||||||
|
#[allow(needless_range_loop)]
|
||||||
fn from_str(text: &str) -> Result<Self, Self::Err> {
|
fn from_str(text: &str) -> Result<Self, Self::Err> {
|
||||||
if let Ok(addr) = Ipv4Addr::from_str(text) {
|
if let Ok(addr) = Ipv4Addr::from_str(text) {
|
||||||
let ip = addr.octets();
|
let ip = addr.octets();
|
||||||
|
|
|
@ -94,6 +94,7 @@ impl<'a> fmt::Debug for Message<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(needless_range_loop)]
|
||||||
pub fn decode<'a>(data: &'a mut [u8], crypto: &mut Crypto) -> Result<(Options, Message<'a>), Error> {
|
pub fn decode<'a>(data: &'a mut [u8], crypto: &mut Crypto) -> Result<(Options, 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) = try!(TopHeader::read_from(&data[..end]));
|
||||||
|
@ -193,6 +194,7 @@ pub fn decode<'a>(data: &'a mut [u8], crypto: &mut Crypto) -> Result<(Options, M
|
||||||
Ok((options, msg))
|
Ok((options, msg))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(needless_range_loop)]
|
||||||
pub fn encode<'a>(options: &Options, msg: &'a mut Message, mut buf: &'a mut [u8], crypto: &mut Crypto) -> &'a mut [u8] {
|
pub fn encode<'a>(options: &Options, msg: &'a mut Message, mut buf: &'a mut [u8], crypto: &mut Crypto) -> &'a mut [u8] {
|
||||||
let mut start = 64;
|
let mut start = 64;
|
||||||
let mut end = 64;
|
let mut end = 64;
|
||||||
|
|
Loading…
Reference in New Issue