Skip to content

Commit

Permalink
fix(monitor.dns-server): added check for interface as LAN before star…
Browse files Browse the repository at this point in the history
…ting DNS server [Backport] (#4627)

Signed-off-by: MMaiero <matteo.maiero@eurotech.com>
  • Loading branch information
MMaiero committed May 3, 2023
1 parent b360f14 commit 1abe40d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion kura/distrib/config/kura.build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ org.eclipse.kura.linux.gpio.version=1.2.0
org.eclipse.kura.linux.position.version=1.2.0
org.eclipse.kura.linux.usb.version=1.2.0
org.eclipse.kura.linux.watchdog.version=1.2.0
org.eclipse.kura.net.admin.version=1.2.1
org.eclipse.kura.net.admin.version=1.2.2-SNAPSHOT
org.eclipse.kura.util.version=1.3.0
org.eclipse.kura.protocol.can.version=3.2.0
org.eclipse.kura.protocol.modbus.version=2.2.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011, 2022 Eurotech and/or its affiliates and others
* Copyright (c) 2011, 2023 Eurotech and/or its affiliates and others
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -236,9 +236,10 @@ private void updateDnsProxyConfig() {
List<NetInterfaceConfig<? extends NetInterfaceAddressConfig>> netInterfaceConfigs = this.networkConfiguration
.getNetInterfaceConfigs();
for (NetInterfaceConfig<? extends NetInterfaceAddressConfig> netInterfaceConfig : netInterfaceConfigs) {
if (netInterfaceConfig.getType() == NetInterfaceType.ETHERNET
if ((netInterfaceConfig.getType() == NetInterfaceType.ETHERNET
|| netInterfaceConfig.getType() == NetInterfaceType.WIFI
|| netInterfaceConfig.getType() == NetInterfaceType.MODEM) {
|| netInterfaceConfig.getType() == NetInterfaceType.MODEM)
&& isEnabledForLan(netInterfaceConfig)) {
getAllowedNetworks(netInterfaceConfig);
}
}
Expand All @@ -260,6 +261,7 @@ private void getAllowedNetworks(NetInterfaceConfig<? extends NetInterfaceAddress

logger.debug("Getting DNS proxy config for {}", netInterfaceConfig.getName());
List<NetConfig> netConfigs = ((AbstractNetInterface<?>) netInterfaceConfig).getNetConfigs();

for (NetConfig netConfig : netConfigs) {
if (netConfig instanceof DhcpServerConfig && ((DhcpServerConfig) netConfig).isPassDns()) {
logger.debug("Found an allowed network: {}/{}", ((DhcpServerConfig) netConfig).getRouterAddress(),
Expand All @@ -274,6 +276,11 @@ private void getAllowedNetworks(NetInterfaceConfig<? extends NetInterfaceAddress
}
}

private boolean isEnabledForLan(NetInterfaceConfig<? extends NetInterfaceAddressConfig> netInterfaceConfig) {
return ((AbstractNetInterface<?>) netInterfaceConfig).getInterfaceStatus()
.equals(NetInterfaceStatus.netIPv4StatusEnabledLAN);
}

private boolean isEnabledForWan(NetInterfaceConfig<? extends NetInterfaceAddressConfig> netInterfaceConfig) {
return ((AbstractNetInterface<?>) netInterfaceConfig).getInterfaceStatus()
.equals(NetInterfaceStatus.netIPv4StatusEnabledWAN);
Expand Down Expand Up @@ -401,4 +408,4 @@ private static void sleep(int millis) {
}
}

}
}

0 comments on commit 1abe40d

Please sign in to comment.