Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
## 5.5.1
## 5.6.0
* Releasing JRE Docker Image Version
* Enabling DPS to run on any JRE 21+
* Fixing IPV6 query answers which could fail in some cases by UDP interface issues
* UDP Server: Stopped trying to bind to link local interfaces
* Defining `0.0.0.0` as the default host for DNS server
* Option to customize the DNS host, see the [docs][5521]

[5521]: https://mageddo.github.io/dns-proxy-server/5.5/en/3-configuration/#server

## 5.3.0
* Docker Solver: Specify Preferred Networks to use when solving container IP #662
Expand Down
50 changes: 26 additions & 24 deletions docs/content/3-configuration/_index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@ Current Version: `3`. See [how to set the configurations][5].

### Server

| Name | Description | Default Value |
|-------------------|-----------------------------------|---------------|
| `server.protocol` | Protocol to start the DNS server. | `UDP_TCP` |
| Name | Description | Default Value |
|---------------|-------------------------|---------------|
| `server.host` | Host to bind the ports. | `0.0.0.0` |

---

### DNS Server

| Name | Description | Default Value |
|------------------------------------|--------------------------------------------------------------------|---------------|
| `server.dns.protocol` | Protocol to start the DNS server. | `UDP_TCP` |
| `server.dns.port` | Port where the DNS server listens. | `53` |
| `server.dns.noEntriesResponseCode` | Response code returned when no entries are resolved by any solver. | `3` |

Expand Down Expand Up @@ -48,23 +49,23 @@ Common DNS resolution mechanisms used by DPS. Solvers are evaluated according to

### Docker Solver

| Name | Description | Default Value |
|----------------------------------------------------|-----------------------------------------------------------------------------------------|-----------------|
| `solver.docker.registerContainerNames` | Whether container or service names should be registered as DNS hostnames. | `false` |
| `solver.docker.domain` | Domain suffix used when registering Docker containers and services. | `docker` |
| `solver.docker.hostMachineFallback` | Whether the host machine IP should be returned when a container is found but has no IP. | `true` |
| `solver.docker.dockerDaemonUri` | Docker daemon URI used to connect to Docker. | OS dependent |
| Name | Description | Default Value |
|----------------------------------------|-----------------------------------------------------------------------------------------|---------------|
| `solver.docker.registerContainerNames` | Whether container or service names should be registered as DNS hostnames. | `false` |
| `solver.docker.domain` | Domain suffix used when registering Docker containers and services. | `docker` |
| `solver.docker.hostMachineFallback` | Whether the host machine IP should be returned when a container is found but has no IP. | `true` |
| `solver.docker.dockerDaemonUri` | Docker daemon URI used to connect to Docker. | OS dependent |

#### DPS Network
| Name | Description | Default Value |
|----------------------------------------------------|-----------------------------------------------------------------------------------------|-----------------|
| `solver.docker.dpsNetwork.autoCreate` | Whether DPS should automatically create a Docker bridge network. | `false` |
| `solver.docker.dpsNetwork.autoConnect` | Whether all containers should be auto-connected to the DPS network. | `false` |
| `solver.docker.dpsNetwork.configs` | Docker network IP configuration | |
| `solver.docker.dpsNetwork.configs[].subNet` | Subnet | `172.20.0.0/16` |
| `solver.docker.dpsNetwork.configs[].ipRange` | Ip Range | `172.20.5.0/24` |
| `solver.docker.dpsNetwork.configs[].gateway` | Gateway | `172.20.5.1` |

| Name | Description | Default Value |
|----------------------------------------------|---------------------------------------------------------------------|-----------------|
| `solver.docker.dpsNetwork.autoCreate` | Whether DPS should automatically create a Docker bridge network. | `false` |
| `solver.docker.dpsNetwork.autoConnect` | Whether all containers should be auto-connected to the DPS network. | `false` |
| `solver.docker.dpsNetwork.configs` | Docker network IP configuration | |
| `solver.docker.dpsNetwork.configs[].subNet` | Subnet | `172.20.0.0/16` |
| `solver.docker.dpsNetwork.configs[].ipRange` | Ip Range | `172.20.5.0/24` |
| `solver.docker.dpsNetwork.configs[].gateway` | Gateway | `172.20.5.1` |

Default DPS network settings

Expand All @@ -77,14 +78,14 @@ Default DPS network settings
gateway: fc00:5c6f:db50::1
```

#### Network Priority when Solving Container IP
| Name | Description | Default Value |
|----------------------------------------------------|-----------------------------------------------------------------------------------------|-----------------|
| `solver.docker.networks.preferred.names` | Which networks DPS must prioritize when discovering container IP | |
| `solver.docker.networks.preferred.overrideDefault` | If will disable DPS and BRIDGE default networks when solving | false |
#### Network Priority when Solving Container IP

See more on [specify from which network solve container][6].
| Name | Description | Default Value |
|----------------------------------------------------|------------------------------------------------------------------|---------------|
| `solver.docker.networks.preferred.names` | Which networks DPS must prioritize when discovering container IP | |
| `solver.docker.networks.preferred.overrideDefault` | If will disable DPS and BRIDGE default networks when solving | false |

See more on [specify from which network solve container][6].

### System Solver

Expand Down Expand Up @@ -134,12 +135,13 @@ See more on [specify from which network solve container][6].
```yaml
version: 3
server:
host: "0.0.0.0"
dns:
port: 53
noEntriesResponseCode: 3
protocol: UDP_TCP
web:
port: 5380
protocol: UDP_TCP
solver:
remote:
active: true
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=5.5.1-snapshot
version=5.6.0-snapshot
38 changes: 25 additions & 13 deletions src/main/java/com/mageddo/dnsproxyserver/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import java.util.stream.Stream;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.mageddo.dnsserver.SimpleServer;
import com.mageddo.dnsserver.SimpleServer.Protocol;
import com.mageddo.net.IP;
import com.mageddo.net.IpAddr;

Expand Down Expand Up @@ -162,17 +162,19 @@ public String getHostMachineHostname() {
}

public Integer getNoEntriesResponseCode() {
if (this.server == null) {
if (this.getDnsServer() == null) {
return null;
}
return this.server.getDnsServerNoEntriesResponseCode();
return this.getDnsServer()
.getNoEntriesResponseCode();
}

public Integer getDnsServerPort() {
if (this.server == null) {
if (this.getDnsServer() == null) {
return null;
}
return this.server.getDnsServerPort();
return this.getDnsServer()
.getPort();
}

public Integer getWebServerPort() {
Expand All @@ -182,11 +184,11 @@ public Integer getWebServerPort() {
return this.server.getWebServerPort();
}

public SimpleServer.Protocol getServerProtocol() {
public Protocol getServerProtocol() {
if (this.server == null) {
return null;
}
return this.server.getServerProtocol();
return this.server.dns.protocol;
}

@JsonIgnore
Expand Down Expand Up @@ -227,6 +229,13 @@ public SolverDocker.Networks getDockerSolverNetworks() {
return this.solverDocker.networks;
}

public Server.Dns getDnsServer() {
if (this.server == null) {
return null;
}
return this.server.dns;
}

@Value
@Builder(toBuilder = true)
public static class DefaultDns {
Expand Down Expand Up @@ -470,14 +479,17 @@ public ch.qos.logback.classic.Level toLogbackLevel() {
@Value
@Builder
public static class Server {

String host;
Dns dns;
Integer webServerPort;

Integer dnsServerPort;
Integer dnsServerNoEntriesResponseCode;

SimpleServer.Protocol serverProtocol;

@Value
@Builder
public static class Dns {
Protocol protocol;
Integer port;
Integer noEntriesResponseCode;
}
}

@Value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ public static Config toConfig(ConfigFlag config) {
return Config.builder()
.server(Config.Server
.builder()
.dnsServerNoEntriesResponseCode(config.getNoEntriesResponseCode())
.dns(Config.Server.Dns.builder()
.port(config.getDnsServerPort())
.noEntriesResponseCode(config.getNoEntriesResponseCode())
.build()
)
.webServerPort(config.getWebServerPort())
.dnsServerPort(config.getDnsServerPort())
.build()
)
.configPath(Files.pathOf(config.getConfigFilePath()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@ public static Config toConfig(ConfigJson json, Path configFileAbsolutePath) {
return Config.builder()
.server(Config.Server
.builder()
.dnsServerNoEntriesResponseCode(json.getNoEntriesResponseCode())
.dns(Config.Server.Dns.builder()
.protocol(json.getServerProtocol())
.port(json.getDnsServerPort())
.noEntriesResponseCode(json.getNoEntriesResponseCode())
.build()
)
.webServerPort(json.getWebServerPort())
.dnsServerPort(json.getDnsServerPort())
.serverProtocol(json.getServerProtocol())
.build()
)
.defaultDns(Config.DefaultDns
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ public static Config toConfig(ConfigEnv config) {
return Config.builder()
.server(Config.Server
.builder()
.dnsServerNoEntriesResponseCode(config.getNoEntriesResponseCode())
.dns(Config.Server.Dns.builder()
.noEntriesResponseCode(config.getNoEntriesResponseCode())
.build()
)
.build()
)
.log(Config.Log
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ static public class DefaultDns {
static public class Dns {
Integer port;
Integer noEntriesResponseCode;
String protocol;
}

@Data
Expand Down Expand Up @@ -188,9 +189,9 @@ static public class ResolvConf {
@Accessors(chain = true)
@FieldDefaults(level = AccessLevel.PRIVATE)
static public class Server {
String host;
Dns dns;
Web web;
String protocol;
}

@Data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import com.mageddo.net.IP;
import com.mageddo.net.IpAddr;

import org.apache.commons.lang3.EnumUtils;

import static java.util.Collections.emptyList;
import static java.util.stream.Collectors.toList;

Expand Down Expand Up @@ -65,20 +67,24 @@ private static Config.Server mapServer(final ConfigV3.Server s) {
return null;
}

final var web = s.getWeb();
return Config.Server.builder()
.dnsServerPort(s.getDns() != null ? s.getDns()
.getPort() : null)
.dnsServerNoEntriesResponseCode(
s.getDns() != null ? s.getDns()
.getNoEntriesResponseCode() : null
)
.webServerPort(s.getWeb() != null ? s.getWeb()
.getPort() : null)
.serverProtocol(
s.getProtocol() != null
? SimpleServer.Protocol.valueOf(s.getProtocol())
: null
)
.host(s.getHost())
.dns(mapDnsServer(s))
.webServerPort(web != null ? web.getPort() : null)
.build();
}

private static Config.Server.Dns mapDnsServer(ConfigV3.Server server) {
final var dns = server.getDns();
if(dns == null) {
return null;
}
return Config.Server.Dns
.builder()
.protocol(EnumUtils.getEnum(SimpleServer.Protocol.class, dns.getProtocol()))
.port(dns.getPort())
.noEntriesResponseCode(dns.getNoEntriesResponseCode())
.build();
}

Expand All @@ -87,15 +93,17 @@ private static ConfigV3.Server mapServerV3(final Config config) {
return null;
}

final var server = config.getServer();
return new ConfigV3.Server()
.setHost(server.getHost())
.setDns(new ConfigV3.Dns()
.setProtocol(Objects.toString(config.getServerProtocol(), null))
.setPort(config.getDnsServerPort())
.setNoEntriesResponseCode(config.getNoEntriesResponseCode())
)
.setWeb(new ConfigV3.Web()
.setPort(config.getWebServerPort())
)
.setProtocol(Objects.toString(config.getServerProtocol(), null));
);
}

/* ================= DEFAULT DNS ================= */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
import com.mageddo.dnsproxyserver.config.Config;
import com.mageddo.dnsproxyserver.config.Config.DefaultDns;
import com.mageddo.dnsproxyserver.config.Config.Env;
import com.mageddo.dnsproxyserver.config.Config.Server;
import com.mageddo.dnsproxyserver.config.Config.SolverDocker;
import com.mageddo.dnsproxyserver.config.StaticThresholdCircuitBreakerStrategyConfig;
import com.mageddo.dnsproxyserver.config.validator.ConfigValidator;
import com.mageddo.dnsproxyserver.solver.docker.Network;
import com.mageddo.dnsproxyserver.utils.Numbers;
import com.mageddo.dnsproxyserver.version.VersionDAO;
import com.mageddo.dnsserver.SimpleServer;
import com.mageddo.dnsserver.SimpleServer.Protocol;
import com.mageddo.net.IP;
import com.mageddo.net.IpAddr;

Expand Down Expand Up @@ -144,14 +145,31 @@ public Config mapFrom(List<Config> configs) {
private Config mapFrom0(List<Config> configs) {

final var config = Config.builder()
.server(Config.Server
.server(Server
.builder()
.host(ValueResolver.findFirstOrThrow(
configs,
Config::getServer,
Server::getHost
))
.webServerPort(Numbers.firstPositive(mapField(Config::getWebServerPort, configs)))
.dnsServerPort(Numbers.firstPositive(mapField(Config::getDnsServerPort, configs)))
.serverProtocol(firstNonNullRequiring(mapField(
Config::getServerProtocol, configs)))
.dnsServerNoEntriesResponseCode(
firstNonNullRequiring(mapField(Config::getNoEntriesResponseCode, configs))
.dns(Server.Dns.builder()
.protocol(ValueResolver.findFirstOrThrow(
configs,
Config::getDnsServer,
Server.Dns::getProtocol
))
.port(ValueResolver.findFirstOrThrow(
configs,
Config::getDnsServer,
Server.Dns::getPort
))
.noEntriesResponseCode(ValueResolver.findFirstOrThrow(
configs,
Config::getDnsServer,
Server.Dns::getNoEntriesResponseCode
))
.build()
)
.build()
)
Expand Down Expand Up @@ -258,9 +276,15 @@ private Config mapFrom0(List<Config> configs) {
static Config buildDefault() {
return Config
.builder()
.server(Config.Server
.builder()
.serverProtocol(SimpleServer.Protocol.UDP_TCP)
.server(Server.builder()
.host("0.0.0.0")
.dns(Server.Dns.builder()
.protocol(Protocol.UDP_TCP)
.port(53)
.noEntriesResponseCode(3)
.build()
)
.webServerPort(5380)
.build()
)
.defaultDns(DefaultDns.builder()
Expand Down
Loading