#2887 - Merge in changes on dev to resolve conflicts. All tests should now pass
This commit is contained in:
@@ -1493,6 +1493,7 @@ class Node(SimComponent, ABC):
|
||||
:param hostname: The node hostname on the network.
|
||||
:param operating_state: The node operating state, either ON or OFF.
|
||||
"""
|
||||
|
||||
operating_state: NodeOperatingState = NodeOperatingState.OFF
|
||||
"The hardware state of the node."
|
||||
network_interfaces: Dict[str, NetworkInterface] = {}
|
||||
@@ -1564,7 +1565,7 @@ class Node(SimComponent, ABC):
|
||||
"Time steps until reveal to red scan is complete."
|
||||
|
||||
dns_server: Optional[IPv4Address] = None
|
||||
"List of IP addresses of DNS servers used for name resolution."
|
||||
"List of IP addresses of DNS servers used for name resolution."
|
||||
|
||||
default_gateway: Optional[IPV4Address] = None
|
||||
"The default gateway IP address for forwarding network traffic to other networks."
|
||||
@@ -1573,6 +1574,7 @@ class Node(SimComponent, ABC):
|
||||
|
||||
@property
|
||||
def dns_server(self) -> Optional[IPv4Address]:
|
||||
"""Convenience method to access the dns_server IP."""
|
||||
return self.config.dns_server
|
||||
|
||||
@classmethod
|
||||
@@ -1625,7 +1627,9 @@ class Node(SimComponent, ABC):
|
||||
dns_server=kwargs["config"].dns_server,
|
||||
)
|
||||
super().__init__(**kwargs)
|
||||
self.operating_state = NodeOperatingState.ON if not (p := kwargs["config"].operating_state) else NodeOperatingState[p.upper()]
|
||||
self.operating_state = (
|
||||
NodeOperatingState.ON if not (p := kwargs["config"].operating_state) else NodeOperatingState[p.upper()]
|
||||
)
|
||||
self._install_system_software()
|
||||
self.session_manager.node = self
|
||||
self.session_manager.software_manager = self.software_manager
|
||||
|
||||
@@ -37,7 +37,7 @@ class Computer(HostNode, identifier="computer"):
|
||||
|
||||
SYSTEM_SOFTWARE: ClassVar[Dict] = {**HostNode.SYSTEM_SOFTWARE, "FTPClient": FTPClient}
|
||||
|
||||
config: "Computer.ConfigSchema" = Field(default_factory=lambda: Computer.ConfigSchema())
|
||||
config: "Computer.ConfigSchema" = Field(default_factory=lambda: Computer.ConfigSchema())
|
||||
|
||||
class ConfigSchema(HostNode.ConfigSchema):
|
||||
"""Configuration Schema for Computer class."""
|
||||
|
||||
@@ -55,7 +55,10 @@ class HostARP(ARP):
|
||||
|
||||
:return: The NIC associated with the default gateway if it exists in the ARP cache; otherwise, None.
|
||||
"""
|
||||
if self.software_manager.node.config.default_gateway and self.software_manager.node.has_enabled_network_interface:
|
||||
if (
|
||||
self.software_manager.node.config.default_gateway
|
||||
and self.software_manager.node.has_enabled_network_interface
|
||||
):
|
||||
return self.get_arp_cache_network_interface(self.software_manager.node.config.default_gateway)
|
||||
|
||||
def _get_arp_cache_mac_address(
|
||||
|
||||
@@ -58,24 +58,28 @@ def client_server_routed() -> Network:
|
||||
router_1.enable_port(2)
|
||||
|
||||
# Client 1
|
||||
client_1 = Computer(config=dict(
|
||||
hostname="client_1",
|
||||
ip_address="192.168.2.2",
|
||||
subnet_mask="255.255.255.0",
|
||||
default_gateway="192.168.2.1",
|
||||
start_up_duration=0,
|
||||
))
|
||||
client_1 = Computer(
|
||||
config=dict(
|
||||
hostname="client_1",
|
||||
ip_address="192.168.2.2",
|
||||
subnet_mask="255.255.255.0",
|
||||
default_gateway="192.168.2.1",
|
||||
start_up_duration=0,
|
||||
)
|
||||
)
|
||||
client_1.power_on()
|
||||
network.connect(endpoint_b=client_1.network_interface[1], endpoint_a=switch_2.network_interface[1])
|
||||
|
||||
# Server 1
|
||||
server_1 = Server(config=dict(
|
||||
hostname="server_1",
|
||||
ip_address="192.168.1.2",
|
||||
subnet_mask="255.255.255.0",
|
||||
default_gateway="192.168.1.1",
|
||||
start_up_duration=0,
|
||||
))
|
||||
server_1 = Server(
|
||||
config=dict(
|
||||
hostname="server_1",
|
||||
ip_address="192.168.1.2",
|
||||
subnet_mask="255.255.255.0",
|
||||
default_gateway="192.168.1.1",
|
||||
start_up_duration=0,
|
||||
)
|
||||
)
|
||||
server_1.power_on()
|
||||
network.connect(endpoint_b=server_1.network_interface[1], endpoint_a=switch_1.network_interface[1])
|
||||
|
||||
|
||||
@@ -43,7 +43,6 @@ class FTPServer(FTPServiceABC, identifier="FTPServer"):
|
||||
"""Convenience method for accessing FTP server password."""
|
||||
return self.config.server_password
|
||||
|
||||
|
||||
def _process_ftp_command(self, payload: FTPPacket, session_id: Optional[str] = None, **kwargs) -> FTPPacket:
|
||||
"""
|
||||
Process the command in the FTP Packet.
|
||||
|
||||
@@ -29,7 +29,6 @@ class NTPClient(Service, identifier="NTPClient"):
|
||||
|
||||
config: "NTPClient.ConfigSchema" = Field(default_factory=lambda: NTPClient.ConfigSchema())
|
||||
|
||||
|
||||
time: Optional[datetime] = None
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
|
||||
Reference in New Issue
Block a user