diff options
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | flake.lock | 108 | ||||
-rw-r--r-- | src/main.rs | 6 |
3 files changed, 116 insertions, 0 deletions
@@ -1 +1,3 @@ /target +result +result-bin diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..4b5713d --- /dev/null +++ b/flake.lock @@ -0,0 +1,108 @@ +{ + "nodes": { + "cargo2nix": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ], + "rust-overlay": "rust-overlay" + }, + "locked": { + "lastModified": 1666087781, + "narHash": "sha256-trKVdjMZ8mNkGfLcY5LsJJGtdV3xJDZnMVrkFjErlcs=", + "owner": "Alexis211", + "repo": "cargo2nix", + "rev": "a7a61179b66054904ef6a195d8da736eaaa06c36", + "type": "github" + }, + "original": { + "owner": "Alexis211", + "repo": "cargo2nix", + "rev": "a7a61179b66054904ef6a195d8da736eaaa06c36", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1650374568, + "narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "b4a34015c698c7793d592d66adbab377907a2be8", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1665657542, + "narHash": "sha256-mojxNyzbvmp8NtVtxqiHGhRfjCALLfk9i/Uup68Y5q8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "a3073c49bc0163fea6a121c276f526837672b555", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "a3073c49bc0163fea6a121c276f526837672b555", + "type": "github" + } + }, + "root": { + "inputs": { + "cargo2nix": "cargo2nix", + "nixpkgs": "nixpkgs" + } + }, + "rust-overlay": { + "inputs": { + "flake-utils": [ + "cargo2nix", + "flake-utils" + ], + "nixpkgs": [ + "cargo2nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1664247556, + "narHash": "sha256-J4vazHU3609ekn7dr+3wfqPo5WGlZVAgV7jfux352L0=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "524db9c9ea7bc7743bb74cdd45b6d46ea3fcc2ab", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/src/main.rs b/src/main.rs index 7e0f013..be73856 100644 --- a/src/main.rs +++ b/src/main.rs @@ -90,6 +90,12 @@ fn wg_dump(config: &Config) -> Result<(Pubkey, u16, Vec<(Pubkey, Option<SocketAd let mut lines = std::str::from_utf8(&output.stdout)?.split('\n'); let ourself = lines.next().unwrap().split('\t').collect::<Vec<_>>(); + if ourself.len() < 3 { + bail!( + "Unable to fetch wireguard status for interface {}", + config.interface + ); + } let our_pubkey = ourself[1].to_string(); let listen_port = ourself[2].parse::<u16>()?; |