corefx removed apache dependency no longer needed, added ipaddress maven dependency for helping generate and deal with node addresses, updated some logic when linking nodes
This commit is contained in:
parent
4f4c4c4f60
commit
56993ec44f
7 changed files with 197 additions and 97 deletions
|
@ -84,11 +84,6 @@
|
||||||
<version>1.18.0</version>
|
<version>1.18.0</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>commons-net</groupId>
|
|
||||||
<artifactId>commons-net</artifactId>
|
|
||||||
<version>3.6</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.jfoenix</groupId>
|
<groupId>com.jfoenix</groupId>
|
||||||
<artifactId>jfoenix</artifactId>
|
<artifactId>jfoenix</artifactId>
|
||||||
|
@ -114,6 +109,11 @@
|
||||||
<artifactId>guava</artifactId>
|
<artifactId>guava</artifactId>
|
||||||
<version>20.0</version>
|
<version>20.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.seancfoley</groupId>
|
||||||
|
<artifactId>ipaddress</artifactId>
|
||||||
|
<version>5.0.2</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -6,6 +6,8 @@ import com.core.client.rest.ServiceFile;
|
||||||
import com.core.client.rest.WlanConfig;
|
import com.core.client.rest.WlanConfig;
|
||||||
import com.core.data.*;
|
import com.core.data.*;
|
||||||
import com.core.ui.dialogs.MobilityPlayerDialog;
|
import com.core.ui.dialogs.MobilityPlayerDialog;
|
||||||
|
import inet.ipaddr.IPAddress;
|
||||||
|
import inet.ipaddr.IPAddressString;
|
||||||
import io.grpc.Context;
|
import io.grpc.Context;
|
||||||
import io.grpc.ManagedChannel;
|
import io.grpc.ManagedChannel;
|
||||||
import io.grpc.ManagedChannelBuilder;
|
import io.grpc.ManagedChannelBuilder;
|
||||||
|
@ -123,6 +125,9 @@ public class CoreGrpcClient implements ICoreClient {
|
||||||
|
|
||||||
private CoreProto.Interface interfaceToProto(CoreInterface coreInterface) {
|
private CoreProto.Interface interfaceToProto(CoreInterface coreInterface) {
|
||||||
CoreProto.Interface.Builder builder = CoreProto.Interface.newBuilder();
|
CoreProto.Interface.Builder builder = CoreProto.Interface.newBuilder();
|
||||||
|
if (coreInterface.getId() != null) {
|
||||||
|
builder.setId(coreInterface.getId());
|
||||||
|
}
|
||||||
if (coreInterface.getName() != null) {
|
if (coreInterface.getName() != null) {
|
||||||
builder.setName(coreInterface.getName());
|
builder.setName(coreInterface.getName());
|
||||||
}
|
}
|
||||||
|
@ -130,16 +135,16 @@ public class CoreGrpcClient implements ICoreClient {
|
||||||
builder.setMac(coreInterface.getMac());
|
builder.setMac(coreInterface.getMac());
|
||||||
}
|
}
|
||||||
if (coreInterface.getIp4() != null) {
|
if (coreInterface.getIp4() != null) {
|
||||||
builder.setIp4(coreInterface.getIp4());
|
builder.setIp4(coreInterface.getIp4().toAddressString().getHostAddress().toString());
|
||||||
}
|
}
|
||||||
if (coreInterface.getIp4Mask() != null) {
|
if (coreInterface.getIp4() != null) {
|
||||||
builder.setIp4Mask(coreInterface.getIp4Mask());
|
builder.setIp4Mask(coreInterface.getIp4().getPrefixLength());
|
||||||
}
|
}
|
||||||
if (coreInterface.getIp6() != null) {
|
if (coreInterface.getIp6() != null) {
|
||||||
builder.setIp6(coreInterface.getIp6());
|
builder.setIp6(coreInterface.getIp6().toAddressString().getHostAddress().toString());
|
||||||
}
|
}
|
||||||
if (coreInterface.getIp6Mask() != null) {
|
if (coreInterface.getIp6() != null) {
|
||||||
builder.setIp6Mask(Integer.parseInt(coreInterface.getIp6Mask()));
|
builder.setIp6Mask(coreInterface.getIp6().getPrefixLength());
|
||||||
}
|
}
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
@ -170,10 +175,12 @@ public class CoreGrpcClient implements ICoreClient {
|
||||||
coreInterface.setId(protoInterface.getId());
|
coreInterface.setId(protoInterface.getId());
|
||||||
coreInterface.setName(protoInterface.getName());
|
coreInterface.setName(protoInterface.getName());
|
||||||
coreInterface.setMac(protoInterface.getMac());
|
coreInterface.setMac(protoInterface.getMac());
|
||||||
coreInterface.setIp4(protoInterface.getIp4());
|
String ip4String = String.format("%s/%s", protoInterface.getIp4(), protoInterface.getIp4Mask());
|
||||||
coreInterface.setIp4Mask(protoInterface.getIp4Mask());
|
IPAddress ip4 = new IPAddressString(ip4String).getAddress();
|
||||||
coreInterface.setIp6(protoInterface.getIp6());
|
coreInterface.setIp4(ip4);
|
||||||
coreInterface.setIp6Mask(Integer.toString(protoInterface.getIp6Mask()));
|
String ip6String = String.format("%s/%s", protoInterface.getIp6(), protoInterface.getIp6Mask());
|
||||||
|
IPAddress ip6 = new IPAddressString(ip6String).getAddress();
|
||||||
|
coreInterface.setIp6(ip6);
|
||||||
return coreInterface;
|
return coreInterface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.core.data;
|
package com.core.data;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import inet.ipaddr.IPAddress;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@ -10,10 +10,6 @@ public class CoreInterface {
|
||||||
private Integer id;
|
private Integer id;
|
||||||
private String name;
|
private String name;
|
||||||
private String mac;
|
private String mac;
|
||||||
private String ip4;
|
private IPAddress ip4;
|
||||||
@JsonProperty("ip4mask")
|
private IPAddress ip6;
|
||||||
private Integer ip4Mask;
|
|
||||||
private String ip6;
|
|
||||||
@JsonProperty("ip6mask")
|
|
||||||
private String ip6Mask;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,41 +1,87 @@
|
||||||
package com.core.graph;
|
package com.core.graph;
|
||||||
|
|
||||||
import com.core.data.CoreInterface;
|
import com.core.data.CoreInterface;
|
||||||
|
import inet.ipaddr.IPAddress;
|
||||||
|
import inet.ipaddr.IPAddressString;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Comparator;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class CoreAddresses {
|
public class CoreAddresses {
|
||||||
private static final Logger logger = LogManager.getLogger();
|
private static final Logger logger = LogManager.getLogger();
|
||||||
public static final int IP4_MASK = 24;
|
private IPAddress defaultSubnet = new IPAddressString("10.0.0.0/24").getAddress();
|
||||||
public static final int IP4_INDEX = (IP4_MASK / 8) - 1;
|
|
||||||
|
|
||||||
private String ip4Base;
|
private IPAddress getMaxAddress(Set<CoreInterface> interfaces) {
|
||||||
|
return interfaces.stream()
|
||||||
public CoreAddresses(String ip4Base) {
|
.map(CoreInterface::getIp4)
|
||||||
this.ip4Base = ip4Base;
|
.max(Comparator.comparingInt(x -> x.toIPv4().intValue()))
|
||||||
|
.orElseGet(() -> defaultSubnet);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSubnet(Collection<CoreInterface> nodeOneInterfaces, Collection<CoreInterface> nodeTwoInterfaces) {
|
public IPAddress getSubnet(Set<CoreInterface> nodeOneInterfaces, Set<CoreInterface> nodeTwoInterfaces,
|
||||||
int subOne = getMaxSubnet(nodeOneInterfaces);
|
boolean nodeOneIsNetwork, boolean nodeTwoIsNetwork) {
|
||||||
int subTwo = getMaxSubnet(nodeTwoInterfaces);
|
IPAddress nodeOneMax = getMaxAddress(nodeOneInterfaces);
|
||||||
logger.info("next subnet: {} - {}", subOne, subTwo);
|
IPAddress nodeTwoMax = getMaxAddress(nodeTwoInterfaces);
|
||||||
return Math.max(subOne, subTwo) + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getMaxSubnet(Collection<CoreInterface> coreInterfaces) {
|
logger.info("node one max: {}, node two max: {}", nodeOneMax, nodeTwoMax);
|
||||||
int sub = 0;
|
logger.info("max one compared to two: {} - {}",
|
||||||
for (CoreInterface coreInterface : coreInterfaces) {
|
nodeOneMax.toIPv4().intValue(), nodeTwoMax.toIPv4().intValue());
|
||||||
String[] values = coreInterface.getIp4().split("\\.");
|
boolean shouldBump;
|
||||||
int currentSub = Integer.parseInt(values[IP4_INDEX]);
|
boolean isDefault;
|
||||||
logger.info("checking {} value {}", coreInterface.getIp4(), currentSub);
|
IPAddress subnet;
|
||||||
sub = Math.max(currentSub, sub);
|
|
||||||
|
if (nodeOneMax.toIPv4().intValue() > nodeTwoMax.toIPv4().intValue()) {
|
||||||
|
subnet = nodeOneMax;
|
||||||
|
isDefault = nodeOneMax == defaultSubnet;
|
||||||
|
shouldBump = !nodeOneIsNetwork && !isDefault;
|
||||||
|
} else {
|
||||||
|
subnet = nodeTwoMax;
|
||||||
|
isDefault = nodeTwoMax == defaultSubnet;
|
||||||
|
shouldBump = !nodeTwoIsNetwork && !isDefault;
|
||||||
}
|
}
|
||||||
return sub;
|
|
||||||
|
logger.info("found max address: {} - {}", isDefault, subnet);
|
||||||
|
if (!isDefault) {
|
||||||
|
subnet = subnet.toPrefixBlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shouldBump) {
|
||||||
|
logger.info("incrementing subnet for host to host");
|
||||||
|
subnet = subnet.incrementBoundary(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.info("found subnet: {}", subnet);
|
||||||
|
return subnet;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIp4Address(int sub, int id) {
|
public static void main(String... args) {
|
||||||
return String.format("%s.%s.%s", ip4Base, sub, id);
|
IPAddress addresses = new IPAddressString("10.0.100.1/24").getAddress();
|
||||||
|
IPAddress addresses3 = new IPAddressString("10.0.0.2/24").getAddress();
|
||||||
|
IPAddress addresses1 = new IPAddressString("10.0.1.0/24").getAddress();
|
||||||
|
IPAddress addresses2 = new IPAddressString("10.0.2.0/24").getAddress();
|
||||||
|
System.out.println(String.format("compare to greater: %s", addresses.compareTo(addresses3)));
|
||||||
|
System.out.println(String.format("compare to greater: %s", addresses3.compareTo(addresses1)));
|
||||||
|
System.out.println(String.format("compare to greater: %s", addresses.toInetAddress()));
|
||||||
|
|
||||||
|
IPAddress address = addresses.increment(1);
|
||||||
|
IPAddress address1 = addresses1.increment(1);
|
||||||
|
IPAddress address2 = addresses2.increment(1);
|
||||||
|
System.out.println(String.format("divisions: %s", address.toPrefixBlock()));
|
||||||
|
System.out.println(String.format("divisions: %s", address1.toPrefixBlock()));
|
||||||
|
System.out.println(String.format("divisions: %s", address2.toPrefixBlock()));
|
||||||
|
System.out.println(String.format("compares: %s", address1.compareTo(address2)));
|
||||||
|
System.out.println(String.format("compares: %s", address1.compareTo(address)));
|
||||||
|
System.out.println(String.format("compares: %s", address2.getSection(2, 3)));
|
||||||
|
System.out.println(String.format("compares: %s", address2.getSegment(2)));
|
||||||
|
System.out.println(String.format("address: %s", address2));
|
||||||
|
|
||||||
|
IPAddress prefixBlock = address1.toPrefixBlock();
|
||||||
|
System.out.println(String.format("prefix block: %s", prefixBlock));
|
||||||
|
IPAddress update = new IPAddressString("0.0.1.0").getAddress();
|
||||||
|
IPAddress nextAddress = prefixBlock.incrementBoundary(1);
|
||||||
|
// nextAddress.setPrefixLength(prefixBlock.getPrefixLength(), true);
|
||||||
|
System.out.println(String.format("prefix block update: %s", nextAddress));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,9 +20,9 @@ import edu.uci.ics.jung.visualization.control.GraphMouseListener;
|
||||||
import edu.uci.ics.jung.visualization.control.ModalGraphMouse;
|
import edu.uci.ics.jung.visualization.control.ModalGraphMouse;
|
||||||
import edu.uci.ics.jung.visualization.decorators.EdgeShape;
|
import edu.uci.ics.jung.visualization.decorators.EdgeShape;
|
||||||
import edu.uci.ics.jung.visualization.renderers.Renderer;
|
import edu.uci.ics.jung.visualization.renderers.Renderer;
|
||||||
|
import inet.ipaddr.IPAddress;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.apache.commons.net.util.SubnetUtils;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
@ -32,7 +32,6 @@ import java.awt.event.MouseEvent;
|
||||||
import java.awt.geom.Ellipse2D;
|
import java.awt.geom.Ellipse2D;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
@ -50,8 +49,7 @@ public class NetworkGraph {
|
||||||
private EditingModalGraphMouse<CoreNode, CoreLink> graphMouse;
|
private EditingModalGraphMouse<CoreNode, CoreLink> graphMouse;
|
||||||
private AnnotationControls<CoreNode, CoreLink> annotationControls;
|
private AnnotationControls<CoreNode, CoreLink> annotationControls;
|
||||||
|
|
||||||
private SubnetUtils subnetUtils = new SubnetUtils("10.0.0.0/24");
|
private CoreAddresses coreAddresses = new CoreAddresses();
|
||||||
private CoreAddresses coreAddresses = new CoreAddresses("10.0");
|
|
||||||
private NodeType nodeType;
|
private NodeType nodeType;
|
||||||
private Map<Integer, CoreNode> nodeMap = new ConcurrentHashMap<>();
|
private Map<Integer, CoreNode> nodeMap = new ConcurrentHashMap<>();
|
||||||
private int vertexId = 1;
|
private int vertexId = 1;
|
||||||
|
@ -287,40 +285,91 @@ public class NetworkGraph {
|
||||||
|
|
||||||
private void handleEdgeAdded(GraphEvent.Edge<CoreNode, CoreLink> edgeEvent) {
|
private void handleEdgeAdded(GraphEvent.Edge<CoreNode, CoreLink> edgeEvent) {
|
||||||
CoreLink link = edgeEvent.getEdge();
|
CoreLink link = edgeEvent.getEdge();
|
||||||
if (!link.isLoaded()) {
|
if (link.isLoaded()) {
|
||||||
Pair<CoreNode> endpoints = graph.getEndpoints(link);
|
return;
|
||||||
|
|
||||||
CoreNode nodeOne = endpoints.getFirst();
|
|
||||||
CoreNode nodeTwo = endpoints.getSecond();
|
|
||||||
|
|
||||||
// create interfaces for nodes
|
|
||||||
int sub = coreAddresses.getSubnet(
|
|
||||||
getInterfaces(nodeOne),
|
|
||||||
getInterfaces(nodeTwo)
|
|
||||||
);
|
|
||||||
|
|
||||||
link.setNodeOne(nodeOne.getId());
|
|
||||||
if (isNode(nodeOne)) {
|
|
||||||
int interfaceOneId = nextInterfaceId(nodeOne);
|
|
||||||
CoreInterface interfaceOne = createInterface(nodeOne, sub, interfaceOneId);
|
|
||||||
link.setInterfaceOne(interfaceOne);
|
|
||||||
}
|
|
||||||
|
|
||||||
link.setNodeTwo(nodeTwo.getId());
|
|
||||||
if (isNode(nodeTwo)) {
|
|
||||||
int interfaceTwoId = nextInterfaceId(nodeTwo);
|
|
||||||
CoreInterface interfaceTwo = createInterface(nodeTwo, sub, interfaceTwoId);
|
|
||||||
link.setInterfaceTwo(interfaceTwo);
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean isVisible = !checkForWirelessNode(nodeOne, nodeTwo);
|
|
||||||
link.setVisible(isVisible);
|
|
||||||
|
|
||||||
logger.info("adding user created edge: {}", link);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Pair<CoreNode> endpoints = graph.getEndpoints(link);
|
||||||
|
|
||||||
|
CoreNode nodeOne = endpoints.getFirst();
|
||||||
|
CoreNode nodeTwo = endpoints.getSecond();
|
||||||
|
|
||||||
|
// check if a node being linked is a network node
|
||||||
|
Set<CoreInterface> nodeOneInterfaces;
|
||||||
|
boolean nodeOneIsNetwork = false;
|
||||||
|
if (isNode(nodeOne)) {
|
||||||
|
nodeOneInterfaces = getNodeInterfaces(nodeOne);
|
||||||
|
} else {
|
||||||
|
nodeOneInterfaces = getNetworkInterfaces(nodeOne, new HashSet<>());
|
||||||
|
nodeOneIsNetwork = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<CoreInterface> nodeTwoInterfaces;
|
||||||
|
boolean nodeTwoIsNetwork = false;
|
||||||
|
if (isNode(nodeTwo)) {
|
||||||
|
nodeTwoInterfaces = getNodeInterfaces(nodeTwo);
|
||||||
|
} else {
|
||||||
|
nodeTwoInterfaces = getNetworkInterfaces(nodeTwo, new HashSet<>());
|
||||||
|
nodeTwoIsNetwork = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// create interfaces for nodes
|
||||||
|
IPAddress subnet = coreAddresses.getSubnet(nodeOneInterfaces, nodeTwoInterfaces,
|
||||||
|
nodeOneIsNetwork, nodeTwoIsNetwork);
|
||||||
|
|
||||||
|
link.setNodeOne(nodeOne.getId());
|
||||||
|
if (isNode(nodeOne)) {
|
||||||
|
int interfaceOneId = nextInterfaceId(nodeOne);
|
||||||
|
CoreInterface interfaceOne = createInterface(nodeOne, interfaceOneId, subnet);
|
||||||
|
link.setInterfaceOne(interfaceOne);
|
||||||
|
}
|
||||||
|
|
||||||
|
link.setNodeTwo(nodeTwo.getId());
|
||||||
|
if (isNode(nodeTwo)) {
|
||||||
|
int interfaceTwoId = nextInterfaceId(nodeTwo);
|
||||||
|
CoreInterface interfaceTwo = createInterface(nodeTwo, interfaceTwoId, subnet);
|
||||||
|
link.setInterfaceTwo(interfaceTwo);
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isVisible = !checkForWirelessNode(nodeOne, nodeTwo);
|
||||||
|
link.setVisible(isVisible);
|
||||||
|
logger.info("adding user created edge: {}", link);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<CoreInterface> getInterfaces(CoreNode node) {
|
public Set<CoreInterface> getNetworkInterfaces(CoreNode node, Set<CoreNode> visited) {
|
||||||
|
Set<CoreInterface> interfaces = new HashSet<>();
|
||||||
|
if (visited.contains(node)) {
|
||||||
|
return interfaces;
|
||||||
|
}
|
||||||
|
visited.add(node);
|
||||||
|
|
||||||
|
logger.info("checking network node links: {}", node);
|
||||||
|
for (CoreLink link : graph.getIncidentEdges(node)) {
|
||||||
|
logger.info("checking link: {}", link);
|
||||||
|
if (link.getNodeOne() == null && link.getNodeTwo() == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ignore oneself
|
||||||
|
CoreNode currentNode = getVertex(link.getNodeOne());
|
||||||
|
CoreInterface currentInterface = link.getInterfaceOne();
|
||||||
|
if (node.getId().equals(link.getNodeOne())) {
|
||||||
|
currentNode = getVertex(link.getNodeTwo());
|
||||||
|
currentInterface = link.getInterfaceTwo();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isNode(currentNode)) {
|
||||||
|
interfaces.add(currentInterface);
|
||||||
|
} else {
|
||||||
|
Set<CoreInterface> nextInterfaces = getNetworkInterfaces(currentNode, visited);
|
||||||
|
interfaces.addAll(nextInterfaces);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return interfaces;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<CoreInterface> getNodeInterfaces(CoreNode node) {
|
||||||
return graph.getIncidentEdges(node).stream()
|
return graph.getIncidentEdges(node).stream()
|
||||||
.map(link -> {
|
.map(link -> {
|
||||||
if (node.getId().equals(link.getNodeOne())) {
|
if (node.getId().equals(link.getNodeOne())) {
|
||||||
|
@ -330,7 +379,7 @@ public class NetworkGraph {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
private int nextInterfaceId(CoreNode node) {
|
private int nextInterfaceId(CoreNode node) {
|
||||||
|
@ -360,13 +409,13 @@ public class NetworkGraph {
|
||||||
return node.getType() == NodeType.DEFAULT;
|
return node.getType() == NodeType.DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
private CoreInterface createInterface(CoreNode node, int sub, int interfaceId) {
|
private CoreInterface createInterface(CoreNode node, int interfaceId, IPAddress subnet) {
|
||||||
CoreInterface coreInterface = new CoreInterface();
|
CoreInterface coreInterface = new CoreInterface();
|
||||||
coreInterface.setId(interfaceId);
|
coreInterface.setId(interfaceId);
|
||||||
coreInterface.setName(String.format("eth%s", interfaceId));
|
coreInterface.setName(String.format("eth%s", interfaceId));
|
||||||
String nodeOneIp4 = coreAddresses.getIp4Address(sub, node.getId());
|
IPAddress address = subnet.increment(node.getId());
|
||||||
coreInterface.setIp4(nodeOneIp4);
|
coreInterface.setIp4(address);
|
||||||
coreInterface.setIp4Mask(CoreAddresses.IP4_MASK);
|
coreInterface.setIp6(address.toIPv6());
|
||||||
return coreInterface;
|
return coreInterface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ import com.core.ui.textfields.DoubleFilter;
|
||||||
import com.core.utils.FxmlUtils;
|
import com.core.utils.FxmlUtils;
|
||||||
import com.jfoenix.controls.JFXButton;
|
import com.jfoenix.controls.JFXButton;
|
||||||
import com.jfoenix.controls.JFXTextField;
|
import com.jfoenix.controls.JFXTextField;
|
||||||
|
import inet.ipaddr.IPAddress;
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import javafx.event.EventHandler;
|
import javafx.event.EventHandler;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
|
@ -129,8 +130,8 @@ public class LinkDetails extends ScrollPane {
|
||||||
if (coreInterface.getMac() != null) {
|
if (coreInterface.getMac() != null) {
|
||||||
addRow("MAC", coreInterface.getMac(), true);
|
addRow("MAC", coreInterface.getMac(), true);
|
||||||
}
|
}
|
||||||
addIp4Address(coreInterface.getIp4(), coreInterface.getIp4Mask());
|
addIp4Address(coreInterface.getIp4());
|
||||||
addIp6Address(coreInterface.getIp6(), coreInterface.getIp6Mask());
|
addIp6Address(coreInterface.getIp6());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addRow(String labelText, String value, boolean disabled) {
|
private void addRow(String labelText, String value, boolean disabled) {
|
||||||
|
@ -155,18 +156,18 @@ public class LinkDetails extends ScrollPane {
|
||||||
return textField;
|
return textField;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addIp4Address(String ip, Integer mask) {
|
private void addIp4Address(IPAddress ip) {
|
||||||
if (ip == null) {
|
if (ip == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
addRow("IP4", String.format("%s/%s", ip, mask), true);
|
addRow("IP4", ip.toString(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addIp6Address(String ip, String mask) {
|
private void addIp6Address(IPAddress ip) {
|
||||||
if (ip == null) {
|
if (ip == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
addRow("IP6", String.format("%s/%s", ip, mask), true);
|
addRow("IP6", ip.toString(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clear() {
|
private void clear() {
|
||||||
|
|
|
@ -10,6 +10,7 @@ import com.jfoenix.controls.JFXButton;
|
||||||
import com.jfoenix.controls.JFXListView;
|
import com.jfoenix.controls.JFXListView;
|
||||||
import com.jfoenix.controls.JFXScrollPane;
|
import com.jfoenix.controls.JFXScrollPane;
|
||||||
import com.jfoenix.controls.JFXTextField;
|
import com.jfoenix.controls.JFXTextField;
|
||||||
|
import inet.ipaddr.IPAddress;
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import javafx.event.EventHandler;
|
import javafx.event.EventHandler;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
|
@ -147,8 +148,8 @@ public class NodeDetails extends ScrollPane {
|
||||||
if (coreInterface.getMac() != null) {
|
if (coreInterface.getMac() != null) {
|
||||||
addRow("MAC", coreInterface.getMac(), true);
|
addRow("MAC", coreInterface.getMac(), true);
|
||||||
}
|
}
|
||||||
addIp4Address(coreInterface.getIp4(), coreInterface.getIp4Mask());
|
addIp4Address(coreInterface.getIp4());
|
||||||
addIp6Address(coreInterface.getIp6(), coreInterface.getIp6Mask());
|
addIp6Address(coreInterface.getIp6());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addRow(String labelText, String value, boolean disabled) {
|
private void addRow(String labelText, String value, boolean disabled) {
|
||||||
|
@ -158,18 +159,18 @@ public class NodeDetails extends ScrollPane {
|
||||||
gridPane.addRow(index++, label, textField);
|
gridPane.addRow(index++, label, textField);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addIp4Address(String ip, Integer mask) {
|
private void addIp4Address(IPAddress ip) {
|
||||||
if (ip == null) {
|
if (ip == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
addRow("IP4", String.format("%s/%s", ip, mask), true);
|
addRow("IP4", ip.toString(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addIp6Address(String ip, String mask) {
|
private void addIp6Address(IPAddress ip) {
|
||||||
if (ip == null) {
|
if (ip == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
addRow("IP6", String.format("%s/%s", ip, mask), true);
|
addRow("IP6", ip.toString(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clear() {
|
private void clear() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue