MindFlavor / prometheus_wireguard_exporter

A Prometheus exporter for WireGuard, written in Rust.
https://mindflavor.github.io/prometheus_wireguard_exporter
MIT License
493 stars 51 forks source link

Exporter fails to listen on IPv6 address #38

Closed telmich closed 4 years ago

telmich commented 4 years ago

Trying to bind it to :: or [::] results in an error message:

[16:00] vpn-2a0ae5c1300:/etc/conf.d# /usr/bin/prometheus_wireguard_exporter -n /etc/wireguard/wg0.conf -l '[::]'
[2020-07-16T14:01:09Z INFO  prometheus_wireguard_exporter] using options: Options { verbose: false, separate_allowed_ips: false, extract_names_config_file: Some("/etc/wireguard/wg0.conf"), export_remote_ip_and_port: false }
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: AddrParseError(())', src/main.rs:180:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[16:01] vpn-2a0ae5c1300:/etc/conf.d# /usr/bin/prometheus_wireguard_exporter -n /etc/wireguard/wg0.conf -l '::'
[2020-07-16T14:01:20Z INFO  prometheus_wireguard_exporter] using options: Options { verbose: false, separate_allowed_ips: false, extract_names_config_file: Some("/etc/wireguard/wg0.conf"), export_remote_ip_and_port: false }
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: AddrParseError(())', src/main.rs:180:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[16:01] vpn-2a0ae5c1300:/etc/conf.d# apk list -I prometheus-wireguard-exporter
prometheus-wireguard-exporter-3.2.1-r2 x86_64 {prometheus-wireguard-exporter} (MIT) [installed]
[16:02] vpn-2a0ae5c1300:/etc/conf.d# 
MindFlavor commented 4 years ago

I am not able to repro the issue:

$ ./target/debug/prometheus_wireguard_exporter -n /etc/wireguard/wg0.conf -l '::'
[2020-07-20T08:36:29Z INFO  prometheus_wireguard_exporter] prometheus_wireguard_exporter v3.3.2 starting...
[2020-07-20T08:36:29Z INFO  prometheus_wireguard_exporter] using options: Options { verbose: false, separate_allowed_ips: false, extract_names_config_file: Some("/etc/wireguard/wg0.conf"), interfaces: None, export_remote_ip_and_port: false }
[2020-07-20T08:36:29Z INFO  prometheus_wireguard_exporter] starting exporter on http://[::]:9586/metrics
[2020-07-20T08:36:29Z INFO  prometheus_exporter_base] Listening on http://[::]:9586

Can you please make sure you are using the latest version (maybe compiling directly from git?). The log should output the version at startup.

Thanks!

telmich commented 4 years ago

I can confirm, this issue is fixed in git.

[10:35] bridge:prometheus_wireguard_exporter% git describe --always 
5e9848d

(build, scp to target machine)

[10:33] vpn-2a0ae5c1300:~# ./prometheus_wireguard_exporter -n /etc/wireguard/wg0.conf -l '::'
[2020-07-21T08:34:06Z INFO  prometheus_wireguard_exporter] prometheus_wireguard_exporter v3.3.2 starting...
[2020-07-21T08:34:06Z INFO  prometheus_wireguard_exporter] using options: Options { verbose: false, separate_allowed_ips: false, extract_names_config_file: Some("/etc/wireguard/wg0.conf"), interfaces: None, export_remote_ip_and_port: false }
[2020-07-21T08:34:06Z INFO  prometheus_wireguard_exporter] starting exporter on http://[::]:9586/metrics
[2020-07-21T08:34:06Z INFO  prometheus_exporter_base] Listening on http://[::]:9586
^C
[10:34] vpn-2a0ae5c1300:~# prometheus_wireguard_exporter  -n /etc/wireguard/wg0.conf -l '::'
[2020-07-21T08:34:18Z INFO  prometheus_wireguard_exporter] using options: Options { verbose: false, separate_allowed_ips: false, extract_names_config_file: Some("/etc/wireguard/wg0.conf"), export_remote_ip_and_port: false }
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: AddrParseError(())', src/main.rs:180:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[10:34] vpn-2a0ae5c1300:~# apk list -I | grep -e wireguard -e export
wireguard-tools-1.0.20200510-r0 x86_64 {wireguard-tools} (GPL-2.0-only) [installed]
wireguard-virt-5.4.43-r1 x86_64 {wireguard-lts} (GPL-2.0) [installed]
wireguard-tools-wg-quick-1.0.20200510-r0 x86_64 {wireguard-tools} (GPL-2.0-only) [installed]
prometheus-wireguard-exporter-openrc-3.2.1-r2 x86_64 {prometheus-wireguard-exporter} (MIT) [installed]
prometheus-wireguard-exporter-3.2.1-r2 x86_64 {prometheus-wireguard-exporter} (MIT) [installed]
wireguard-lts-5.4.43-r1 x86_64 {wireguard-lts} (GPL-2.0) [installed]
wireguard-tools-wg-1.0.20200510-r0 x86_64 {wireguard-tools} (GPL-2.0-only) [installed]
[10:34] vpn-2a0ae5c1300:~# 

I'll try to see if 3.3.2 can easily be added to alpine linux. Thanks a lot for the quick reply!