bemasher / rtlamr

An rtl-sdr receiver for Itron ERT compatible smart meters operating in the 900MHz ISM band.
GNU Affero General Public License v3.0
2.19k stars 249 forks source link

Boolean flags ignore value #193

Closed apaperclip closed 3 years ago

apaperclip commented 3 years ago

I think I may found a bug where a value of false for -unique will trigger the case statement for enabling unique message deduplication.

When using -unique=false I am getting deduped results. This may seem like a silly test since the default is false. I came across this by using the metermon project which sets this to true by default, Overriding the value with the rtlamr_unique env variable to false did not have the desired affect. So I tested rtlamr directly and found that setting the flag to false still dedupes.

I also recreated the issue with the latest bemasher/rtlamr docker hub image.

bemasher commented 3 years ago

You are correct. In go's standard flags package, boolean flags don't need to be specified with a value, so the current logic only checks for existence of the flag. See below.

https://github.com/bemasher/rtlamr/blob/master/main.go#L96-L111

I see where it may be useful to always specify a flag and instead change the value passed when controlling rtlamr with another process. Luckily, the fix is easy, I'll work on it.