provide ip gateway

This commit is contained in:
Peter Hormanns 2023-03-06 12:04:52 +01:00
parent ced1f7a00a
commit c5fc07024c
2 changed files with 17 additions and 2 deletions

View File

@ -73,10 +73,18 @@ public class INetAddress extends AbstractEntity implements Serializable {
return name; return name;
} }
public String getInet4Gateway() throws HSAdminException {
return IPv6Trick.IPv4Gateway(name);
}
public String getInet6Addr() throws HSAdminException { public String getInet6Addr() throws HSAdminException {
return IPv6Trick.convertIPv4ToIPv6(name); return IPv6Trick.convertIPv4ToIPv6(name);
} }
public String getInet6Gateway() throws HSAdminException {
return IPv6Trick.IPv6Gateway(name);
}
public void setInetAddr(String inetAddr) { public void setInetAddr(String inetAddr) {
this.name = inetAddr; this.name = inetAddr;
} }

View File

@ -76,9 +76,16 @@ public class JsonPillarServlet extends HttpServlet {
final PrintWriter writer = resp.getWriter(); final PrintWriter writer = resp.getWriter();
writer.println("{"); writer.println("{");
writer.println(" \"hivename\": \"" + hive.getHiveName() + "\""); writer.println(" \"hivename\": \"" + hive.getHiveName() + "\"");
writer.println(" , \"hiveipv4\": \"" + hive.getInetAddr().getInet4Addr() + "\""); final INetAddress inetAddr = hive.getInetAddr();
writer.println(" , \"hiveipv4\": \"" + inetAddr.getInet4Addr() + "\"");
try { try {
writer.println(" , \"hiveipv6\": \"" + hive.getInetAddr().getInet6Addr() + "\""); writer.println(" , \"hiveipv4gateway\": \"" + inetAddr.getInet4Gateway() + "\"");
} catch (HSAdminException e) {
// dont care
}
try {
writer.println(" , \"hiveipv6\": \"" + inetAddr.getInet6Addr() + "\"");
writer.println(" , \"hiveipv6gateway\": \"" + inetAddr.getInet6Gateway() + "\"");
} catch (HSAdminException e) { } catch (HSAdminException e) {
// dont care // dont care
} }