pygui: added check so bridge based nodes can only have 1 link between them
This commit is contained in:
parent
29bd6ef7f8
commit
055029e5c5
2 changed files with 13 additions and 0 deletions
|
@ -437,6 +437,14 @@ class CanvasGraph(tk.Canvas):
|
|||
edge.delete()
|
||||
return
|
||||
|
||||
# only 1 link between bridge based nodes
|
||||
is_src_bridge = NodeUtils.is_bridge_node(src_node.core_node)
|
||||
is_dst_bridge = NodeUtils.is_bridge_node(dst_node.core_node)
|
||||
common_links = src_node.edges & dst_node.edges
|
||||
if all([is_src_bridge, is_dst_bridge, common_links]):
|
||||
edge.delete()
|
||||
return
|
||||
|
||||
# finalize edge creation
|
||||
self.complete_edge(src_node, dst_node, edge)
|
||||
|
||||
|
|
|
@ -62,12 +62,17 @@ class NodeUtils:
|
|||
IMAGE_NODES: Set[NodeType] = {NodeType.DOCKER, NodeType.LXC}
|
||||
WIRELESS_NODES: Set[NodeType] = {NodeType.WIRELESS_LAN, NodeType.EMANE}
|
||||
RJ45_NODES: Set[NodeType] = {NodeType.RJ45}
|
||||
BRIDGE_NODES: Set[NodeType] = {NodeType.HUB, NodeType.SWITCH}
|
||||
IGNORE_NODES: Set[NodeType] = {NodeType.CONTROL_NET}
|
||||
MOBILITY_NODES: Set[NodeType] = {NodeType.WIRELESS_LAN, NodeType.EMANE}
|
||||
NODE_MODELS: Set[str] = {"router", "host", "PC", "mdr", "prouter"}
|
||||
ROUTER_NODES: Set[str] = {"router", "mdr"}
|
||||
ANTENNA_ICON: PhotoImage = None
|
||||
|
||||
@classmethod
|
||||
def is_bridge_node(cls, node: Node) -> bool:
|
||||
return node.type in cls.BRIDGE_NODES
|
||||
|
||||
@classmethod
|
||||
def is_mobility(cls, node: Node) -> bool:
|
||||
return node.type in cls.MOBILITY_NODES
|
||||
|
|
Loading…
Reference in a new issue