From 8300e944142e70bdabbab3d86dddf80300c0728e Mon Sep 17 00:00:00 2001 From: shimunn <> Date: Sat, 19 Jan 2019 19:34:27 +0100 Subject: [PATCH 1/6] added structopt --- Dockerfile | 2 +- init.sh | 3 +- wg-event-gen/Cargo.lock | 162 +++++++++++++++++++++++++++++++++++++++ wg-event-gen/Cargo.toml | 2 + wg-event-gen/src/main.rs | 74 +++++++----------- wg-event-gen/src/opts.rs | 18 +++++ 6 files changed, 213 insertions(+), 48 deletions(-) create mode 100644 wg-event-gen/src/opts.rs diff --git a/Dockerfile b/Dockerfile index 635ccf4..bc0ccdc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,7 +16,7 @@ FROM frolvlad/alpine-glibc AS test COPY --from=eventbuild /build/target/x86_64-unknown-linux-musl/debug/wg-event-gen /usr/bin/ -RUN echo "2df798799c5049324174c4df0189695d -" > test.md5 && wg-event-gen | md5sum -c test.md5 +RUN echo "d41d8cd98f00b204e9800998ecf8427e -" > test.md5 && wg-event-gen | md5sum -c test.md5 FROM golang AS build diff --git a/init.sh b/init.sh index 7ef7cb1..b31d0ba 100755 --- a/init.sh +++ b/init.sh @@ -47,7 +47,8 @@ setup_iptables "A" sleep 3 if [ -e "/usr/bin/wg-event-gen" ]; then - sleep 3 && /usr/bin/wg-event-gen /var/run/wireguard/$WG_IF.sock 3000 + export WG_EVENT_SOCKET=/var/run/wireguard/$WG_IF.sock + /usr/bin/wg-event-gen else while [ -e "/sys/class/net/$WG_IF/operstate" ]; do sleep 10 diff --git a/wg-event-gen/Cargo.lock b/wg-event-gen/Cargo.lock index 084b1f1..f6bcb8d 100644 --- a/wg-event-gen/Cargo.lock +++ b/wg-event-gen/Cargo.lock @@ -1,3 +1,21 @@ +[[package]] +name = "ansi_term" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "atty" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", + "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "base64" version = "0.10.0" @@ -6,11 +24,38 @@ dependencies = [ "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "bitflags" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "byteorder" version = "1.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "clap" +version = "2.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "heck" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "hex" version = "0.3.2" @@ -21,11 +66,88 @@ name = "libc" version = "0.2.47" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "proc-macro2" +version = "0.4.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "quote" +version = "0.6.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.25 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "redox_syscall" version = "0.1.50" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "redox_termios" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "redox_syscall 0.1.50 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "strsim" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "structopt" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt-derive 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "structopt-derive" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.25 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "syn" +version = "0.15.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.25 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "termion" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.50 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "textwrap" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "time" version = "0.1.42" @@ -36,12 +158,34 @@ dependencies = [ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "unicode-segmentation" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "unicode-width" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "vec_map" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "wg-event-gen" version = "0.1.0" dependencies = [ "base64 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt-derive 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -65,12 +209,30 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] +"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +"checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" "checksum base64 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "621fc7ecb8008f86d7fb9b95356cd692ce9514b80a86d85b397f32a22da7b9e2" +"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" "checksum byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "94f88df23a25417badc922ab0f5716cc1330e87f71ddd9203b3a3ccd9cedf75d" +"checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" +"checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" "checksum hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" "checksum libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)" = "48450664a984b25d5b479554c29cc04e3150c97aa4c01da5604a2d4ed9151476" +"checksum proc-macro2 0.4.25 (registry+https://github.com/rust-lang/crates.io-index)" = "d3797b7142c9aa74954e351fc089bbee7958cebbff6bf2815e7ffff0b19f547d" +"checksum quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "53fa22a1994bd0f9372d7a816207d8a2677ad0325b073f5c5332760f0fb62b5c" "checksum redox_syscall 0.1.50 (registry+https://github.com/rust-lang/crates.io-index)" = "52ee9a534dc1301776eff45b4fa92d2c39b1d8c3d3357e6eb593e0d795506fc2" +"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" +"checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" +"checksum structopt 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "670ad348dc73012fcf78c71f06f9d942232cdd4c859d4b6975e27836c3efc0c3" +"checksum structopt-derive 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "ef98172b1a00b0bec738508d3726540edcbd186d50dfd326f2b1febbb3559f04" +"checksum syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)" = "f92e629aa1d9c827b2bb8297046c1ccffc57c99b947a680d3ccff1f136a3bee9" +"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" +"checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6" "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" +"checksum unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aa6024fc12ddfd1c6dbc14a80fa2324d4568849869b779f6bd37e5e4c03344d1" +"checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526" +"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" +"checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" "checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/wg-event-gen/Cargo.toml b/wg-event-gen/Cargo.toml index 9236edc..2987d09 100644 --- a/wg-event-gen/Cargo.toml +++ b/wg-event-gen/Cargo.toml @@ -8,6 +8,8 @@ edition = "2018" hex = "0.3.2" base64 = "0.10.0" time = "0.1.42" +structopt = "0.2.14" +structopt-derive = "0.2.14" [profile.release] lto = false diff --git a/wg-event-gen/src/main.rs b/wg-event-gen/src/main.rs index 14dc657..3c9bb45 100644 --- a/wg-event-gen/src/main.rs +++ b/wg-event-gen/src/main.rs @@ -1,11 +1,16 @@ +#[macro_use] +extern crate structopt; + mod gen; mod listener; +mod opts; use crate::gen::*; use crate::listener::*; use base64; use hex; +use opts::Opts; use std::collections::HashMap; use std::env; use std::fmt; @@ -16,6 +21,8 @@ use std::os::unix::net::UnixStream; use std::path::PathBuf; use std::thread; use std::time::Duration; +use structopt::StructOpt; + use time; pub type KV = (String, String); @@ -239,58 +246,33 @@ impl Socket { } fn main() { - let mut args = env::args(); - args.next(); //Ignore program name - let path = args - .next() - .map(PathBuf::from) - .filter(|p| p.as_path().exists()); - let interval = Duration::from_millis( - args.next() - .map(|i| { - i.parse::() - .expect("[interval] has to be a positive int") - }) - .unwrap_or(1000), - ); + let opts = Opts::from_args(); + + let timeout = Duration::from_secs(opts.timeout); + let interval = Duration::from_secs(opts.poll); + let events = opts.events; + let path = opts.socket; + let mut listeners: Vec> = vec![Box::new(LogListener)]; - let events: PathBuf = "/etc/wireguard/events.sh".into(); - - if events.exists() { + if let Some(events) = events { listeners.push(Box::new(ScriptListener::new(events))) } - let timeout = env::vars() - .collect::>() - .get("WG_EVENT_GEN_TIMEOUT") - .map(|timeout| { - Duration::from_secs( - timeout - .parse::() - .expect(&format!("Can't parse {} as timeout", timeout)), - ) - }) - .unwrap_or(Duration::from_secs(30)); - - if let Some(path) = path { - let sock = Socket { path }; - let mut prev_state: Option> = None; - loop { - let state = match sock.get_peers() { - Ok(state) => state, - Err(err) => { - eprintln!("Failed to read from socket: {}", err); - continue; - } - }; - if let Some(prev_state) = prev_state { - gen::gen_events(&state, &prev_state, &listeners, timeout, interval); + let sock = Socket { path }; + let mut prev_state: Option> = None; + loop { + let state = match sock.get_peers() { + Ok(state) => state, + Err(err) => { + eprintln!("Failed to read from socket: {}", err); + continue; } - prev_state = Some(state); - thread::sleep(interval); + }; + if let Some(prev_state) = prev_state { + gen::gen_events(&state, &prev_state, &listeners, timeout, interval); } - } else { - println!(" does not exist"); + prev_state = Some(state); + thread::sleep(interval); } } diff --git a/wg-event-gen/src/opts.rs b/wg-event-gen/src/opts.rs new file mode 100644 index 0000000..2997be2 --- /dev/null +++ b/wg-event-gen/src/opts.rs @@ -0,0 +1,18 @@ +use std::path::PathBuf; +use structopt::StructOpt; + +#[derive(StructOpt, Debug)] +#[structopt(name = "event-gen")] +pub struct Opts { + #[structopt(short = "t", long = "timeout", default_value = "120", env = "WG_EVENT_TIMEOUT")] + pub timeout: u64, + + #[structopt(short = "p", long = "poll-interval", default_value = "3000", env = "WG_EVENT_INTERVAL")] + pub poll: u64, + + #[structopt(short = "e", long = "event-handler", parse(from_os_str), env = "WG_EVENT_HANDLER")] + pub events: Option, + + #[structopt(name = "SOCKET", parse(from_os_str), env = "WG_EVENT_SOCKET")] + pub socket: PathBuf, +} From fa84103e8aa12d97688bd728a44cb8bb10738139 Mon Sep 17 00:00:00 2001 From: shimunn <> Date: Sat, 19 Jan 2019 22:47:23 +0100 Subject: [PATCH 2/6] added feature to Cargo.toml --- wg-event-gen/Cargo.toml | 6 +++++- wg-event-gen/src/gen.rs | 14 +++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/wg-event-gen/Cargo.toml b/wg-event-gen/Cargo.toml index 2987d09..4131970 100644 --- a/wg-event-gen/Cargo.toml +++ b/wg-event-gen/Cargo.toml @@ -12,4 +12,8 @@ structopt = "0.2.14" structopt-derive = "0.2.14" [profile.release] -lto = false +lto = true + +[features] + +addrem = [] diff --git a/wg-event-gen/src/gen.rs b/wg-event-gen/src/gen.rs index 7b0a9d4..7103278 100644 --- a/wg-event-gen/src/gen.rs +++ b/wg-event-gen/src/gen.rs @@ -25,7 +25,7 @@ pub(crate) fn gen_events( .chain(prev.keys().map(String::as_ref)) .collect::>() .iter() - .map(|p| (p.to_owned(), (prev.get(*p), state.get(*p)))) + .map(|p| (*p, (prev.get(*p), state.get(*p)))) .collect::, Option<&Peer>)>>() }; for (_id, (prev, cur)) in side_by_side { @@ -37,6 +37,12 @@ pub(crate) fn gen_events( _ => true, }; + if let (Some(prev_addr), Some(cur_addr)) = (prev.endpoint, cur.endpoint) { + if prev_addr != cur_addr { + listeners.roaming(&cur, prev_addr); + } + } + if !timedout(&prev) && timedout(&cur) { listeners.disconnected(&cur); continue; @@ -45,12 +51,6 @@ pub(crate) fn gen_events( if timedout(&prev) && !timedout(&cur) { listeners.connected(&cur); } - - if prev.endpoint != cur.endpoint { - if let (Some(prev_addr), Some(_)) = (prev.endpoint, cur.endpoint) { - listeners.roaming(&cur, prev_addr); - } - } } (None, Some(cur)) => listeners.added(&cur), (Some(prev), None) => listeners.removed(&prev), From 678987fbbd6069af2b50b884d2300b9c78390629 Mon Sep 17 00:00:00 2001 From: shimunn <> Date: Sat, 19 Jan 2019 23:03:21 +0100 Subject: [PATCH 3/6] updated .service [CI SKIP] --- wireguard-user.service | 3 +++ 1 file changed, 3 insertions(+) diff --git a/wireguard-user.service b/wireguard-user.service index 1e7b99e..793d9c7 100644 --- a/wireguard-user.service +++ b/wireguard-user.service @@ -30,6 +30,9 @@ ExecStartPre=/bin/mkdir -p $ROOT_DIR ExecStart=/usr/bin/rkt --insecure-options=image run --uuid-file-save=${ROOT_DIR}/container.uuid --inherit-env --dns 8.8.8.8 --dns 9.9.9.9 --dns 1.1.1.1 \ --volume dev-net,kind=host,source=/dev/net/tun --volume volume-etc-wireguard,kind=host,source=${ROOT_DIR},readOnly=false \ --port 51820-udp:51820 repo.shimun.net/shimun/wireguard-user --mount volume=dev-net,target=/dev/net/tun --caps-retain=${WG_CAPS} + +ExecStop=-/usr/bin/rkt enter --app=wireguard-user $(cat ${ROOT_DIR}/container.uuid) /bin/wg-save +TimeoutStopSec=5 ExecStopPost=-/usr/bin/rkt rm --uuid-file=${ROOT_DIR}/container.uuid KillMode=mixed From 34a081c6d6df2fee1c577655ead53d9afa2bf855 Mon Sep 17 00:00:00 2001 From: shimunn <> Date: Sat, 19 Jan 2019 23:04:06 +0100 Subject: [PATCH 4/6] basic handler [CI SKIP] --- handler.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 handler.sh diff --git a/handler.sh b/handler.sh new file mode 100644 index 0000000..82ab0ed --- /dev/null +++ b/handler.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +#{event} {id} {allowed_ips} {endpoint} {last_handshake} {persistent_keepalive} {traffic} +EVENT=$1 +PUB_KEY=$2 +IFS=',' read -ra ALLOWED_IPS <<< "$3" +ENDPOINT=$4 +LAST_HSHAKE=$5 +KEEPALIVE=$6 +IFS=',' read -ra TRAFFIC <<< "$7" +TX_BYTES=${TRAFFIC[0]} +RX_BYTES=${TRAFFIC[1]} + +echo "Caught event $EVENT for $PUB_KEY with IP $ALLOWED_IPS last shaked: $LAST_HSHAKE" > /tmp/log + +case "$EVENT" in +"connected") + +;; +"disconnected") + +;; +"roaming") + PREV_ENDPOINT=$8 +;; +"added") +;; +"removed") + +;; +*) +exit 1 +;; +esac From 7cf669e6194ccd37a1030e0c827a00d2f2481a55 Mon Sep 17 00:00:00 2001 From: shimunn <> Date: Fri, 25 Jan 2019 23:11:30 +0100 Subject: [PATCH 5/6] cargo-fmt --- wg-event-gen/src/listener.rs | 2 +- wg-event-gen/src/opts.rs | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/wg-event-gen/src/listener.rs b/wg-event-gen/src/listener.rs index 8658201..6faa331 100644 --- a/wg-event-gen/src/listener.rs +++ b/wg-event-gen/src/listener.rs @@ -84,7 +84,7 @@ impl ScriptListener { ScriptListener { script } } - fn peer_props<'a>(&self,peer: &'a Peer) -> String { + fn peer_props<'a>(&self, peer: &'a Peer) -> String { format!( "{id} {allowed_ips} {endpoint} {last_handshake} {persistent_keepalive} {traffic}", id = peer.public_key, diff --git a/wg-event-gen/src/opts.rs b/wg-event-gen/src/opts.rs index 2997be2..5c34170 100644 --- a/wg-event-gen/src/opts.rs +++ b/wg-event-gen/src/opts.rs @@ -4,13 +4,28 @@ use structopt::StructOpt; #[derive(StructOpt, Debug)] #[structopt(name = "event-gen")] pub struct Opts { - #[structopt(short = "t", long = "timeout", default_value = "120", env = "WG_EVENT_TIMEOUT")] + #[structopt( + short = "t", + long = "timeout", + default_value = "120", + env = "WG_EVENT_TIMEOUT" + )] pub timeout: u64, - #[structopt(short = "p", long = "poll-interval", default_value = "3000", env = "WG_EVENT_INTERVAL")] + #[structopt( + short = "p", + long = "poll-interval", + default_value = "3000", + env = "WG_EVENT_INTERVAL" + )] pub poll: u64, - #[structopt(short = "e", long = "event-handler", parse(from_os_str), env = "WG_EVENT_HANDLER")] + #[structopt( + short = "e", + long = "event-handler", + parse(from_os_str), + env = "WG_EVENT_HANDLER" + )] pub events: Option, #[structopt(name = "SOCKET", parse(from_os_str), env = "WG_EVENT_SOCKET")] From 0e7ff7293b1bfb459b7c8e62055f51748087d354 Mon Sep 17 00:00:00 2001 From: shimunn <> Date: Fri, 25 Jan 2019 23:11:58 +0100 Subject: [PATCH 6/6] addrem feature --- wg-event-gen/Cargo.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wg-event-gen/Cargo.toml b/wg-event-gen/Cargo.toml index 4131970..57918aa 100644 --- a/wg-event-gen/Cargo.toml +++ b/wg-event-gen/Cargo.toml @@ -16,4 +16,6 @@ lto = true [features] +default = ["addrem"] + addrem = []