Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

structure: split boringtun into a workspace #232

Merged
merged 4 commits into from Mar 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
56 changes: 47 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 3 additions & 56 deletions Cargo.toml
@@ -1,59 +1,6 @@
[package]
name = "boringtun"
description = "an implementation of the WireGuard® protocol designed for portability and speed"
version = "0.4.0"
authors = ["Noah Kennedy <nkennedy@cloudflare.com>", "Andy Grover <agrover@cloudflare.com>"]
license = "BSD-3-Clause"
repository = "https://github.com/cloudflare/boringtun"
documentation = "https://docs.rs/boringtun/0.4.0/boringtun/"
edition = "2018"

[dependencies]
base64 = "0.13"
hex = "0.4"
untrusted = "0.9.0"
libc = "0.2"
parking_lot = "0.12"
tracing = "0.1.29"
ip_network = "0.4.1"
ip_network_table = "0.2.0"
zeroize = { version = "1.5.2", features = ["zeroize_derive"]}
ring = "0.16"

[dependencies.tracing-subscriber]
version = "0.3"
optional = true

[dependencies.tracing-appender]
version = "0.2.0"
optional = true

[dev-dependencies]
tracing-subscriber = "0.3"

[target.'cfg(not(any(target_os="windows", target_os="ios", target_os="android")))'.dependencies]
clap = { version = "2.33", default-features = false, features = ["suggestions"], optional = true }
daemonize = { version = "0.4.1", optional = true }

[target.'cfg(target_os="android")'.dependencies]
jni = "0.19.0"

[features]
default = ["build-binary"]
build-binary = ["tracing-subscriber", "tracing-appender", "clap", "daemonize"]
[workspace]
members = ["boringtun", "boringtun-cli"]

[profile.release]
lto = true # Enable full link-time optimization.
codegen-units = 1 # Use only 1 codegen-unit to enable full optimizations.

[lib]
crate-type = ["lib", "staticlib", "dylib"]

[[bin]]
name = "boringtun"
path = "src/main.rs"
required-features = ["build-binary"]

[[example]]
name = "benchmarks"
path = "src/benchmarks_example.rs"
codegen-units = 1 # Use only 1 codegen-unit to enable full optimizations.
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Expand Up @@ -165,7 +165,7 @@ jobs:
mkdir -p tmp/$name
cp README.md \
LICENSE.md \
tmp/$src/boringtun \
tmp/$src/boringtun-cli \
tmp/$name/
chmod +x tmp/$name/boringtun*
tar czvf gh-release/$name.tar.gz -C tmp $name
Expand Down
15 changes: 15 additions & 0 deletions boringtun-cli/Cargo.toml
@@ -0,0 +1,15 @@
[package]
name = "boringtun-cli"
version = "0.1.0"
edition = "2021"

[dependencies]
daemonize = "0.4.1"
clap = "2.34.0"
tracing = "0.1.31"
tracing-subscriber = "0.3.9"
tracing-appender = "0.2.1"

# CHANGE THIS BEFORE EACH RELEASE
[dependencies.boringtun]
path = "../boringtun"
14 changes: 3 additions & 11 deletions src/main.rs → boringtun-cli/src/main.rs
@@ -1,16 +1,8 @@
// Copyright (c) 2019 Cloudflare, Inc. All rights reserved.
// SPDX-License-Identifier: BSD-3-Clause

pub mod crypto;

#[cfg(not(target_os = "windows"))]
pub mod device;

pub mod ffi;
pub mod noise;

use crate::device::drop_privileges::drop_privileges;
use crate::device::{DeviceConfig, DeviceHandle};
use boringtun::device::drop_privileges::drop_privileges;
use boringtun::device::{DeviceConfig, DeviceHandle};
use clap::{value_t, App, Arg};
use daemonize::Daemonize;
use std::fs::File;
Expand All @@ -20,7 +12,7 @@ use std::process::exit;
fn check_tun_name(_v: String) -> Result<(), String> {
#[cfg(any(target_os = "macos", target_os = "ios"))]
{
if device::tun::parse_utun_name(&_v).is_ok() {
if boringtun::device::tun::parse_utun_name(&_v).is_ok() {
Ok(())
} else {
Err("Tunnel name must have the format 'utun[0-9]+', use 'utun' for automatic assignment".to_owned())
Expand Down
31 changes: 31 additions & 0 deletions boringtun/Cargo.toml
@@ -0,0 +1,31 @@
[package]
name = "boringtun"
description = "an implementation of the WireGuard® protocol designed for portability and speed"
version = "0.4.0"
authors = ["Noah Kennedy <nkennedy@cloudflare.com>", "Andy Grover <agrover@cloudflare.com>"]
license = "BSD-3-Clause"
repository = "https://github.com/cloudflare/boringtun"
documentation = "https://docs.rs/boringtun/0.4.0/boringtun/"
edition = "2018"

[dependencies]
base64 = "0.13"
hex = "0.4"
untrusted = "0.9.0"
libc = "0.2"
parking_lot = "0.12"
tracing = "0.1.29"
ip_network = "0.4.1"
ip_network_table = "0.2.0"
zeroize = { version = "1.5.2", features = ["zeroize_derive"]}
ring = "0.16"

[dev-dependencies]
tracing-subscriber = "0.3"

[target.'cfg(target_os="android")'.dependencies]
jni = "0.19.0"

[[example]]
name = "benchmarks"
path = "src/benchmarks_example.rs"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Expand Up @@ -3,7 +3,7 @@

// This module contains some integration tests for boringtun
// Those tests require docker and sudo privileges to run
#[cfg(test)]
#[cfg(all(test, not(target_os = "macos")))]
mod tests {
use crate::crypto::{SystemRandom, X25519PublicKey, X25519SecretKey};
use crate::device::{DeviceConfig, DeviceHandle};
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions ci/azure-build.yml
Expand Up @@ -20,10 +20,10 @@ steps:
displayName: 'Library integration tests'
- script: |
export PATH=$PATH:$HOME/.cargo/bin
cargo build --bin boringtun
cargo build --bin boringtun-cli
displayName: 'Build executable'
- ${{ if eq(parameters.runBinaryTests, 'true') }}:
- script: |
export PATH=$PATH:$HOME/.cargo/bin
cargo test --bin boringtun -- --test-threads=1
cargo test --bin boringtun-cli -- --test-threads=1
displayName: 'Test executable'
2 changes: 1 addition & 1 deletion ci/azure-create-release-build.yml
Expand Up @@ -6,7 +6,7 @@ steps:
- bash: |
set -ex
dst=$BUILD_ARTIFACTSTAGINGDIRECTORY
cp ${{ parameters.artifacts }}/boringtun $dst/
cp ${{ parameters.artifacts }}/boringtun-cli $dst/
displayName: Create distribution tarball
- task: PublishPipelineArtifact@0
inputs:
Expand Down