Merge branch 'origin/dev' into feature/1812-traverse-actions-dict
This commit is contained in:
@@ -722,7 +722,9 @@ class ARPCache:
|
||||
|
||||
# Unmatched ARP Request
|
||||
if arp_packet.target_ip_address != from_nic.ip_address:
|
||||
self.sys_log.info(f"Ignoring ARP request for {arp_packet.target_ip_address}")
|
||||
self.sys_log.info(
|
||||
f"Ignoring ARP request for {arp_packet.target_ip_address}. Current IP address is {from_nic.ip_address}"
|
||||
)
|
||||
return
|
||||
|
||||
# Matched ARP request
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from primaite.simulator.network.hardware.base import NIC, Node
|
||||
from primaite.simulator.system.applications.web_browser import WebBrowser
|
||||
from primaite.simulator.system.services.dns.dns_client import DNSClient
|
||||
from primaite.simulator.system.services.ftp.ftp_client import FTPClient
|
||||
|
||||
@@ -48,4 +49,7 @@ class Computer(Node):
|
||||
# FTP
|
||||
self.software_manager.install(FTPClient)
|
||||
|
||||
# Web Browser
|
||||
self.software_manager.install(WebBrowser)
|
||||
|
||||
super()._install_system_software()
|
||||
|
||||
@@ -13,6 +13,7 @@ from primaite.simulator.system.services.database.database_service import Databas
|
||||
from primaite.simulator.system.services.dns.dns_server import DNSServer
|
||||
from primaite.simulator.system.services.ftp.ftp_server import FTPServer
|
||||
from primaite.simulator.system.services.red_services.data_manipulation_bot import DataManipulationBot
|
||||
from primaite.simulator.system.services.web_server.web_server import WebServer
|
||||
|
||||
|
||||
def client_server_routed() -> Network:
|
||||
@@ -253,6 +254,8 @@ def arcd_uc2_network() -> Network:
|
||||
database_client.run()
|
||||
database_client.connect()
|
||||
|
||||
web_server.software_manager.install(WebServer)
|
||||
|
||||
# register the web_server to a domain
|
||||
dns_server_service: DNSServer = domain_controller.software_manager.software["DNSServer"] # noqa
|
||||
dns_server_service.dns_register("arcd.com", web_server.ip_address)
|
||||
@@ -266,9 +269,8 @@ def arcd_uc2_network() -> Network:
|
||||
dns_server=IPv4Address("192.168.1.10"),
|
||||
)
|
||||
backup_server.power_on()
|
||||
network.connect(endpoint_b=backup_server.ethernet_port[1], endpoint_a=switch_1.switch_ports[4])
|
||||
|
||||
backup_server.software_manager.install(FTPServer)
|
||||
network.connect(endpoint_b=backup_server.ethernet_port[1], endpoint_a=switch_1.switch_ports[4])
|
||||
|
||||
# Security Suite
|
||||
security_suite = Server(
|
||||
@@ -298,4 +300,7 @@ def arcd_uc2_network() -> Network:
|
||||
# Allow FTP requests
|
||||
router_1.acl.add_rule(action=ACLAction.PERMIT, src_port=Port.FTP, dst_port=Port.FTP, position=2)
|
||||
|
||||
# Open port 80 for web server
|
||||
router_1.acl.add_rule(action=ACLAction.PERMIT, src_port=Port.HTTP, dst_port=Port.HTTP, position=3)
|
||||
|
||||
return network
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from enum import Enum
|
||||
from typing import Any, Optional
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
from primaite.simulator.network.protocols.packet import DataPacket
|
||||
|
||||
@@ -51,5 +51,5 @@ class FTPPacket(DataPacket):
|
||||
ftp_command_args: Optional[Any] = None
|
||||
"""Arguments for command."""
|
||||
|
||||
status_code: FTPStatusCode = None
|
||||
status_code: Union[FTPStatusCode, None] = None
|
||||
"""Status of the response."""
|
||||
|
||||
64
src/primaite/simulator/network/protocols/http.py
Normal file
64
src/primaite/simulator/network/protocols/http.py
Normal file
@@ -0,0 +1,64 @@
|
||||
from enum import Enum
|
||||
|
||||
from primaite.simulator.network.protocols.packet import DataPacket
|
||||
|
||||
|
||||
class HttpRequestMethod(Enum):
|
||||
"""Enum list of HTTP Request methods that can be handled by the simulation."""
|
||||
|
||||
GET = "GET"
|
||||
"""HTTP GET Method. Requests using GET should only retrieve data."""
|
||||
|
||||
HEAD = "HEAD"
|
||||
"""Asks for a response identical to a GET request, but without the response body."""
|
||||
|
||||
POST = "POST"
|
||||
"""Submit an entity to the specified resource, often causing a change in state or side effects on the server."""
|
||||
|
||||
PUT = "PUT"
|
||||
"""Replace all current representations of the target resource with the request payload."""
|
||||
|
||||
DELETE = "DELETE"
|
||||
"""Delete the specified resource."""
|
||||
|
||||
PATCH = "PATCH"
|
||||
"""Apply partial modifications to a resource."""
|
||||
|
||||
|
||||
class HttpStatusCode(Enum):
|
||||
"""List of available HTTP Statuses."""
|
||||
|
||||
OK = 200
|
||||
"""request has succeeded."""
|
||||
|
||||
BAD_REQUEST = 400
|
||||
"""Payload cannot be parsed."""
|
||||
|
||||
UNAUTHORIZED = 401
|
||||
"""Auth required."""
|
||||
|
||||
NOT_FOUND = 404
|
||||
"""Item not found in server."""
|
||||
|
||||
METHOD_NOT_ALLOWED = 405
|
||||
"""Method is not supported by server."""
|
||||
|
||||
INTERNAL_SERVER_ERROR = 500
|
||||
"""Error on the server side."""
|
||||
|
||||
|
||||
class HttpRequestPacket(DataPacket):
|
||||
"""Class that represents an HTTP Request Packet."""
|
||||
|
||||
request_method: HttpRequestMethod
|
||||
"""The HTTP Request method."""
|
||||
|
||||
request_url: str
|
||||
"""URL of request."""
|
||||
|
||||
|
||||
class HttpResponsePacket(DataPacket):
|
||||
"""Class that reprensents an HTTP Response Packet."""
|
||||
|
||||
status_code: HttpStatusCode = None
|
||||
"""Status code of the HTTP response."""
|
||||
@@ -1,9 +1,14 @@
|
||||
from typing import Any
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class DataPacket(BaseModel):
|
||||
"""Data packet abstract class."""
|
||||
|
||||
payload: Any = None
|
||||
"""Payload content of the packet."""
|
||||
|
||||
packet_payload_size: float = 0
|
||||
"""Size of the packet."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user