Compare commits

..

No commits in common. "7d86892f6ffc30e2d9594d85a49d5f2e519ea371" and "744a1511100db3b4693250f657673823483cc21e" have entirely different histories.

26 changed files with 257 additions and 287 deletions

View File

@ -18,16 +18,6 @@ linker = "arm-linux-gnueabihf-gcc"
objcopy = { path = "arm-linux-gnueabihf-objcopy" }
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]
linker = "aarch64-linux-gnu-gcc"
objcopy = { path = "aarch64-linux-gnu-objcopy" }

View File

@ -11,8 +11,8 @@ RUN chown vscode: -R /usr/local/rustup /usr/local/cargo
USER vscode
RUN rustup default 1.57.0 \
RUN rustup default 1.51.0 \
&& 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

View File

@ -25,8 +25,7 @@
"editorconfig.editorconfig",
"swellaby.vscode-rust-test-adapter",
"matklad.rust-analyzer",
"asciidoctor.asciidoctor-vscode",
"ms-vscode.test-adapter-converter"
"asciidoctor.asciidoctor-vscode"
],
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

View File

@ -6,10 +6,8 @@ RUN apt-get update \
curl \
gcc-aarch64-linux-gnu \
gcc-arm-linux-gnueabihf \
gcc-arm-linux-gnueabi \
libc6-dev-arm64-cross \
libc6-dev-armhf-cross \
libc6-dev-armel-cross \
libc6-dev-i386 \
gcc-5-multilib \
asciidoctor \

View File

@ -13,7 +13,6 @@ curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain ${TOOLCHAIN}
source $HOME/.cargo/env
rustup target add i686-unknown-linux-gnu
rustup target add armv5te-unknown-linux-gnueabi
rustup target add armv7-unknown-linux-gnueabihf
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 armhf armv7-unknown-linux-gnueabihf
build_deb armel armv5te-unknown-linux-gnueabi
build_deb arm64 aarch64-unknown-linux-gnu

View File

@ -6,10 +6,8 @@ RUN apt-get update \
curl \
gcc-aarch64-linux-gnu \
gcc-arm-linux-gnueabihf \
gcc-arm-linux-gnueabi \
libc6-dev-arm64-cross \
libc6-dev-armhf-cross \
libc6-dev-armel-cross \
libc6-dev-i386 \
gcc-5-multilib \
asciidoctor \

View File

@ -17,7 +17,6 @@ source $HOME/.cargo/env
rustup target add x86_64-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 aarch64-unknown-linux-musl
@ -35,5 +34,4 @@ build_static() {
build_static amd64 x86_64-unknown-linux-musl
#build_static i386 i686-unknown-linux-musl
build_static armhf armv7-unknown-linux-musleabihf
build_static armel armv5te-unknown-linux-musleabi
build_static arm64 aarch64-unknown-linux-musl

View File

@ -4,12 +4,8 @@ This project follows [semantic versioning](http://semver.org).
### UNRELEASED
- [added] Added build for armv5te (thanks to xek)
- [added] Option to specify advertised addresses
- [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)

425
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -12,7 +12,7 @@ readme = "README.md"
edition = "2018"
[package.metadata]
toolchain = "1.57.0"
toolchain = "1.51.0"
upx_version = "3.96"
[dependencies]
@ -30,10 +30,10 @@ ring = "0.16"
privdrop = "0.5"
byteorder = "1.4"
thiserror = "1.0"
parking_lot = "^0.11.2"
smallvec = "1.7"
dialoguer = { version = "0.9", optional = true }
tungstenite = { version = "0.16", optional = true, default-features = false }
parking_lot = "*"
smallvec = "1.6"
dialoguer = { version = "0.8", optional = true }
tungstenite = { version = "0.13", optional = true, default-features = false }
url = { version = "2.2", optional = true }
igd = { version = "0.12", optional = true }
timeout_io = "0.6"

View File

@ -3,6 +3,8 @@
extern crate serde;
#[macro_use]
extern crate log;
#[macro_use]
extern crate tokio;
use criterion::{criterion_group, criterion_main, Criterion, Throughput};

View File

@ -3,6 +3,8 @@
extern crate serde;
#[macro_use]
extern crate log;
#[macro_use]
extern crate tokio;
use iai::{black_box, main};

View File

@ -9,10 +9,8 @@ RUN apt-get update \
curl \
gcc-aarch64-linux-gnu \
gcc-arm-linux-gnueabihf \
gcc-arm-linux-gnueabi \
libc6-dev-arm64-cross \
libc6-dev-armhf-cross \
libc6-dev-armel-cross \
libc6-dev-i386 \
gcc-5-multilib \
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 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 aarch64-unknown-linux-gnu

View File

@ -9,10 +9,8 @@ RUN apt-get update \
curl \
gcc-aarch64-linux-gnu \
gcc-arm-linux-gnueabihf \
gcc-arm-linux-gnueabi \
libc6-dev-arm64-cross \
libc6-dev-armhf-cross \
libc6-dev-armel-cross \
libc6-dev-i386 \
gcc-5-multilib \
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 \
&& 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 aarch64-unknown-linux-musl

View File

@ -53,7 +53,6 @@ build_deb() {
build_deb i386 i686-unknown-linux-gnu
build_deb armhf armv7-unknown-linux-gnueabihf
build_deb armel armv5te-unknown-linux-gnueabi
build_deb arm64 aarch64-unknown-linux-gnu
@ -70,7 +69,6 @@ build_static() {
build_static amd64 x86_64-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 arm64 aarch64-unknown-linux-musl

View File

@ -387,7 +387,7 @@ impl Config {
if let Some(ref s) = self.hook {
script = Some(s);
}
if let Some(s) = self.hooks.get(event) {
if let Some(ref s) = self.hooks.get(event) {
script = Some(s);
}
if script.is_none() {

View File

@ -247,7 +247,7 @@ impl PeerCrypto {
match self {
PeerCrypto::Encrypted { 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();
if msg.stage() == STAGE_PONG {
buffer.set_length(last_init_message.len());

View File

@ -112,7 +112,7 @@ struct CryptoKey {
impl CryptoKey {
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 });
CryptoKey {
key,

View File

@ -246,7 +246,7 @@ impl InitMsg {
let signed_data = &r.into_inner()[1..pos];
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"));
}
@ -331,7 +331,7 @@ impl InitMsg {
w.write_u8(Self::PART_ECDH_PUBLIC_KEY)?;
let key_bytes = ecdh_public_key.bytes();
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!(),
};
let bytes = out.buffer();
let len = msg.write_to(bytes, &self.key_pair).expect("Buffer too small");
let mut bytes = out.buffer();
let len = msg.write_to(&mut bytes, &self.key_pair).expect("Buffer too small");
self.last_message = Some(bytes[0..len].to_vec());
out.set_length(len);
}
@ -699,7 +699,7 @@ mod tests {
impl Payload for Vec<u8> {
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())
}

View File

@ -176,7 +176,7 @@ impl RotationState {
if let Some(ref private_key) = self.proposed {
// Still a proposed key that has not been confirmed, proposal must have been lost
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 {
// Reconfirm last confirmed key
Self::send(
@ -271,7 +271,7 @@ mod tests {
assert!(key2.is_some());
let key2 = key2.unwrap();
assert_eq!(key2.id, 2);
assert!(!key2.use_for_sending);
assert_eq!(key2.use_for_sending, false);
assert!(!out2.is_empty());
let msg2 = out2.msg().unwrap();
assert_eq!(msg2.message_id, 2);
@ -281,14 +281,14 @@ mod tests {
assert!(key.is_some());
let key = key.unwrap();
assert_eq!(key.id, 2);
assert!(key.use_for_sending);
assert_eq!(key.use_for_sending, true);
// Cycle 2
let key1 = node1.cycle(&mut out1);
let key2 = node2.cycle(&mut out2);
assert!(key1.is_some());
let key1 = key1.unwrap();
assert_eq!(key1.id, 3);
assert!(!key1.use_for_sending);
assert_eq!(key1.use_for_sending, false);
assert!(!out1.is_empty());
let msg1 = out1.msg().unwrap();
assert_eq!(msg1.message_id, 3);
@ -300,7 +300,7 @@ mod tests {
assert!(key.is_some());
let key = key.unwrap();
assert_eq!(key.id, 3);
assert!(key.use_for_sending);
assert_eq!(key.use_for_sending, true);
// Cycle 3
let key1 = node1.cycle(&mut out1);
let key2 = node2.cycle(&mut out2);
@ -309,7 +309,7 @@ mod tests {
assert!(key2.is_some());
let key2 = key2.unwrap();
assert_eq!(key2.id, 4);
assert!(!key2.use_for_sending);
assert_eq!(key2.use_for_sending, false);
assert!(!out2.is_empty());
let msg2 = out2.msg().unwrap();
assert_eq!(msg2.message_id, 4);
@ -319,7 +319,7 @@ mod tests {
assert!(key.is_some());
let key = key.unwrap();
assert_eq!(key.id, 4);
assert!(key.use_for_sending);
assert_eq!(key.use_for_sending, true);
}
#[test]

View File

@ -270,7 +270,7 @@ impl Device for TunTapDevice {
fn read(&mut self, buffer: &mut MsgBuffer) -> Result<(), Error> {
buffer.clear();
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);
self.correct_data_after_read(buffer);
Ok(())

View File

@ -50,7 +50,7 @@ impl<D: Device, P: Protocol, S: Socket, TS: TimeSource> GenericCloud<D, P, S, TS
pub fn new(
config: &Config, socket: S, device: D, port_forwarding: Option<PortForwarding>, stats_file: Option<File>,
) -> Result<Self, Error> {
let table = SharedTable::<TS>::new(config);
let table = SharedTable::<TS>::new(&config);
let traffic = SharedTraffic::new();
let peer_crypto = SharedPeerCrypto::new();
let running = Arc::new(AtomicBool::new(true));

View File

@ -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> {
let now = TS::now();
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 {
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 {
// Schedule for next second if node is connected
for addr in &entry.resolved {
if self.peers.contains_key(addr) {
if self.peers.contains_key(&addr) {
entry.tries = 0;
entry.timeout = 1;
entry.next = now + 1;

View File

@ -96,15 +96,13 @@ thread_local! {
static MOCK_SOCKET_NAT: AtomicBool = AtomicBool::new(false);
}
type MsgQueue = Arc<Mutex<VecDeque<(SocketAddr, Vec<u8>)>>>;
#[derive(Clone)]
pub struct MockSocket {
nat: bool,
nat_peers: Arc<Mutex<HashMap<SocketAddr, Time>>>,
address: SocketAddr,
outbound: MsgQueue,
inbound: MsgQueue,
outbound: Arc<Mutex<VecDeque<(SocketAddr, Vec<u8>)>>>,
inbound: Arc<Mutex<VecDeque<(SocketAddr, Vec<u8>)>>>,
}
impl MockSocket {

View File

@ -501,8 +501,8 @@ pub fn configure(name: Option<String>) -> Result<(), io::Error> {
println!(" start the VPN: sudo service vpncloud@{0} start", name);
println!(" stop the VPN: sudo service vpncloud@{0} stop", name);
println!(" get the status: sudo service vpncloud@{0} status", name);
println!(" add VPN to autostart: sudo systemctl enable vpncloud@{0}", name);
println!(" remove VPN from autostart: sudo systemctl disable vpncloud@{0}", name);
println!(" add VPN to autostart: sudo sysctl enable vpncloud@{0}", name);
println!(" remove VPN from autostart: sudo sysctl disable vpncloud@{0}", name);
}
Ok(())

View File

@ -9,13 +9,8 @@ use super::{
util::MsgBuffer,
};
use byteorder::{NetworkEndian, ReadBytesExt, WriteBytesExt};
use std::{
io::{self, Cursor, Read, Write},
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 std::{io::{self, Cursor, Read, Write}, net::{Ipv6Addr, SocketAddr, SocketAddrV6, TcpListener, TcpStream, UdpSocket}, os::unix::io::AsRawFd, sync::Arc, thread};
use tungstenite::{client::AutoStream, connect, protocol::WebSocket, server::accept, Message};
use url::Url;
macro_rules! io_error {
@ -110,7 +105,7 @@ pub fn run_proxy(listen: &str) -> Result<(), io::Error> {
#[derive(Clone)]
pub struct ProxyConnection {
addr: SocketAddr,
socket: Arc<WebSocket<MaybeTlsStream<TcpStream>>>,
socket: Arc<WebSocket<AutoStream>>,
}
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 {
fn create_port_forwarding(&self) -> Option<PortForwarding> {
None