MindFlavor / prometheus_wireguard_exporter

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

Friendly names are not matched if PublicKey contains comment #52

Closed arisudesu closed 3 years ago

arisudesu commented 3 years ago

As says the title, friendly names are not matched with public keys, if the public key line contains comment.

My wireguard config looks like this:

[Interface]
Address    = ...
ListenPort = ...
PrivateKey = ...

[Peer]
# friendly_name = mobile
PublicKey  = my-mobile-public-key  # my-private-key-in-comment
AllowedIPs = ...

[Peer]
# friendly_name = home
PublicKey  = my-home-public-key  # my-private-key-in-comment
AllowedIPs = ...

With this config, no friendly names are exported, although this is valid wireguard conf file.

If I modify peer config like this:

[Peer]
# friendly_name = home
PublicKey  = my-home-public-key
AllowedIPs = ...

Then friendly names work.

MindFlavor commented 3 years ago

mmm this is weird and most likely a bug. Thank you for reporting, the repro is quite clear 👍 !

qdm12 commented 3 years ago

Then friendly names work.

What client are you using on that peer?

I don't know/think friendly names are part of the wireguard original program.

MindFlavor commented 3 years ago

Yes it was a bug indeed. This is what happens when you roll your custom parser 🤷‍♂️.

The above PR should fix this: can you try it and get back to me please?

Update: sorry autoclosed by GitHub 🙄 .

arisudesu commented 3 years ago

A quick check shows that this is now working correctly. Thanks!

@qdm12 It is a feature of this exporter.