From c308720e84e1ab8601b2f75f3f0bcb4afe5f5d83 Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Fri, 29 Jul 2022 11:57:31 +0200 Subject: [PATCH] setup a network interface only if the pac has its own IP address --- hsarback/src/de/hsadmin/mods/pac/Hive.java | 10 ++++++++++ hsarback/src/de/hsadmin/mods/pac/Pac.java | 6 ++++++ hsarback/src/de/hsadmin/mods/pac/hosts.vm | 2 +- hsarback/src/de/hsadmin/mods/pac/httpd-virtual.vm | 2 +- hsarback/src/de/hsadmin/mods/pac/pac-addr-ipv4.vm | 2 +- hsarback/src/de/hsadmin/mods/pac/pac-addr-ipv6.vm | 2 +- 6 files changed, 20 insertions(+), 4 deletions(-) diff --git a/hsarback/src/de/hsadmin/mods/pac/Hive.java b/hsarback/src/de/hsadmin/mods/pac/Hive.java index deaf3a8..c2dc7d7 100644 --- a/hsarback/src/de/hsadmin/mods/pac/Hive.java +++ b/hsarback/src/de/hsadmin/mods/pac/Hive.java @@ -130,6 +130,16 @@ public class Hive extends AbstractEntity implements Serializable { return webpacs; } + public List getPacsWithIPAddress() { + final ArrayList pacsWithIPAddress = new ArrayList(); + for (final Pac pac : pacs) { + if (!pac.isManagedServer() && !pac.usesPacIPAddress()) { + pacsWithIPAddress.add(pac); + } + } + return pacsWithIPAddress; + } + public void setPacs(Set pacs) { this.pacs = pacs; } diff --git a/hsarback/src/de/hsadmin/mods/pac/Pac.java b/hsarback/src/de/hsadmin/mods/pac/Pac.java index f172bee..84d3935 100644 --- a/hsarback/src/de/hsadmin/mods/pac/Pac.java +++ b/hsarback/src/de/hsadmin/mods/pac/Pac.java @@ -294,4 +294,10 @@ public class Pac extends AbstractEntity implements Serializable { String basepacName = getBasepac().getName(); return BasePacType.PAC_SRV.equals(basepacName); } + + public boolean usesPacIPAddress() { + String hiveIP = hive.getInetAddr().getInet4Addr(); + String pacIP = getCurINetAddr().getInet4Addr(); + return pacIP.equals(hiveIP); + } } diff --git a/hsarback/src/de/hsadmin/mods/pac/hosts.vm b/hsarback/src/de/hsadmin/mods/pac/hosts.vm index 14d15d8..9a7d29c 100644 --- a/hsarback/src/de/hsadmin/mods/pac/hosts.vm +++ b/hsarback/src/de/hsadmin/mods/pac/hosts.vm @@ -14,7 +14,7 @@ ff02::3 ip6-allhosts ${hive.inetAddr.inet4Addr} ${hive.name}.hostsharing.net ${hive.name} localhive ${hive.inetAddr.inet6Addr} ${hive.name}.hostsharing.net ${hive.name} localhive -#foreach( $pac in ${hive.webpacs} ) +#foreach( $pac in ${hive.pacsWithIPAddress} ) ${pac.curINetAddr.inet4Addr} ${pac.name}.hostsharing.net ${pac.name} ${pac.curINetAddr.inet6Addr} ${pac.name}.hostsharing.net ${pac.name} #end diff --git a/hsarback/src/de/hsadmin/mods/pac/httpd-virtual.vm b/hsarback/src/de/hsadmin/mods/pac/httpd-virtual.vm index 1460a38..9c9553f 100644 --- a/hsarback/src/de/hsadmin/mods/pac/httpd-virtual.vm +++ b/hsarback/src/de/hsadmin/mods/pac/httpd-virtual.vm @@ -3,7 +3,7 @@ # Do not edit manually. Changes will be overwritten. # -#foreach( $pac in ${hive.webpacs} ) +#foreach( $pac in ${hive.pacsWithIPAddress} ) ServerName _ ServerAdmin webmaster@${pac.name}.hostsharing.net diff --git a/hsarback/src/de/hsadmin/mods/pac/pac-addr-ipv4.vm b/hsarback/src/de/hsadmin/mods/pac/pac-addr-ipv4.vm index cfb3917..7ad3889 100644 --- a/hsarback/src/de/hsadmin/mods/pac/pac-addr-ipv4.vm +++ b/hsarback/src/de/hsadmin/mods/pac/pac-addr-ipv4.vm @@ -3,6 +3,6 @@ # Do not edit manually. Changes will be overwritten. # # -#foreach( $pac in ${hive.webpacs} ) +#foreach( $pac in ${hive.pacsWithIPAddress} ) eth0|${pac.name}|${pac.curINetAddr.inet4Addr}/32 #end \ No newline at end of file diff --git a/hsarback/src/de/hsadmin/mods/pac/pac-addr-ipv6.vm b/hsarback/src/de/hsadmin/mods/pac/pac-addr-ipv6.vm index cf25c95..a85b38c 100644 --- a/hsarback/src/de/hsadmin/mods/pac/pac-addr-ipv6.vm +++ b/hsarback/src/de/hsadmin/mods/pac/pac-addr-ipv6.vm @@ -3,6 +3,6 @@ # Do not edit manually. Changes will be overwritten. # # -#foreach( $pac in ${hive.webpacs} ) +#foreach( $pac in ${hive.pacsWithIPAddress} ) eth0|${pac.name}|${pac.curINetAddr.inet6Addr}/128 #end