mirror of https://github.com/dswd/vpncloud.git
Compare commits
No commits in common. "7d86892f6ffc30e2d9594d85a49d5f2e519ea371" and "744a1511100db3b4693250f657673823483cc21e" have entirely different histories.
7d86892f6f
...
744a151110
|
@ -18,16 +18,6 @@ linker = "arm-linux-gnueabihf-gcc"
|
||||||
objcopy = { path = "arm-linux-gnueabihf-objcopy" }
|
objcopy = { path = "arm-linux-gnueabihf-objcopy" }
|
||||||
strip = { path = "arm-linux-gnueabihf-strip" }
|
strip = { path = "arm-linux-gnueabihf-strip" }
|
||||||
|
|
||||||
[target.armv5te-unknown-linux-gnueabi]
|
|
||||||
linker = "arm-linux-gnueabi-gcc"
|
|
||||||
objcopy = { path = "arm-linux-gnueabi-objcopy" }
|
|
||||||
strip = { path = "arm-linux-gnueabi-strip" }
|
|
||||||
|
|
||||||
[target.armv5te-unknown-linux-musleabi]
|
|
||||||
linker = "arm-linux-gnueabi-gcc"
|
|
||||||
objcopy = { path = "arm-linux-gnueabi-objcopy" }
|
|
||||||
strip = { path = "arm-linux-gnueabi-strip" }
|
|
||||||
|
|
||||||
[target.aarch64-unknown-linux-gnu]
|
[target.aarch64-unknown-linux-gnu]
|
||||||
linker = "aarch64-linux-gnu-gcc"
|
linker = "aarch64-linux-gnu-gcc"
|
||||||
objcopy = { path = "aarch64-linux-gnu-objcopy" }
|
objcopy = { path = "aarch64-linux-gnu-objcopy" }
|
||||||
|
|
|
@ -11,8 +11,8 @@ RUN chown vscode: -R /usr/local/rustup /usr/local/cargo
|
||||||
|
|
||||||
USER vscode
|
USER vscode
|
||||||
|
|
||||||
RUN rustup default 1.57.0 \
|
RUN rustup default 1.51.0 \
|
||||||
&& rustup component add clippy rust-src rustfmt
|
&& rustup component add clippy rust-src rustfmt
|
||||||
|
|
||||||
RUN cargo install cargo-outdated cargo-cache cargo-criterion \
|
RUN cargo install cargo-outdated cargo-cache \
|
||||||
&& cargo cache -a
|
&& cargo cache -a
|
||||||
|
|
|
@ -25,8 +25,7 @@
|
||||||
"editorconfig.editorconfig",
|
"editorconfig.editorconfig",
|
||||||
"swellaby.vscode-rust-test-adapter",
|
"swellaby.vscode-rust-test-adapter",
|
||||||
"matklad.rust-analyzer",
|
"matklad.rust-analyzer",
|
||||||
"asciidoctor.asciidoctor-vscode",
|
"asciidoctor.asciidoctor-vscode"
|
||||||
"ms-vscode.test-adapter-converter"
|
|
||||||
],
|
],
|
||||||
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
||||||
// "forwardPorts": [],
|
// "forwardPorts": [],
|
||||||
|
|
|
@ -6,10 +6,8 @@ RUN apt-get update \
|
||||||
curl \
|
curl \
|
||||||
gcc-aarch64-linux-gnu \
|
gcc-aarch64-linux-gnu \
|
||||||
gcc-arm-linux-gnueabihf \
|
gcc-arm-linux-gnueabihf \
|
||||||
gcc-arm-linux-gnueabi \
|
|
||||||
libc6-dev-arm64-cross \
|
libc6-dev-arm64-cross \
|
||||||
libc6-dev-armhf-cross \
|
libc6-dev-armhf-cross \
|
||||||
libc6-dev-armel-cross \
|
|
||||||
libc6-dev-i386 \
|
libc6-dev-i386 \
|
||||||
gcc-5-multilib \
|
gcc-5-multilib \
|
||||||
asciidoctor \
|
asciidoctor \
|
||||||
|
|
|
@ -13,7 +13,6 @@ curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain ${TOOLCHAIN}
|
||||||
source $HOME/.cargo/env
|
source $HOME/.cargo/env
|
||||||
|
|
||||||
rustup target add i686-unknown-linux-gnu
|
rustup target add i686-unknown-linux-gnu
|
||||||
rustup target add armv5te-unknown-linux-gnueabi
|
|
||||||
rustup target add armv7-unknown-linux-gnueabihf
|
rustup target add armv7-unknown-linux-gnueabihf
|
||||||
rustup target add aarch64-unknown-linux-gnu
|
rustup target add aarch64-unknown-linux-gnu
|
||||||
|
|
||||||
|
@ -33,5 +32,4 @@ cp target/debian/vpncloud_${DEB_VERSION}_amd64.deb dist/vpncloud_${DEB_VERSION}_
|
||||||
|
|
||||||
build_deb i386 i686-unknown-linux-gnu
|
build_deb i386 i686-unknown-linux-gnu
|
||||||
build_deb armhf armv7-unknown-linux-gnueabihf
|
build_deb armhf armv7-unknown-linux-gnueabihf
|
||||||
build_deb armel armv5te-unknown-linux-gnueabi
|
|
||||||
build_deb arm64 aarch64-unknown-linux-gnu
|
build_deb arm64 aarch64-unknown-linux-gnu
|
|
@ -6,10 +6,8 @@ RUN apt-get update \
|
||||||
curl \
|
curl \
|
||||||
gcc-aarch64-linux-gnu \
|
gcc-aarch64-linux-gnu \
|
||||||
gcc-arm-linux-gnueabihf \
|
gcc-arm-linux-gnueabihf \
|
||||||
gcc-arm-linux-gnueabi \
|
|
||||||
libc6-dev-arm64-cross \
|
libc6-dev-arm64-cross \
|
||||||
libc6-dev-armhf-cross \
|
libc6-dev-armhf-cross \
|
||||||
libc6-dev-armel-cross \
|
|
||||||
libc6-dev-i386 \
|
libc6-dev-i386 \
|
||||||
gcc-5-multilib \
|
gcc-5-multilib \
|
||||||
asciidoctor \
|
asciidoctor \
|
||||||
|
|
|
@ -17,7 +17,6 @@ source $HOME/.cargo/env
|
||||||
|
|
||||||
rustup target add x86_64-unknown-linux-musl
|
rustup target add x86_64-unknown-linux-musl
|
||||||
rustup target add i686-unknown-linux-musl
|
rustup target add i686-unknown-linux-musl
|
||||||
rustup target add armv5te-unknown-linux-musleabi
|
|
||||||
rustup target add armv7-unknown-linux-musleabihf
|
rustup target add armv7-unknown-linux-musleabihf
|
||||||
rustup target add aarch64-unknown-linux-musl
|
rustup target add aarch64-unknown-linux-musl
|
||||||
|
|
||||||
|
@ -35,5 +34,4 @@ build_static() {
|
||||||
build_static amd64 x86_64-unknown-linux-musl
|
build_static amd64 x86_64-unknown-linux-musl
|
||||||
#build_static i386 i686-unknown-linux-musl
|
#build_static i386 i686-unknown-linux-musl
|
||||||
build_static armhf armv7-unknown-linux-musleabihf
|
build_static armhf armv7-unknown-linux-musleabihf
|
||||||
build_static armel armv5te-unknown-linux-musleabi
|
|
||||||
build_static arm64 aarch64-unknown-linux-musl
|
build_static arm64 aarch64-unknown-linux-musl
|
|
@ -4,12 +4,8 @@ This project follows [semantic versioning](http://semver.org).
|
||||||
|
|
||||||
### UNRELEASED
|
### UNRELEASED
|
||||||
|
|
||||||
- [added] Added build for armv5te (thanks to xek)
|
|
||||||
- [added] Option to specify advertised addresses
|
- [added] Option to specify advertised addresses
|
||||||
- [added] Peers now learn their own address from peers
|
- [added] Peers now learn their own address from peers
|
||||||
- [changed] Changed Rust version to 1.57.0
|
|
||||||
- [changed] Updated dependencies
|
|
||||||
- [fixed] Fixed problem with IPv4 addresses in listen option
|
|
||||||
|
|
||||||
### v2.2.0 (2021-04-06)
|
### v2.2.0 (2021-04-06)
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
10
Cargo.toml
10
Cargo.toml
|
@ -12,7 +12,7 @@ readme = "README.md"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[package.metadata]
|
[package.metadata]
|
||||||
toolchain = "1.57.0"
|
toolchain = "1.51.0"
|
||||||
upx_version = "3.96"
|
upx_version = "3.96"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
@ -30,10 +30,10 @@ ring = "0.16"
|
||||||
privdrop = "0.5"
|
privdrop = "0.5"
|
||||||
byteorder = "1.4"
|
byteorder = "1.4"
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
parking_lot = "^0.11.2"
|
parking_lot = "*"
|
||||||
smallvec = "1.7"
|
smallvec = "1.6"
|
||||||
dialoguer = { version = "0.9", optional = true }
|
dialoguer = { version = "0.8", optional = true }
|
||||||
tungstenite = { version = "0.16", optional = true, default-features = false }
|
tungstenite = { version = "0.13", optional = true, default-features = false }
|
||||||
url = { version = "2.2", optional = true }
|
url = { version = "2.2", optional = true }
|
||||||
igd = { version = "0.12", optional = true }
|
igd = { version = "0.12", optional = true }
|
||||||
timeout_io = "0.6"
|
timeout_io = "0.6"
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
extern crate serde;
|
extern crate serde;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate log;
|
extern crate log;
|
||||||
|
#[macro_use]
|
||||||
|
extern crate tokio;
|
||||||
|
|
||||||
use criterion::{criterion_group, criterion_main, Criterion, Throughput};
|
use criterion::{criterion_group, criterion_main, Criterion, Throughput};
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
extern crate serde;
|
extern crate serde;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate log;
|
extern crate log;
|
||||||
|
#[macro_use]
|
||||||
|
extern crate tokio;
|
||||||
|
|
||||||
use iai::{black_box, main};
|
use iai::{black_box, main};
|
||||||
|
|
||||||
|
|
|
@ -9,10 +9,8 @@ RUN apt-get update \
|
||||||
curl \
|
curl \
|
||||||
gcc-aarch64-linux-gnu \
|
gcc-aarch64-linux-gnu \
|
||||||
gcc-arm-linux-gnueabihf \
|
gcc-arm-linux-gnueabihf \
|
||||||
gcc-arm-linux-gnueabi \
|
|
||||||
libc6-dev-arm64-cross \
|
libc6-dev-arm64-cross \
|
||||||
libc6-dev-armhf-cross \
|
libc6-dev-armhf-cross \
|
||||||
libc6-dev-armel-cross \
|
|
||||||
libc6-dev-i386 \
|
libc6-dev-i386 \
|
||||||
gcc-5-multilib \
|
gcc-5-multilib \
|
||||||
asciidoctor \
|
asciidoctor \
|
||||||
|
@ -24,7 +22,6 @@ ENV RUSTUP_HOME=/opt/rust/rustup \
|
||||||
RUN curl https://sh.rustup.rs -sSf | env CARGO_HOME=/opt/rust/cargo sh -s -- -y --default-toolchain ${TOOLCHAIN} --profile minimal --no-modify-path
|
RUN curl https://sh.rustup.rs -sSf | env CARGO_HOME=/opt/rust/cargo sh -s -- -y --default-toolchain ${TOOLCHAIN} --profile minimal --no-modify-path
|
||||||
|
|
||||||
RUN env CARGO_HOME=/opt/rust/cargo rustup target add i686-unknown-linux-gnu \
|
RUN env CARGO_HOME=/opt/rust/cargo rustup target add i686-unknown-linux-gnu \
|
||||||
&& env CARGO_HOME=/opt/rust/cargo rustup target add armv5te-unknown-linux-gnueabi \
|
|
||||||
&& env CARGO_HOME=/opt/rust/cargo rustup target add armv7-unknown-linux-gnueabihf \
|
&& env CARGO_HOME=/opt/rust/cargo rustup target add armv7-unknown-linux-gnueabihf \
|
||||||
&& env CARGO_HOME=/opt/rust/cargo rustup target add aarch64-unknown-linux-gnu
|
&& env CARGO_HOME=/opt/rust/cargo rustup target add aarch64-unknown-linux-gnu
|
||||||
|
|
||||||
|
|
|
@ -9,10 +9,8 @@ RUN apt-get update \
|
||||||
curl \
|
curl \
|
||||||
gcc-aarch64-linux-gnu \
|
gcc-aarch64-linux-gnu \
|
||||||
gcc-arm-linux-gnueabihf \
|
gcc-arm-linux-gnueabihf \
|
||||||
gcc-arm-linux-gnueabi \
|
|
||||||
libc6-dev-arm64-cross \
|
libc6-dev-arm64-cross \
|
||||||
libc6-dev-armhf-cross \
|
libc6-dev-armhf-cross \
|
||||||
libc6-dev-armel-cross \
|
|
||||||
libc6-dev-i386 \
|
libc6-dev-i386 \
|
||||||
gcc-5-multilib \
|
gcc-5-multilib \
|
||||||
asciidoctor \
|
asciidoctor \
|
||||||
|
@ -26,7 +24,6 @@ RUN curl https://sh.rustup.rs -sSf | env CARGO_HOME=/opt/rust/cargo sh -s -- -y
|
||||||
|
|
||||||
RUN env CARGO_HOME=/opt/rust/cargo rustup target add x86_64-unknown-linux-musl \
|
RUN env CARGO_HOME=/opt/rust/cargo rustup target add x86_64-unknown-linux-musl \
|
||||||
&& env CARGO_HOME=/opt/rust/cargo rustup target add i686-unknown-linux-musl \
|
&& env CARGO_HOME=/opt/rust/cargo rustup target add i686-unknown-linux-musl \
|
||||||
&& env CARGO_HOME=/opt/rust/cargo rustup target add armv5te-unknown-linux-musleabi \
|
|
||||||
&& env CARGO_HOME=/opt/rust/cargo rustup target add armv7-unknown-linux-musleabihf \
|
&& env CARGO_HOME=/opt/rust/cargo rustup target add armv7-unknown-linux-musleabihf \
|
||||||
&& env CARGO_HOME=/opt/rust/cargo rustup target add aarch64-unknown-linux-musl
|
&& env CARGO_HOME=/opt/rust/cargo rustup target add aarch64-unknown-linux-musl
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,6 @@ build_deb() {
|
||||||
|
|
||||||
build_deb i386 i686-unknown-linux-gnu
|
build_deb i386 i686-unknown-linux-gnu
|
||||||
build_deb armhf armv7-unknown-linux-gnueabihf
|
build_deb armhf armv7-unknown-linux-gnueabihf
|
||||||
build_deb armel armv5te-unknown-linux-gnueabi
|
|
||||||
build_deb arm64 aarch64-unknown-linux-gnu
|
build_deb arm64 aarch64-unknown-linux-gnu
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,7 +69,6 @@ build_static() {
|
||||||
|
|
||||||
build_static amd64 x86_64-unknown-linux-musl
|
build_static amd64 x86_64-unknown-linux-musl
|
||||||
#build_static i386 i686-unknown-linux-musl
|
#build_static i386 i686-unknown-linux-musl
|
||||||
build_static armel armv5te-unknown-linux-musleabi
|
|
||||||
build_static armhf armv7-unknown-linux-musleabihf
|
build_static armhf armv7-unknown-linux-musleabihf
|
||||||
build_static arm64 aarch64-unknown-linux-musl
|
build_static arm64 aarch64-unknown-linux-musl
|
||||||
|
|
||||||
|
|
|
@ -387,7 +387,7 @@ impl Config {
|
||||||
if let Some(ref s) = self.hook {
|
if let Some(ref s) = self.hook {
|
||||||
script = Some(s);
|
script = Some(s);
|
||||||
}
|
}
|
||||||
if let Some(s) = self.hooks.get(event) {
|
if let Some(ref s) = self.hooks.get(event) {
|
||||||
script = Some(s);
|
script = Some(s);
|
||||||
}
|
}
|
||||||
if script.is_none() {
|
if script.is_none() {
|
||||||
|
|
|
@ -247,7 +247,7 @@ impl PeerCrypto {
|
||||||
match self {
|
match self {
|
||||||
PeerCrypto::Encrypted { trusted_keys, last_init_message, .. }
|
PeerCrypto::Encrypted { trusted_keys, last_init_message, .. }
|
||||||
| PeerCrypto::Unencrypted { trusted_keys, last_init_message, .. } => {
|
| PeerCrypto::Unencrypted { trusted_keys, last_init_message, .. } => {
|
||||||
let (msg, _) = InitMsg::read_from(buffer.buffer(), trusted_keys)?;
|
let (msg, _) = InitMsg::read_from(buffer.buffer(), &trusted_keys)?;
|
||||||
buffer.clear();
|
buffer.clear();
|
||||||
if msg.stage() == STAGE_PONG {
|
if msg.stage() == STAGE_PONG {
|
||||||
buffer.set_length(last_init_message.len());
|
buffer.set_length(last_init_message.len());
|
||||||
|
|
|
@ -112,7 +112,7 @@ struct CryptoKey {
|
||||||
|
|
||||||
impl CryptoKey {
|
impl CryptoKey {
|
||||||
fn new(rand: &SystemRandom, key: LessSafeKey, nonce_half: bool) -> Self {
|
fn new(rand: &SystemRandom, key: LessSafeKey, nonce_half: bool) -> Self {
|
||||||
let mut send_nonce = Nonce::random(rand);
|
let mut send_nonce = Nonce::random(&rand);
|
||||||
send_nonce.set_msb(if nonce_half { 0x80 } else { 0x00 });
|
send_nonce.set_msb(if nonce_half { 0x80 } else { 0x00 });
|
||||||
CryptoKey {
|
CryptoKey {
|
||||||
key,
|
key,
|
||||||
|
|
|
@ -246,7 +246,7 @@ impl InitMsg {
|
||||||
|
|
||||||
let signed_data = &r.into_inner()[1..pos];
|
let signed_data = &r.into_inner()[1..pos];
|
||||||
let public_key = signature::UnparsedPublicKey::new(&ED25519, &public_key_data);
|
let public_key = signature::UnparsedPublicKey::new(&ED25519, &public_key_data);
|
||||||
if public_key.verify(signed_data, &signature).is_err() {
|
if public_key.verify(&signed_data, &signature).is_err() {
|
||||||
return Err(Error::Crypto("invalid signature"));
|
return Err(Error::Crypto("invalid signature"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -331,7 +331,7 @@ impl InitMsg {
|
||||||
w.write_u8(Self::PART_ECDH_PUBLIC_KEY)?;
|
w.write_u8(Self::PART_ECDH_PUBLIC_KEY)?;
|
||||||
let key_bytes = ecdh_public_key.bytes();
|
let key_bytes = ecdh_public_key.bytes();
|
||||||
w.write_u16::<NetworkEndian>(key_bytes.len() as u16)?;
|
w.write_u16::<NetworkEndian>(key_bytes.len() as u16)?;
|
||||||
w.write_all(key_bytes)?;
|
w.write_all(&key_bytes)?;
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
@ -536,8 +536,8 @@ impl<P: Payload> InitState<P> {
|
||||||
},
|
},
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
let bytes = out.buffer();
|
let mut bytes = out.buffer();
|
||||||
let len = msg.write_to(bytes, &self.key_pair).expect("Buffer too small");
|
let len = msg.write_to(&mut bytes, &self.key_pair).expect("Buffer too small");
|
||||||
self.last_message = Some(bytes[0..len].to_vec());
|
self.last_message = Some(bytes[0..len].to_vec());
|
||||||
out.set_length(len);
|
out.set_length(len);
|
||||||
}
|
}
|
||||||
|
@ -699,7 +699,7 @@ mod tests {
|
||||||
|
|
||||||
impl Payload for Vec<u8> {
|
impl Payload for Vec<u8> {
|
||||||
fn write_to(&self, buffer: &mut MsgBuffer) {
|
fn write_to(&self, buffer: &mut MsgBuffer) {
|
||||||
buffer.buffer().write_all(self).expect("Buffer too small");
|
buffer.buffer().write_all(&self).expect("Buffer too small");
|
||||||
buffer.set_length(self.len())
|
buffer.set_length(self.len())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -176,7 +176,7 @@ impl RotationState {
|
||||||
if let Some(ref private_key) = self.proposed {
|
if let Some(ref private_key) = self.proposed {
|
||||||
// Still a proposed key that has not been confirmed, proposal must have been lost
|
// Still a proposed key that has not been confirmed, proposal must have been lost
|
||||||
if self.timeout {
|
if self.timeout {
|
||||||
let proposed_key = Self::compute_public_key(private_key);
|
let proposed_key = Self::compute_public_key(&private_key);
|
||||||
if let Some((ref confirmed_key, message_id)) = self.confirmed {
|
if let Some((ref confirmed_key, message_id)) = self.confirmed {
|
||||||
// Reconfirm last confirmed key
|
// Reconfirm last confirmed key
|
||||||
Self::send(
|
Self::send(
|
||||||
|
@ -271,7 +271,7 @@ mod tests {
|
||||||
assert!(key2.is_some());
|
assert!(key2.is_some());
|
||||||
let key2 = key2.unwrap();
|
let key2 = key2.unwrap();
|
||||||
assert_eq!(key2.id, 2);
|
assert_eq!(key2.id, 2);
|
||||||
assert!(!key2.use_for_sending);
|
assert_eq!(key2.use_for_sending, false);
|
||||||
assert!(!out2.is_empty());
|
assert!(!out2.is_empty());
|
||||||
let msg2 = out2.msg().unwrap();
|
let msg2 = out2.msg().unwrap();
|
||||||
assert_eq!(msg2.message_id, 2);
|
assert_eq!(msg2.message_id, 2);
|
||||||
|
@ -281,14 +281,14 @@ mod tests {
|
||||||
assert!(key.is_some());
|
assert!(key.is_some());
|
||||||
let key = key.unwrap();
|
let key = key.unwrap();
|
||||||
assert_eq!(key.id, 2);
|
assert_eq!(key.id, 2);
|
||||||
assert!(key.use_for_sending);
|
assert_eq!(key.use_for_sending, true);
|
||||||
// Cycle 2
|
// Cycle 2
|
||||||
let key1 = node1.cycle(&mut out1);
|
let key1 = node1.cycle(&mut out1);
|
||||||
let key2 = node2.cycle(&mut out2);
|
let key2 = node2.cycle(&mut out2);
|
||||||
assert!(key1.is_some());
|
assert!(key1.is_some());
|
||||||
let key1 = key1.unwrap();
|
let key1 = key1.unwrap();
|
||||||
assert_eq!(key1.id, 3);
|
assert_eq!(key1.id, 3);
|
||||||
assert!(!key1.use_for_sending);
|
assert_eq!(key1.use_for_sending, false);
|
||||||
assert!(!out1.is_empty());
|
assert!(!out1.is_empty());
|
||||||
let msg1 = out1.msg().unwrap();
|
let msg1 = out1.msg().unwrap();
|
||||||
assert_eq!(msg1.message_id, 3);
|
assert_eq!(msg1.message_id, 3);
|
||||||
|
@ -300,7 +300,7 @@ mod tests {
|
||||||
assert!(key.is_some());
|
assert!(key.is_some());
|
||||||
let key = key.unwrap();
|
let key = key.unwrap();
|
||||||
assert_eq!(key.id, 3);
|
assert_eq!(key.id, 3);
|
||||||
assert!(key.use_for_sending);
|
assert_eq!(key.use_for_sending, true);
|
||||||
// Cycle 3
|
// Cycle 3
|
||||||
let key1 = node1.cycle(&mut out1);
|
let key1 = node1.cycle(&mut out1);
|
||||||
let key2 = node2.cycle(&mut out2);
|
let key2 = node2.cycle(&mut out2);
|
||||||
|
@ -309,7 +309,7 @@ mod tests {
|
||||||
assert!(key2.is_some());
|
assert!(key2.is_some());
|
||||||
let key2 = key2.unwrap();
|
let key2 = key2.unwrap();
|
||||||
assert_eq!(key2.id, 4);
|
assert_eq!(key2.id, 4);
|
||||||
assert!(!key2.use_for_sending);
|
assert_eq!(key2.use_for_sending, false);
|
||||||
assert!(!out2.is_empty());
|
assert!(!out2.is_empty());
|
||||||
let msg2 = out2.msg().unwrap();
|
let msg2 = out2.msg().unwrap();
|
||||||
assert_eq!(msg2.message_id, 4);
|
assert_eq!(msg2.message_id, 4);
|
||||||
|
@ -319,7 +319,7 @@ mod tests {
|
||||||
assert!(key.is_some());
|
assert!(key.is_some());
|
||||||
let key = key.unwrap();
|
let key = key.unwrap();
|
||||||
assert_eq!(key.id, 4);
|
assert_eq!(key.id, 4);
|
||||||
assert!(key.use_for_sending);
|
assert_eq!(key.use_for_sending, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -270,7 +270,7 @@ impl Device for TunTapDevice {
|
||||||
fn read(&mut self, buffer: &mut MsgBuffer) -> Result<(), Error> {
|
fn read(&mut self, buffer: &mut MsgBuffer) -> Result<(), Error> {
|
||||||
buffer.clear();
|
buffer.clear();
|
||||||
let mut read = 0;
|
let mut read = 0;
|
||||||
self.fd.try_read(buffer.buffer(), &mut read, Duration::from_secs(1)).map_err(Error::DeviceRead)?;
|
self.fd.try_read(buffer.buffer(), &mut read, Duration::from_secs(1)).map_err(|e| Error::DeviceRead(e))?;
|
||||||
buffer.set_length(read);
|
buffer.set_length(read);
|
||||||
self.correct_data_after_read(buffer);
|
self.correct_data_after_read(buffer);
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -50,7 +50,7 @@ impl<D: Device, P: Protocol, S: Socket, TS: TimeSource> GenericCloud<D, P, S, TS
|
||||||
pub fn new(
|
pub fn new(
|
||||||
config: &Config, socket: S, device: D, port_forwarding: Option<PortForwarding>, stats_file: Option<File>,
|
config: &Config, socket: S, device: D, port_forwarding: Option<PortForwarding>, stats_file: Option<File>,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
let table = SharedTable::<TS>::new(config);
|
let table = SharedTable::<TS>::new(&config);
|
||||||
let traffic = SharedTraffic::new();
|
let traffic = SharedTraffic::new();
|
||||||
let peer_crypto = SharedPeerCrypto::new();
|
let peer_crypto = SharedPeerCrypto::new();
|
||||||
let running = Arc::new(AtomicBool::new(true));
|
let running = Arc::new(AtomicBool::new(true));
|
||||||
|
|
|
@ -430,7 +430,7 @@ impl<S: Socket, D: Device, P: Protocol, TS: TimeSource> SocketThread<S, D, P, TS
|
||||||
pub fn housekeep(&mut self) -> Result<(), Error> {
|
pub fn housekeep(&mut self) -> Result<(), Error> {
|
||||||
let now = TS::now();
|
let now = TS::now();
|
||||||
let mut del: SmallVec<[SocketAddr; 3]> = SmallVec::new();
|
let mut del: SmallVec<[SocketAddr; 3]> = SmallVec::new();
|
||||||
for (&addr, data) in &self.peers {
|
for (&addr, ref data) in &self.peers {
|
||||||
if data.timeout < now {
|
if data.timeout < now {
|
||||||
del.push(addr);
|
del.push(addr);
|
||||||
}
|
}
|
||||||
|
@ -675,7 +675,7 @@ impl<S: Socket, D: Device, P: Protocol, TS: TimeSource> SocketThread<S, D, P, TS
|
||||||
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
|
||||||
for addr in &entry.resolved {
|
for addr in &entry.resolved {
|
||||||
if self.peers.contains_key(addr) {
|
if self.peers.contains_key(&addr) {
|
||||||
entry.tries = 0;
|
entry.tries = 0;
|
||||||
entry.timeout = 1;
|
entry.timeout = 1;
|
||||||
entry.next = now + 1;
|
entry.next = now + 1;
|
||||||
|
|
|
@ -96,15 +96,13 @@ thread_local! {
|
||||||
static MOCK_SOCKET_NAT: AtomicBool = AtomicBool::new(false);
|
static MOCK_SOCKET_NAT: AtomicBool = AtomicBool::new(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
type MsgQueue = Arc<Mutex<VecDeque<(SocketAddr, Vec<u8>)>>>;
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct MockSocket {
|
pub struct MockSocket {
|
||||||
nat: bool,
|
nat: bool,
|
||||||
nat_peers: Arc<Mutex<HashMap<SocketAddr, Time>>>,
|
nat_peers: Arc<Mutex<HashMap<SocketAddr, Time>>>,
|
||||||
address: SocketAddr,
|
address: SocketAddr,
|
||||||
outbound: MsgQueue,
|
outbound: Arc<Mutex<VecDeque<(SocketAddr, Vec<u8>)>>>,
|
||||||
inbound: MsgQueue,
|
inbound: Arc<Mutex<VecDeque<(SocketAddr, Vec<u8>)>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MockSocket {
|
impl MockSocket {
|
||||||
|
|
|
@ -501,8 +501,8 @@ pub fn configure(name: Option<String>) -> Result<(), io::Error> {
|
||||||
println!(" start the VPN: sudo service vpncloud@{0} start", name);
|
println!(" start the VPN: sudo service vpncloud@{0} start", name);
|
||||||
println!(" stop the VPN: sudo service vpncloud@{0} stop", name);
|
println!(" stop the VPN: sudo service vpncloud@{0} stop", name);
|
||||||
println!(" get the status: sudo service vpncloud@{0} status", name);
|
println!(" get the status: sudo service vpncloud@{0} status", name);
|
||||||
println!(" add VPN to autostart: sudo systemctl enable vpncloud@{0}", name);
|
println!(" add VPN to autostart: sudo sysctl enable vpncloud@{0}", name);
|
||||||
println!(" remove VPN from autostart: sudo systemctl disable vpncloud@{0}", name);
|
println!(" remove VPN from autostart: sudo sysctl disable vpncloud@{0}", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -9,13 +9,8 @@ use super::{
|
||||||
util::MsgBuffer,
|
util::MsgBuffer,
|
||||||
};
|
};
|
||||||
use byteorder::{NetworkEndian, ReadBytesExt, WriteBytesExt};
|
use byteorder::{NetworkEndian, ReadBytesExt, WriteBytesExt};
|
||||||
use std::{
|
use std::{io::{self, Cursor, Read, Write}, net::{Ipv6Addr, SocketAddr, SocketAddrV6, TcpListener, TcpStream, UdpSocket}, os::unix::io::AsRawFd, sync::Arc, thread};
|
||||||
io::{self, Cursor, Read, Write},
|
use tungstenite::{client::AutoStream, connect, protocol::WebSocket, server::accept, Message};
|
||||||
net::{Ipv6Addr, SocketAddr, SocketAddrV6, TcpListener, TcpStream, UdpSocket},
|
|
||||||
os::unix::io::{AsRawFd, RawFd},
|
|
||||||
thread, sync::Arc,
|
|
||||||
};
|
|
||||||
use tungstenite::{connect, protocol::WebSocket, Message, accept, stream::{MaybeTlsStream, NoDelay}};
|
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
macro_rules! io_error {
|
macro_rules! io_error {
|
||||||
|
@ -110,7 +105,7 @@ pub fn run_proxy(listen: &str) -> Result<(), io::Error> {
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct ProxyConnection {
|
pub struct ProxyConnection {
|
||||||
addr: SocketAddr,
|
addr: SocketAddr,
|
||||||
socket: Arc<WebSocket<MaybeTlsStream<TcpStream>>>,
|
socket: Arc<WebSocket<AutoStream>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ProxyConnection {
|
impl ProxyConnection {
|
||||||
|
@ -137,15 +132,6 @@ impl ProxyConnection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsRawFd for ProxyConnection {
|
|
||||||
fn as_raw_fd(&self) -> RawFd {
|
|
||||||
match self.socket.get_ref() {
|
|
||||||
MaybeTlsStream::Plain(stream) => stream.as_raw_fd(),
|
|
||||||
_ => unimplemented!()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Socket for ProxyConnection {
|
impl Socket for ProxyConnection {
|
||||||
fn create_port_forwarding(&self) -> Option<PortForwarding> {
|
fn create_port_forwarding(&self) -> Option<PortForwarding> {
|
||||||
None
|
None
|
||||||
|
|
Loading…
Reference in New Issue