mirror of https://github.com/dswd/vpncloud.git
Compare commits
No commits in common. "7e55ec5df6b7e6b83f6fe35299f72fa26c2638e3" and "06f3d3c761456eb1abe7ed2206c75ce6925c9127" have entirely different histories.
7e55ec5df6
...
06f3d3c761
|
@ -0,0 +1,39 @@
|
||||||
|
[target.armv7-unknown-linux-gnueabihf]
|
||||||
|
linker = "arm-linux-gnueabihf-gcc"
|
||||||
|
objcopy = { path = "arm-linux-gnueabihf-objcopy" }
|
||||||
|
strip = { path = "arm-linux-gnueabihf-strip" }
|
||||||
|
|
||||||
|
[target.armv7-unknown-linux-musleabihf]
|
||||||
|
linker = "arm-linux-gnueabihf-gcc"
|
||||||
|
objcopy = { path = "arm-linux-gnueabihf-objcopy" }
|
||||||
|
strip = { path = "arm-linux-gnueabihf-strip" }
|
||||||
|
|
||||||
|
[target.arm-unknown-linux-gnueabihf]
|
||||||
|
linker = "arm-linux-gnueabihf-gcc"
|
||||||
|
objcopy = { path = "arm-linux-gnueabihf-objcopy" }
|
||||||
|
strip = { path = "arm-linux-gnueabihf-strip" }
|
||||||
|
|
||||||
|
[target.arm-unknown-linux-musleabihf]
|
||||||
|
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" }
|
||||||
|
strip = { path = "aarch64-linux-gnu-strip" }
|
||||||
|
|
||||||
|
[target.aarch64-unknown-linux-musl]
|
||||||
|
linker = "aarch64-linux-gnu-gcc"
|
||||||
|
objcopy = { path = "aarch64-linux-gnu-objcopy" }
|
||||||
|
strip = { path = "aarch64-linux-gnu-strip" }
|
|
@ -0,0 +1,18 @@
|
||||||
|
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.148.1/containers/rust/.devcontainer/base.Dockerfile
|
||||||
|
|
||||||
|
FROM mcr.microsoft.com/vscode/devcontainers/rust:1
|
||||||
|
|
||||||
|
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
||||||
|
&& apt-get -y install --no-install-recommends asciidoctor
|
||||||
|
|
||||||
|
RUN rm /etc/localtime && ln -s /usr/share/zoneinfo/Europe/Berlin /etc/localtime
|
||||||
|
|
||||||
|
RUN chown vscode: -R /usr/local/rustup /usr/local/cargo
|
||||||
|
|
||||||
|
USER vscode
|
||||||
|
|
||||||
|
RUN rustup default 1.73.0 \
|
||||||
|
&& rustup component add clippy rust-src rustfmt
|
||||||
|
|
||||||
|
RUN cargo install cargo-outdated cargo-cache cargo-criterion \
|
||||||
|
&& cargo cache -a
|
|
@ -0,0 +1,41 @@
|
||||||
|
{
|
||||||
|
"name": "Rust",
|
||||||
|
"build": {
|
||||||
|
"dockerfile": "Dockerfile"
|
||||||
|
},
|
||||||
|
"runArgs": [
|
||||||
|
"--cap-add=SYS_PTRACE",
|
||||||
|
"--security-opt",
|
||||||
|
"seccomp=unconfined"
|
||||||
|
],
|
||||||
|
|
||||||
|
// Add the IDs of extensions you want installed when the container is created.
|
||||||
|
// Set *default* container specific settings.json values on container create.
|
||||||
|
"customizations": {
|
||||||
|
"vscode": {
|
||||||
|
"terminal.integrated.shell.linux": "/bin/bash",
|
||||||
|
"lldb.executable": "/usr/bin/lldb",
|
||||||
|
// VS Code don't watch files under ./target
|
||||||
|
"files.watcherExclude": {
|
||||||
|
"**/target/**": true
|
||||||
|
},
|
||||||
|
// Add the IDs of extensions you want installed when the container is created.
|
||||||
|
"extensions": [
|
||||||
|
"bungcip.better-toml",
|
||||||
|
"vadimcn.vscode-lldb",
|
||||||
|
"serayuzgur.crates",
|
||||||
|
"editorconfig.editorconfig",
|
||||||
|
"swellaby.vscode-rust-test-adapter",
|
||||||
|
"matklad.rust-analyzer",
|
||||||
|
"asciidoctor.asciidoctor-vscode",
|
||||||
|
"ms-vscode.test-adapter-converter"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
||||||
|
// "forwardPorts": [],
|
||||||
|
// Use 'postCreateCommand' to run commands after the container is created.
|
||||||
|
// "postCreateCommand": "rustc --version",
|
||||||
|
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
|
||||||
|
"remoteUser": "vscode"
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
%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: @@RELEASE@@
|
||||||
|
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
|
||||||
|
chmod 700 %{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}/../../../../../assets/vpncloud.target %{buildroot}/lib/systemd/system/vpncloud.target
|
||||||
|
cp %{buildroot}/../../../../../assets/vpncloud-wsproxy.service %{buildroot}/lib/systemd/system/vpncloud-wsproxy.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
|
||||||
|
/lib/systemd/system/vpncloud.target
|
||||||
|
/lib/systemd/system/vpncloud-wsproxy.service
|
||||||
|
/usr/share/man/man1/vpncloud.1.gz
|
||||||
|
|
||||||
|
%defattr(-,root,root,-)
|
||||||
|
%{_bindir}/*
|
|
@ -4,7 +4,7 @@ This project follows [semantic versioning](http://semver.org).
|
||||||
|
|
||||||
### UNRELEASED
|
### UNRELEASED
|
||||||
|
|
||||||
- [changed] Changed Rust version to 1.75.0
|
- [changed] Changed Rust version to 1.73.0
|
||||||
- [changed] Updated dependencies
|
- [changed] Updated dependencies
|
||||||
- [fixed] Fix error when IPv6 is not available
|
- [fixed] Fix error when IPv6 is not available
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
30
Cargo.toml
30
Cargo.toml
|
@ -1,18 +1,19 @@
|
||||||
[package]
|
[package]
|
||||||
name = "vpncloud"
|
name = "vpncloud"
|
||||||
version = "2.4.0"
|
version = "2.3.0"
|
||||||
authors = ["Dennis Schwerdel <schwerdel@googlemail.com>"]
|
authors = ["Dennis Schwerdel <schwerdel@googlemail.com>"]
|
||||||
|
build = "build.rs"
|
||||||
license = "GPL-3.0"
|
license = "GPL-3.0"
|
||||||
description = "Peer-to-peer VPN"
|
description = "Peer-to-peer VPN"
|
||||||
homepage = "https://vpncloud.ddswd.de"
|
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 = "2021"
|
edition = "2018"
|
||||||
|
|
||||||
[package.metadata]
|
[package.metadata]
|
||||||
toolchain = "1.75.0"
|
toolchain = "1.73.0"
|
||||||
upx_version = "4.2.2"
|
upx_version = "3.96"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
chrono = { version = "0.4", features = ["std", "clock"], default_features = false}
|
chrono = { version = "0.4", features = ["std", "clock"], default_features = false}
|
||||||
|
@ -26,13 +27,14 @@ rand = "0.8"
|
||||||
fnv = "1"
|
fnv = "1"
|
||||||
yaml-rust = "0.4"
|
yaml-rust = "0.4"
|
||||||
daemonize = "0.5"
|
daemonize = "0.5"
|
||||||
ring = "0.17"
|
#ring = "0.17"
|
||||||
|
ring = { git = "https://github.com/briansmith/ring", rev = "2afc921" } # https://github.com/briansmith/ring/issues/1707
|
||||||
privdrop = "0.5"
|
privdrop = "0.5"
|
||||||
byteorder = "1.4"
|
byteorder = "1.4"
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
smallvec = "1.7"
|
smallvec = "1.7"
|
||||||
dialoguer = { version = "0.11", optional = true }
|
dialoguer = { version = "0.11", optional = true }
|
||||||
tungstenite = { version = "0.21", optional = true }
|
tungstenite = { version = "0.20", optional = true }
|
||||||
url = { version = "2.2", optional = true }
|
url = { version = "2.2", optional = true }
|
||||||
igd = { version = "0.12", optional = true }
|
igd = { version = "0.12", optional = true }
|
||||||
|
|
||||||
|
@ -59,7 +61,6 @@ harness = false
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
lto = true
|
lto = true
|
||||||
strip = true
|
|
||||||
|
|
||||||
[profile.dev]
|
[profile.dev]
|
||||||
lto = false
|
lto = false
|
||||||
|
@ -89,13 +90,8 @@ assets = [
|
||||||
["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.generate-rpm]
|
[package.metadata.rpm.cargo]
|
||||||
assets = [
|
buildflags = ["--release"]
|
||||||
{ source = "target/release/vpncloud", dest = "/usr/bin/vpncloud", mode = "755" },
|
|
||||||
{ source = "assets/example.net.disabled", dest = "/etc/vpncloud/example.net.disabled", mode = "600" },
|
[package.metadata.rpm.targets]
|
||||||
{ source = "assets/vpncloud@.service", dest = "/lib/systemd/system/vpncloud@.service", mode = "644" },
|
vpncloud = { path = "/usr/bin/vpncloud" }
|
||||||
{ source = "assets/vpncloud.target", dest = "/lib/systemd/system/vpncloud.target", mode = "644" },
|
|
||||||
{ source = "assets/vpncloud-wsproxy.service", dest = "/lib/systemd/system/vpncloud-wsproxy.service", mode = "644" },
|
|
||||||
{ source = "target/vpncloud.1.gz", dest = "/usr/share/man/man1/vpncloud.1.gz", mode = "644" }
|
|
||||||
]
|
|
||||||
auto-req = "no"
|
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
// VpnCloud - Peer-to-Peer VPN
|
||||||
|
// Copyright (C) 2015-2021 Dennis Schwerdel
|
||||||
|
// This software is licensed under GPL-3 or newer (see LICENSE.md)
|
||||||
|
|
||||||
|
use std::{env, fs, path::Path, process::Command};
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let out_dir = env::var("OUT_DIR").unwrap();
|
||||||
|
|
||||||
|
// Process manpage using asciidoctor command
|
||||||
|
println!("cargo:rerun-if-changed=vpncloud.adoc");
|
||||||
|
fs::create_dir_all(&out_dir).unwrap();
|
||||||
|
fs::copy("vpncloud.adoc", Path::new(&out_dir).join("vpncloud.adoc")).unwrap();
|
||||||
|
match Command::new("asciidoctor")
|
||||||
|
.args(["-b", "manpage", "vpncloud.adoc"])
|
||||||
|
.current_dir(Path::new(&out_dir))
|
||||||
|
.status()
|
||||||
|
{
|
||||||
|
Ok(_) => {
|
||||||
|
Command::new("gzip").args(["vpncloud.1"]).current_dir(Path::new(&out_dir)).status().unwrap();
|
||||||
|
fs::copy(Path::new(&out_dir).join("vpncloud.1.gz"), "target/vpncloud.1.gz").unwrap();
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
println!("cargo:warning=Error building manpage: {}", err);
|
||||||
|
println!("cargo:warning=The manpage will not be build. Do you have 'asciidoctor'?");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,2 @@
|
||||||
|
cache
|
||||||
|
build.sh
|
|
@ -0,0 +1,45 @@
|
||||||
|
FROM ubuntu:16.04
|
||||||
|
|
||||||
|
ARG TOOLCHAIN=stable
|
||||||
|
ARG UPX_VERSION=3.96
|
||||||
|
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get install -y --no-install-recommends \
|
||||||
|
build-essential \
|
||||||
|
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 \
|
||||||
|
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
ENV RUSTUP_HOME=/opt/rust/rustup \
|
||||||
|
PATH=/opt/rust/cargo/bin:/home/user/.cargo/bin:/usr/local/musl/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
RUN env CARGO_HOME=/opt/rust/cargo cargo install cargo-deb \
|
||||||
|
&& rm -rf /opt/rust/cargo/{git,tmp,registry}
|
||||||
|
|
||||||
|
RUN ln -s asm-generic/ /usr/include/asm
|
||||||
|
|
||||||
|
RUN useradd -ms /bin/bash user
|
||||||
|
USER user
|
||||||
|
WORKDIR /home/user
|
||||||
|
|
||||||
|
RUN mkdir -p /home/user/.cargo \
|
||||||
|
&& ln -s /opt/rust/cargo/config /home/user/.cargo/config
|
||||||
|
|
||||||
|
VOLUME /home/user/.cargo/tmp
|
||||||
|
VOLUME /home/user/.cargo/git
|
||||||
|
VOLUME /home/user/.cargo/registry
|
|
@ -0,0 +1,49 @@
|
||||||
|
FROM ubuntu:16.04
|
||||||
|
|
||||||
|
ARG TOOLCHAIN=stable
|
||||||
|
ARG UPX_VERSION=3.96
|
||||||
|
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get install -y --no-install-recommends --no-install-suggests \
|
||||||
|
build-essential \
|
||||||
|
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 \
|
||||||
|
musl musl-dev musl-tools \
|
||||||
|
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
ENV RUSTUP_HOME=/opt/rust/rustup \
|
||||||
|
PATH=/opt/rust/cargo/bin:/home/user/.cargo/bin:/usr/local/musl/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||||
|
|
||||||
|
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 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
|
||||||
|
|
||||||
|
RUN curl https://github.com/upx/upx/releases/download/v${UPX_VERSION}/upx-${UPX_VERSION}-amd64_linux.tar.xz -Lf | tar -xJ --strip-components=1 -C /opt/rust/cargo/bin
|
||||||
|
|
||||||
|
RUN ln -s asm-generic/ /usr/include/asm \
|
||||||
|
&& ln -s /usr/bin/g++ /usr/bin/musl-g++ \
|
||||||
|
&& ln -s /usr/bin/aarch64-linux-gnu-gcc /usr/bin/aarch64-linux-musl-gcc \
|
||||||
|
&& ln -s /usr/bin/arm-linux-gnueabihf-gcc /usr/bin/arm-linux-musleabihf-gcc
|
||||||
|
|
||||||
|
RUN useradd -ms /bin/bash user
|
||||||
|
USER user
|
||||||
|
WORKDIR /home/user
|
||||||
|
|
||||||
|
RUN mkdir -p /home/user/.cargo \
|
||||||
|
&& ln -s /opt/rust/cargo/config /home/user/.cargo/config
|
||||||
|
|
||||||
|
VOLUME /home/user/.cargo/tmp
|
||||||
|
VOLUME /home/user/.cargo/git
|
||||||
|
VOLUME /home/user/.cargo/registry
|
|
@ -0,0 +1,34 @@
|
||||||
|
FROM centos:7
|
||||||
|
|
||||||
|
ARG TOOLCHAIN=stable
|
||||||
|
|
||||||
|
RUN yum groupinstall -y 'Development Tools'
|
||||||
|
RUN yum install -y ruby && gem install asciidoctor -v 2.0.10
|
||||||
|
|
||||||
|
ENV RUSTUP_HOME=/opt/rust/rustup \
|
||||||
|
PATH=/opt/rust/cargo/bin:/home/user/.cargo/bin:/usr/local/musl/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||||
|
|
||||||
|
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 armv7-unknown-linux-gnueabihf
|
||||||
|
|
||||||
|
RUN env CARGO_HOME=/opt/rust/cargo cargo install cargo-rpm \
|
||||||
|
&& rm -rf /opt/rust/cargo/{git,tmp,registry}
|
||||||
|
|
||||||
|
RUN yum install -y libstdc++-*.i686 \
|
||||||
|
&& yum install -y glibc-*.i686 \
|
||||||
|
&& yum install -y libgcc.i686
|
||||||
|
|
||||||
|
RUN ln -s /usr/bin/gcc /usr/bin/i686-linux-gnu-gcc
|
||||||
|
|
||||||
|
RUN useradd -ms /bin/bash user
|
||||||
|
USER user
|
||||||
|
WORKDIR /home/user
|
||||||
|
|
||||||
|
RUN mkdir -p /home/user/.cargo \
|
||||||
|
&& ln -s /opt/rust/cargo/config /home/user/.cargo/config
|
||||||
|
|
||||||
|
VOLUME /home/user/.cargo/tmp
|
||||||
|
VOLUME /home/user/.cargo/git
|
||||||
|
VOLUME /home/user/.cargo/registry
|
|
@ -0,0 +1,98 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
function docker_cmd() {
|
||||||
|
DIST=$1
|
||||||
|
CMD=$2
|
||||||
|
mkdir -p $CACHE/$DIST/{target,registry,git,tmp}
|
||||||
|
docker run -it --rm -v $(pwd)/..:/home/user/code \
|
||||||
|
-v $CACHE/$DIST/target:/home/user/code/target \
|
||||||
|
-v $CACHE/$DIST/registry:/home/user/.cargo/registry \
|
||||||
|
-v $CACHE/$DIST/git:/home/user/.cargo/git \
|
||||||
|
-v $CACHE/$DIST/tmp:/home/user/.cargo/tmp \
|
||||||
|
vpncloud-builder-$DIST bash -c "$CMD"
|
||||||
|
}
|
||||||
|
|
||||||
|
# docker run -it --rm -v $(pwd)/..:/home/user/code -v $(pwd)/cache/rpm/target:/home/user/code/target -v $(pwd)/cache/rpm/registry:/home/user/code/registry -v $(pwd)/cache/rpm/git:/home/user/code/git -v $(pwd)/cache/rpm/tmp:/home/user/code/tmp vpncloud-builder-rpm
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
cd $(dirname $0)
|
||||||
|
|
||||||
|
TOOLCHAIN=$(grep -e '^toolchain =' ../Cargo.toml | sed -e 's/toolchain = "\(.*\)"/\1/')
|
||||||
|
UPX_VERSION=$(grep -e '^upx_version =' ../Cargo.toml | sed -e 's/upx_version = "\(.*\)"/\1/')
|
||||||
|
|
||||||
|
VERSION=$(grep -e '^version =' ../Cargo.toml | sed -e 's/version = "\(.*\)"/\1/')
|
||||||
|
DEB_VERSION=$(echo "$VERSION" | sed -e 's/-/~/g')
|
||||||
|
if echo "$VERSION" | fgrep -q "-"; then
|
||||||
|
RPM_VERSION=$(echo "$VERSION" | sed -e 's/-/-0./g')
|
||||||
|
else
|
||||||
|
RPM_VERSION="$VERSION-1"
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p cache/{rpm,deb,musl}
|
||||||
|
CACHE=$(pwd)/cache
|
||||||
|
|
||||||
|
mkdir -p ../dist
|
||||||
|
|
||||||
|
docker build --rm -f=Dockerfile-deb --build-arg TOOLCHAIN=$TOOLCHAIN --build-arg UPX_VERSION=$UPX_VERSION -t vpncloud-builder-deb .
|
||||||
|
|
||||||
|
# x86_64 deb
|
||||||
|
if ! [ -f ../dist/vpncloud_${DEB_VERSION}_amd64.deb ]; then
|
||||||
|
docker_cmd deb 'cd code && cargo deb'
|
||||||
|
cp $CACHE/deb/target/debian/vpncloud_${DEB_VERSION}_amd64.deb ../dist/vpncloud_${DEB_VERSION}_amd64.deb
|
||||||
|
fi
|
||||||
|
|
||||||
|
build_deb() {
|
||||||
|
ARCH=$1
|
||||||
|
TARGET=$2
|
||||||
|
if ! [ -f ../dist/vpncloud_${DEB_VERSION}_${ARCH}.deb ]; then
|
||||||
|
docker_cmd deb "cd code && cargo deb --target ${TARGET}"
|
||||||
|
cp $CACHE/deb/target/${TARGET}/debian/vpncloud_${DEB_VERSION}_${ARCH}.deb ../dist/vpncloud_${DEB_VERSION}_${ARCH}.deb
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
docker build --rm -f=Dockerfile-musl -t vpncloud-builder-musl .
|
||||||
|
|
||||||
|
build_static() {
|
||||||
|
ARCH=$1
|
||||||
|
TARGET=$2
|
||||||
|
if ! [ -f ../dist/vpncloud_${VERSION}_static_${ARCH} ]; then
|
||||||
|
docker_cmd musl "cd code && cargo build --release --features installer --target ${TARGET} && upx --lzma target/${TARGET}/release/vpncloud"
|
||||||
|
cp $CACHE/musl/target/${TARGET}/release/vpncloud ../dist/vpncloud_${VERSION}_static_${ARCH}
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
docker build --rm -f=Dockerfile-rpm -t vpncloud-builder-rpm .
|
||||||
|
|
||||||
|
if ! [ -f ../dist/vpncloud_${RPM_VERSION}.x86_64.rpm ]; then
|
||||||
|
# x86_64 rpm
|
||||||
|
docker_cmd rpm 'cd code && cargo rpm build'
|
||||||
|
cp $CACHE/rpm/target/release/rpmbuild/RPMS/x86_64/vpncloud-${RPM_VERSION}.x86_64.rpm ../dist/vpncloud_${RPM_VERSION}.x86_64.rpm
|
||||||
|
fi
|
||||||
|
|
||||||
|
build_rpm() {
|
||||||
|
ARCH=$1
|
||||||
|
TARGET=$2
|
||||||
|
if ! [ -f ../dist/vpncloud_${RPM_VERSION}.${ARCH}.rpm ]; then
|
||||||
|
mkdir -p $CACHE/rpm/target
|
||||||
|
[ -L $CACHE/rpm/target/assets ] || ln -s ../assets $CACHE/rpm/target/assets
|
||||||
|
[ -L $CACHE/rpm/target/target ] || ln -s ../target $CACHE/rpm/target/target
|
||||||
|
docker_cmd rpm "cd code && cargo rpm build --target ${TARGET}"
|
||||||
|
cp $CACHE/rpm/target/${TARGET}/release/rpmbuild/RPMS/${ARCH}/vpncloud-${RPM_VERSION}.${ARCH}.rpm ../dist/vpncloud_${RPM_VERSION}.${ARCH}.rpm
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
build_rpm i686 i686-unknown-linux-gnu
|
196
maskfile.md
196
maskfile.md
|
@ -1,196 +0,0 @@
|
||||||
# Commands
|
|
||||||
|
|
||||||
Needs [mask](https://github.com/jacobdeichert/mask) to run.
|
|
||||||
|
|
||||||
|
|
||||||
## install-tools
|
|
||||||
|
|
||||||
> Install tools.
|
|
||||||
|
|
||||||
```sh
|
|
||||||
set -e
|
|
||||||
apt-get install -y asciidoctor
|
|
||||||
cargo install cargo-binstall
|
|
||||||
cargo binstall cross cargo-deb cargo-generate-rpm
|
|
||||||
UPX_VERSION=$(grep -e '^upx_version =' Cargo.toml | sed -e 's/upx_version = "\(.*\)"/\1/')
|
|
||||||
curl https://github.com/upx/upx/releases/download/v${UPX_VERSION}/upx-${UPX_VERSION}-amd64_linux.tar.xz -Lf | tar -xJ --strip-components=1 -C /usr/local/bin
|
|
||||||
```
|
|
||||||
|
|
||||||
## manpage
|
|
||||||
|
|
||||||
> Generate manpage.
|
|
||||||
|
|
||||||
```sh
|
|
||||||
set -e
|
|
||||||
echo >&2 "Generating manpage"
|
|
||||||
if [ ! -f target/vpncloud.1.gz -o vpncloud.adoc -nt target/vpncloud.1.gz ]; then
|
|
||||||
asciidoctor -b manpage -o target/vpncloud.1 vpncloud.adoc
|
|
||||||
gzip -f target/vpncloud.1
|
|
||||||
fi
|
|
||||||
```
|
|
||||||
|
|
||||||
## build-packages-cross (target) (target_name) (target_name_rpm)
|
|
||||||
|
|
||||||
> Build the project packages for a given target.
|
|
||||||
|
|
||||||
```sh
|
|
||||||
set -e
|
|
||||||
VERSION=$(grep -e '^version =' Cargo.toml | sed -e 's/version = "\(.*\)"/\1/')
|
|
||||||
TARGET=$target
|
|
||||||
TARGET_DIR=target/$target_name
|
|
||||||
|
|
||||||
# compile
|
|
||||||
echo >&2 "Compiling for $target_name"
|
|
||||||
cross build --release --target $TARGET --target-dir $TARGET_DIR
|
|
||||||
mkdir -p target/$TARGET/release
|
|
||||||
cp $TARGET_DIR/$TARGET/release/vpncloud target/$TARGET/release/
|
|
||||||
|
|
||||||
# build deb
|
|
||||||
echo >&2 "Building deb package"
|
|
||||||
cargo deb --no-build --no-strip --target $TARGET
|
|
||||||
mv target/$TARGET/debian/vpncloud_${VERSION}-1_$target_name.deb dist/vpncloud_${VERSION}_$target_name.deb
|
|
||||||
|
|
||||||
# build rpm
|
|
||||||
if [ -n "$target_name_rpm" ]; then
|
|
||||||
echo >&2 "Building rpm package"
|
|
||||||
cargo generate-rpm --target $TARGET --target-dir $TARGET_DIR
|
|
||||||
mv $TARGET_DIR/$TARGET/generate-rpm/vpncloud-${VERSION}-1.$target_name_rpm.rpm dist/vpncloud_${VERSION}-1.$target_name_rpm.rpm
|
|
||||||
fi
|
|
||||||
```
|
|
||||||
|
|
||||||
## build-amd64-packages
|
|
||||||
|
|
||||||
```sh
|
|
||||||
$MASK build-packages-cross x86_64-unknown-linux-gnu amd64 x86_64
|
|
||||||
```
|
|
||||||
|
|
||||||
## build-i386-packages
|
|
||||||
|
|
||||||
```sh
|
|
||||||
$MASK build-packages-cross i686-unknown-linux-gnu i386 i686
|
|
||||||
```
|
|
||||||
|
|
||||||
## build-arm64-packages
|
|
||||||
|
|
||||||
```sh
|
|
||||||
$MASK build-packages-cross aarch64-unknown-linux-gnu arm64 aarch64
|
|
||||||
```
|
|
||||||
|
|
||||||
## build-armhf-packages
|
|
||||||
|
|
||||||
```sh
|
|
||||||
$MASK build-packages-cross armv7-unknown-linux-gnueabihf armhf ""
|
|
||||||
```
|
|
||||||
|
|
||||||
## build-armel-packages
|
|
||||||
|
|
||||||
```sh
|
|
||||||
$MASK build-packages-cross armv5te-unknown-linux-gnueabi armel ""
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## build-static-cross (target) (target_name)
|
|
||||||
|
|
||||||
> Build the project statically for a given target.
|
|
||||||
|
|
||||||
```sh
|
|
||||||
set -e
|
|
||||||
VERSION=$(grep -e '^version =' Cargo.toml | sed -e 's/version = "\(.*\)"/\1/')
|
|
||||||
TARGET=$target
|
|
||||||
TARGET_DIR=target/$target_name-musl
|
|
||||||
BIN=$TARGET_DIR/$TARGET/release/vpncloud
|
|
||||||
|
|
||||||
echo >&2 "Compiling for $target_name musl"
|
|
||||||
cross build --release --features installer --target $TARGET --target-dir $TARGET_DIR
|
|
||||||
upx --lzma $BIN
|
|
||||||
cp $BIN dist/vpncloud_${VERSION}_static_$target_name
|
|
||||||
```
|
|
||||||
|
|
||||||
## build-amd64-static
|
|
||||||
|
|
||||||
```sh
|
|
||||||
$MASK build-static-cross x86_64-unknown-linux-musl amd64
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
## build-i386-static
|
|
||||||
|
|
||||||
```sh
|
|
||||||
$MASK build-static-cross i686-unknown-linux-musl i386
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
## build-arm64-static
|
|
||||||
|
|
||||||
```sh
|
|
||||||
$MASK build-static-cross aarch64-unknown-linux-musl arm64
|
|
||||||
```
|
|
||||||
|
|
||||||
## build-armhf-static
|
|
||||||
|
|
||||||
```sh
|
|
||||||
$MASK build-static-cross armv7-unknown-linux-musleabihf armhf
|
|
||||||
```
|
|
||||||
|
|
||||||
## build-armel-static
|
|
||||||
|
|
||||||
```sh
|
|
||||||
$MASK build-static-cross armv5te-unknown-linux-musleabi armel
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
## build
|
|
||||||
|
|
||||||
> Build the project for all architectures.
|
|
||||||
|
|
||||||
```sh
|
|
||||||
set -e
|
|
||||||
$MASK manpage
|
|
||||||
$MASK build-amd64-packages
|
|
||||||
$MASK build-amd64-static
|
|
||||||
$MASK build-i386-packages
|
|
||||||
$MASK build-i386-static
|
|
||||||
$MASK build-arm64-packages
|
|
||||||
$MASK build-arm64-static
|
|
||||||
$MASK build-armhf-packages
|
|
||||||
$MASK build-armhf-static
|
|
||||||
$MASK build-armel-packages
|
|
||||||
$MASK build-armel-static
|
|
||||||
```
|
|
||||||
|
|
||||||
## test
|
|
||||||
|
|
||||||
> Test the project.
|
|
||||||
|
|
||||||
```sh
|
|
||||||
cargo test --all-features
|
|
||||||
```
|
|
||||||
|
|
||||||
## release
|
|
||||||
|
|
||||||
> Release the project.
|
|
||||||
|
|
||||||
```sh
|
|
||||||
set -e
|
|
||||||
|
|
||||||
$MASK test
|
|
||||||
nano Cargo.toml
|
|
||||||
VERSION=$(grep -e '^version =' Cargo.toml | sed -e 's/version = "\(.*\)"/\1/')
|
|
||||||
nano CHANGELOG.md
|
|
||||||
nano assets/changelog.txt
|
|
||||||
$MASK build
|
|
||||||
git commit -a
|
|
||||||
cargo publish
|
|
||||||
git tag v$VERSION
|
|
||||||
git push --tags
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
## count
|
|
||||||
|
|
||||||
> Count the lines of code.
|
|
||||||
|
|
||||||
```sh
|
|
||||||
tokei
|
|
||||||
```
|
|
|
@ -18,6 +18,7 @@ pub use crate::{
|
||||||
device::{MockDevice, Type},
|
device::{MockDevice, Type},
|
||||||
net::MockSocket,
|
net::MockSocket,
|
||||||
payload::{Frame, Packet, Protocol},
|
payload::{Frame, Packet, Protocol},
|
||||||
|
types::Range,
|
||||||
util::{MockTimeSource, Time, TimeSource},
|
util::{MockTimeSource, Time, TimeSource},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -82,25 +82,25 @@ impl TrafficStats {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn count_out_traffic(&mut self, peer: SocketAddr, bytes: usize) {
|
pub fn count_out_traffic(&mut self, peer: SocketAddr, bytes: usize) {
|
||||||
// HOT PATH
|
// HOT PATH
|
||||||
self.peers.entry(peer).or_default().count_out(bytes);
|
self.peers.entry(peer).or_insert_with(TrafficEntry::default).count_out(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn count_in_traffic(&mut self, peer: SocketAddr, bytes: usize) {
|
pub fn count_in_traffic(&mut self, peer: SocketAddr, bytes: usize) {
|
||||||
// HOT PATH
|
// HOT PATH
|
||||||
self.peers.entry(peer).or_default().count_in(bytes);
|
self.peers.entry(peer).or_insert_with(TrafficEntry::default).count_in(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn count_out_payload(&mut self, remote: Address, local: Address, bytes: usize) {
|
pub fn count_out_payload(&mut self, remote: Address, local: Address, bytes: usize) {
|
||||||
// HOT PATH
|
// HOT PATH
|
||||||
self.payload.entry((remote, local)).or_default().count_out(bytes);
|
self.payload.entry((remote, local)).or_insert_with(TrafficEntry::default).count_out(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn count_in_payload(&mut self, remote: Address, local: Address, bytes: usize) {
|
pub fn count_in_payload(&mut self, remote: Address, local: Address, bytes: usize) {
|
||||||
// HOT PATH
|
// HOT PATH
|
||||||
self.payload.entry((remote, local)).or_default().count_in(bytes);
|
self.payload.entry((remote, local)).or_insert_with(TrafficEntry::default).count_in(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn count_invalid_protocol(&mut self, bytes: usize) {
|
pub fn count_invalid_protocol(&mut self, bytes: usize) {
|
||||||
|
|
Loading…
Reference in New Issue