Skip to content

Commit

Permalink
release v3.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
MindFlavor committed Nov 8, 2019
1 parent 90a1585 commit 4612afe
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "prometheus_wireguard_exporter"
version = "3.2.0"
version = "3.2.1"
authors = ["Francesco Cogno <[email protected]>"]
description = "Prometheus WireGuard Exporter"
edition = "2018"
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Prometheus WireGuard Exporter

[![legal](https://img.shields.io/github/license/mindflavor/prometheus_wireguard_exporter.svg)](LICENSE)
[![legal](https://img.shields.io/github/license/mindflavor/prometheus_wireguard_exporter.svg)](LICENSE) ![stability-stable](https://img.shields.io/badge/stability-stable-green.svg)

[![Crate](https://img.shields.io/crates/v/prometheus_wireguard_exporter.svg)](https://crates.io/crates/prometheus_wireguard_exporter) [![cratedown](https://img.shields.io/crates/d/prometheus_wireguard_exporter.svg)](https://crates.io/crates/prometheus_wireguard_exporter) [![cratelastdown](https://img.shields.io/crates/dv/prometheus_wireguard_exporter.svg)](https://crates.io/crates/prometheus_wireguard_exporter)

[![release](https://img.shields.io/github/release/MindFlavor/prometheus_wireguard_exporter.svg)](https://github.com/MindFlavor/prometheus_wireguard_exporter/tree/3.2.0)
[![tag](https://img.shields.io/github/tag/mindflavor/prometheus_wireguard_exporter.svg)](https://github.com/MindFlavor/prometheus_wireguard_exporter/tree/3.2.0)
[![release](https://img.shields.io/github/release/MindFlavor/prometheus_wireguard_exporter.svg)](https://github.com/MindFlavor/prometheus_wireguard_exporter/tree/3.2.1)
[![tag](https://img.shields.io/github/tag/mindflavor/prometheus_wireguard_exporter.svg)](https://github.com/MindFlavor/prometheus_wireguard_exporter/tree/3.2.1)

[![Build Status](https://travis-ci.org/MindFlavor/prometheus_wireguard_exporter.svg?branch=master)](https://travis-ci.org/MindFlavor/prometheus_wireguard_exporter)
[![commitssince](https://img.shields.io/github/commits-since/mindflavor/prometheus_wireguard_exporter/3.2.0.svg)](https://img.shields.io/github/commits-since/mindflavor/prometheus_wireguard_exporter/3.2.0.svg)
[![commitssince](https://img.shields.io/github/commits-since/mindflavor/prometheus_wireguard_exporter/3.2.1.svg)](https://img.shields.io/github/commits-since/mindflavor/prometheus_wireguard_exporter/3.2.1.svg)

## Intro

Expand Down
15 changes: 12 additions & 3 deletions src/wireguard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use crate::exporter_error::ExporterError;
use crate::wireguard_config::PeerEntryHashMap;
use log::{debug, trace};
use prometheus_exporter_base::PrometheusCounter;
use regex::Regex;
use std::collections::HashMap;
use std::convert::TryFrom;
use std::net::SocketAddr;
use regex::Regex;

const EMPTY: &str = "(none)";

Expand Down Expand Up @@ -78,8 +78,17 @@ impl TryFrom<&str> for WireGuard {
let public_key = v[1].to_owned();

let (remote_ip, remote_port) = if let Some(ip_and_port) = to_option_string(v[3]) {
let re = Regex::new(r"^\[(?P<ip>[A-Fa-f0-9:]+)%(.*)\]:(?P<port>[0-9]+)$").unwrap();
let addr: SocketAddr = re.replace_all(&ip_and_port, "[$ip]:$port").parse::<SocketAddr>().unwrap();
// this workaround fixes issue #10 (see
// https://github.com/MindFlavor/prometheus_wireguard_exporter/issues/10).
// Whenever it will be fixed upstream this code will be replaced with a
// simple
// let addr: SocketAddr = ip_and_port.parse::<SocketAddr>().unwrap();
let re =
Regex::new(r"^\[(?P<ip>[A-Fa-f0-9:]+)%(.*)\]:(?P<port>[0-9]+)$").unwrap();
let addr: SocketAddr = re
.replace_all(&ip_and_port, "[$ip]:$port")
.parse::<SocketAddr>()
.unwrap();

(Some(addr.ip().to_string()), Some(addr.port()))
} else {
Expand Down

0 comments on commit 4612afe

Please sign in to comment.