mirror of
https://github.com/aramperes/onetun.git
synced 2025-09-09 17:58:32 -04:00
Split dependencies that are only used for the binary version of onetun
This commit is contained in:
parent
1c1399d5ff
commit
f85692950f
3 changed files with 17 additions and 4 deletions
14
Cargo.toml
14
Cargo.toml
|
@ -10,15 +10,23 @@ repository = "https://github.com/aramperes/onetun"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
# Required dependencies (bin and lib)
|
||||||
boringtun = { version = "0.4.0", default-features = false }
|
boringtun = { version = "0.4.0", default-features = false }
|
||||||
clap = { version = "2.33", default-features = false, features = ["suggestions"] }
|
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
pretty_env_logger = "0.4"
|
|
||||||
anyhow = "1"
|
anyhow = "1"
|
||||||
smoltcp = { version = "0.8.0", default-features = false, features = ["std", "log", "medium-ip", "proto-ipv4", "proto-ipv6", "socket-udp", "socket-tcp"] }
|
|
||||||
tokio = { version = "1", features = ["full"] }
|
tokio = { version = "1", features = ["full"] }
|
||||||
futures = "0.3.17"
|
futures = "0.3.17"
|
||||||
rand = "0.8.4"
|
rand = "0.8.4"
|
||||||
nom = "7"
|
nom = "7"
|
||||||
async-trait = "0.1.51"
|
async-trait = "0.1.51"
|
||||||
priority-queue = "1.2.0"
|
priority-queue = "1.2.0"
|
||||||
|
smoltcp = { version = "0.8.0", default-features = false, features = ["std", "log", "medium-ip", "proto-ipv4", "proto-ipv6", "socket-udp", "socket-tcp"] }
|
||||||
|
|
||||||
|
# bin-only dependencies
|
||||||
|
clap = { version = "2.33", default-features = false, features = ["suggestions"], optional = true }
|
||||||
|
pretty_env_logger = { version = "0.4", optional = true }
|
||||||
|
|
||||||
|
[features]
|
||||||
|
pcap = []
|
||||||
|
default = [ "bin" ]
|
||||||
|
bin = [ "clap", "pretty_env_logger", "pcap" ]
|
||||||
|
|
|
@ -7,7 +7,6 @@ use std::sync::Arc;
|
||||||
|
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use boringtun::crypto::{X25519PublicKey, X25519SecretKey};
|
use boringtun::crypto::{X25519PublicKey, X25519SecretKey};
|
||||||
use clap::{App, Arg};
|
|
||||||
|
|
||||||
const DEFAULT_PORT_FORWARD_SOURCE: &str = "127.0.0.1";
|
const DEFAULT_PORT_FORWARD_SOURCE: &str = "127.0.0.1";
|
||||||
|
|
||||||
|
@ -29,7 +28,10 @@ pub struct Config {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
|
#[cfg(feature = "bin")]
|
||||||
pub fn from_args() -> anyhow::Result<Self> {
|
pub fn from_args() -> anyhow::Result<Self> {
|
||||||
|
use clap::{App, Arg};
|
||||||
|
|
||||||
let mut warnings = vec![];
|
let mut warnings = vec![];
|
||||||
|
|
||||||
let matches = App::new("onetun")
|
let matches = App::new("onetun")
|
||||||
|
|
|
@ -17,12 +17,14 @@ use crate::wg::WireGuardTunnel;
|
||||||
|
|
||||||
pub mod config;
|
pub mod config;
|
||||||
pub mod events;
|
pub mod events;
|
||||||
|
#[cfg(feature = "pcap")]
|
||||||
pub mod pcap;
|
pub mod pcap;
|
||||||
pub mod tunnel;
|
pub mod tunnel;
|
||||||
pub mod virtual_device;
|
pub mod virtual_device;
|
||||||
pub mod virtual_iface;
|
pub mod virtual_iface;
|
||||||
pub mod wg;
|
pub mod wg;
|
||||||
|
|
||||||
|
#[cfg(feature = "bin")]
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> anyhow::Result<()> {
|
async fn main() -> anyhow::Result<()> {
|
||||||
let config = Config::from_args().with_context(|| "Failed to read config")?;
|
let config = Config::from_args().with_context(|| "Failed to read config")?;
|
||||||
|
@ -126,6 +128,7 @@ async fn main() -> anyhow::Result<()> {
|
||||||
futures::future::pending().await
|
futures::future::pending().await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "bin")]
|
||||||
fn init_logger(config: &Config) -> anyhow::Result<()> {
|
fn init_logger(config: &Config) -> anyhow::Result<()> {
|
||||||
let mut builder = pretty_env_logger::formatted_timed_builder();
|
let mut builder = pretty_env_logger::formatted_timed_builder();
|
||||||
builder.parse_filters(&config.log);
|
builder.parse_filters(&config.log);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue