support for ipv6 addr in command line

This commit is contained in:
Francesco Cogno 2020-03-24 09:36:13 +01:00
parent 8f0f5112ec
commit ff5806571b
3 changed files with 275 additions and 513 deletions

778
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
[package]
name = "prometheus_wireguard_exporter"
version = "3.2.2"
version = "3.2.3"
authors = ["Francesco Cogno <francesco.cogno@outlook.com>"]
description = "Prometheus WireGuard Exporter"
edition = "2018"

View File

@ -18,7 +18,7 @@ mod wireguard_config;
use wireguard_config::peer_entry_hashmap_try_from;
extern crate prometheus_exporter_base;
use prometheus_exporter_base::render_prometheus;
use std::net::Ipv4Addr;
use std::net::IpAddr;
use std::sync::Arc;
fn wg_with_text(
@ -156,11 +156,7 @@ async fn main() {
let bind = matches.value_of("port").unwrap();
let bind = u16::from_str_radix(&bind, 10).expect("port must be a valid number");
let ip = matches
.value_of("addr")
.unwrap()
.parse::<Ipv4Addr>()
.unwrap();
let ip = matches.value_of("addr").unwrap().parse::<IpAddr>().unwrap();
let addr = (ip, bind).into();
info!("starting exporter on http://{}/metrics", addr);