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] [package]
name = "prometheus_wireguard_exporter" name = "prometheus_wireguard_exporter"
version = "3.2.2" version = "3.2.3"
authors = ["Francesco Cogno <francesco.cogno@outlook.com>"] authors = ["Francesco Cogno <francesco.cogno@outlook.com>"]
description = "Prometheus WireGuard Exporter" description = "Prometheus WireGuard Exporter"
edition = "2018" edition = "2018"

View file

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