diff --git a/README.md b/README.md index bd7a4dee4..ab8c139db 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ or via docker looking at [Dockerhub images][3]. Basic running it on Linux or Mac ```bash -$ curl -s -L https://github.com/mageddo/dns-proxy-server/releases/download/3.7.0/dns-proxy-server-linux-amd64-3.7.0.tgz | tar -vzx &&\ +$ curl -s -L https://github.com/mageddo/dns-proxy-server/releases/download/3.8.0/dns-proxy-server-linux-amd64-3.8.0.tgz | tar -vzx &&\ sudo ./dns-proxy-server ``` diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 311eee093..583a7828a 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -1,5 +1,8 @@ +### 3.8.0 +* Now you're able to activate flags by using `1` or `true` (case insenstive), [see the docs](http://mageddo.github.io/dns-proxy-server/latest/en/3-configuration/#environment-variable-configuration). + ### 3.7.0 -* Support to configure DPS as default DNS Server on MacOS, [see the docs]() +* Support to configure DPS as default DNS Server on MacOS, [see the docs](http://mageddo.github.io/dns-proxy-server/latest/en/1-getting-started/running-it/#running-on-mac) ### 3.6.0 * Configure DPS at system-resolved with a custom port when is necessary diff --git a/docs/content/3-configuration/_index.en.md b/docs/content/3-configuration/_index.en.md index b505f49ec..d86a14775 100755 --- a/docs/content/3-configuration/_index.en.md +++ b/docs/content/3-configuration/_index.en.md @@ -73,9 +73,13 @@ __Version 1__ ### Environment variable configuration +Boolean values +> You can use `1` or `true` (case insensitive) to specify which the flag is activated, any other +value will be considered false. + | VARIBLE | DESCRIPTION | DEFAULT VALUE | |-----------------------------|-----------------------------------------------------------------------|---------------------------------------------------------------------------------------------------| -| MG_RESOLVCONF | Linux resolvconf path to set DPS as default DNS | /host/etc/systemd/resolved.conf,/host/etc/resolv.conf,/etc/systemd/resolved.conf,/etc/resolv.conf | +| MG_RESOLVCONF | Linux resolvconf or systemd-resolved path to set DPS as default DNS | /host/etc/systemd/resolved.conf,/host/etc/resolv.conf,/etc/systemd/resolved.conf,/etc/resolv.conf | | MG_LOG_LEVEL | | INFO | | MG_LOG_FILE | Path where to logs will be stored | console | | MG_REGISTER_CONTAINER_NAMES | if should register container name / service name as a hostname | false | diff --git a/gradle.properties b/gradle.properties index f7824ac23..4bf475339 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -version=3.7.0 +version=3.8.0 quarkusPluginId=io.quarkus quarkusPluginVersion=2.16.0.Final quarkusPlatformGroupId=io.quarkus.platform diff --git a/src/main/java/com/mageddo/dnsproxyserver/utils/Envs.java b/src/main/java/com/mageddo/dnsproxyserver/utils/Envs.java index 7582ede23..b3477251c 100644 --- a/src/main/java/com/mageddo/dnsproxyserver/utils/Envs.java +++ b/src/main/java/com/mageddo/dnsproxyserver/utils/Envs.java @@ -33,10 +33,14 @@ public static String getStringOrNull(String env) { public static Boolean getBooleanOrNull(String env) { final var v = StringUtils.trimToEmpty(System.getenv(env)); + return parseBoolean(v); + } + + static Boolean parseBoolean(String v) { if(StringUtils.isBlank(v)){ return null; } - return Objects.equals(v, "1"); + return Objects.equals(v, "1") || StringUtils.equalsIgnoreCase(v, "true"); } public static String getStringOrDefault(String env, String def) { diff --git a/src/test/java/com/mageddo/dnsproxyserver/utils/EnvsTest.java b/src/test/java/com/mageddo/dnsproxyserver/utils/EnvsTest.java new file mode 100644 index 000000000..49e666e28 --- /dev/null +++ b/src/test/java/com/mageddo/dnsproxyserver/utils/EnvsTest.java @@ -0,0 +1,43 @@ +package com.mageddo.dnsproxyserver.utils; + +import org.junit.jupiter.api.Test; + +import static com.mageddo.dnsproxyserver.utils.Envs.parseBoolean; +import static org.junit.jupiter.api.Assertions.*; + +class EnvsTest { + + @Test + void mustParseAsTrue(){ + // arrange + + // act + // assert + assertTrue(parseBoolean("true")); + assertTrue(parseBoolean("TRUE")); + assertTrue(parseBoolean("TRuE")); + assertTrue(parseBoolean("1")); + } + + @Test + void mustParseAsFalse(){ + // arrange + + // act + // assert + assertFalse(parseBoolean("dps")); + assertFalse(parseBoolean("0")); + assertFalse(parseBoolean("!")); + assertFalse(parseBoolean("FALSE")); + assertFalse(parseBoolean("false")); + } + + @Test + void mustParseAsNull(){ + // arrange + + // act + // assert + assertNull(parseBoolean("")); + } +}