Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions app/components/ConnectivityMatrix.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,9 @@ export const ConnectivityMatrix: React.FC<ConnectivityMatrixProps> = ({
};

const getConnectivityStatus = (sourceId: string, targetId: string) => {
if (sourceId === targetId) return "self";
if (sourceId === targetId) return "connected";
if (sourceId.includes("rt") || targetId.includes("rt"))
return "connected";

const key = `${sourceId}-${targetId}`;
const result = connectivityResults.get(key);
Expand Down Expand Up @@ -373,10 +375,15 @@ export const ConnectivityMatrix: React.FC<ConnectivityMatrixProps> = ({
const getConnectivityStats = () => {
if (connectivityResults.size === 0) return null;

const totalConnections = connectivityResults.size;
const successfulConnections = Array.from(
connectivityResults.values()
).filter((r) => r.success).length;
const totalConnections = connectivityResults.size + nodes.length; // Include self-connections
const successfulConnections =
Array.from(connectivityResults.values()).filter(
(r) =>
r.success ||
r.sourceId == r.targetId ||
r.sourceId.includes("rt") ||
r.targetId.includes("rt")
).length + nodes.length; // Count self-connections and router connections as successful
const avgLatency = Array.from(connectivityResults.values())
.filter((r) => r.success && r.latency)
.reduce((sum, r, _, arr) => sum + (r.latency || 0) / arr.length, 0);
Expand Down Expand Up @@ -463,10 +470,10 @@ export const ConnectivityMatrix: React.FC<ConnectivityMatrixProps> = ({
<button
onClick={() => setAutoRefresh(!autoRefresh)}
className={`p-1 rounded transition-colors ${
autoRefresh ? "text-green-600" : "text-red-400"
!autoRefresh ? "text-green-600" : "text-red-400"
}`}
>
{autoRefresh ? (
{!autoRefresh ? (
<Play className="w-4 h-4" />
) : (
<Pause className="w-4 h-4" />
Expand All @@ -478,7 +485,9 @@ export const ConnectivityMatrix: React.FC<ConnectivityMatrixProps> = ({
setRefreshInterval(Number(e.target.value))
}
className={`border border-gray-300 rounded px-2 py-1 text-sm ${
autoRefresh ? "text-green-600" : "text-red-400"
autoRefresh
? ""
: "opacity-50 cursor-not-allowed"
}`}
disabled={!autoRefresh}
>
Expand Down Expand Up @@ -681,9 +690,6 @@ export const ConnectivityMatrix: React.FC<ConnectivityMatrixProps> = ({
? ` (${result.error})`
: ""
}`
: status ===
"self"
? "Same device"
: "Not tested"
}
>
Expand Down
10 changes: 5 additions & 5 deletions commands/init_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,14 @@ def assign_ip_address(self, node_id: str, node_index: int) -> str:
if node_type == 'external':
segment = self.network_segments['external']
base_ip = int(segment.split('.')[2])
ip_host = 10 + node_index
ip_host = 0 + node_index
ip = f"10.0.{base_ip}.{ip_host}"
elif node_type == 'firewall':
# Firewall gets IP in management segment and acts as gateway
ip = "10.0.0.2" # Main gateway
ip = "10.0.0.20" # Main gateway
elif node_type == 'router':
# Router gets IP in management segment
ip = "10.0.0.3"
ip = "10.0.0.30"
elif node_type == 'server':
# Servers in DMZ
segment = self.network_segments['dmz']
Expand All @@ -203,11 +203,11 @@ def assign_ip_address(self, node_id: str, node_index: int) -> str:
# Users and switches in internal network
segment = self.network_segments['internal']
base_ip = int(segment.split('.')[2])
ip_host = 10 + (node_index % 240)
ip_host = 0 + (node_index % 240) - 1
ip = f"10.0.{base_ip}.{ip_host}"
else:
# Default assignment
ip_host = 10 + node_index
ip_host = 0 + node_index
ip = f"10.0.0.{ip_host}"

self.ip_assignments[node_id] = ip
Expand Down
10 changes: 5 additions & 5 deletions public/simplified_state.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"threats_blocked": 0,
"traffic_volume": "150 MB/s"
},
"ip": "172.20.3.10"
"ip": "10.0.0.20"
},
{
"id": "rt-001",
Expand All @@ -32,7 +32,7 @@
"throughput": "500 MB/s",
"rules": []
},
"ip": "172.20.3.11"
"ip": "10.0.0.30"
},
{
"id": "host-001",
Expand All @@ -48,7 +48,7 @@
"last_activity": "1 minute ago",
"security_level": "medium"
},
"ip": "172.20.3.12"
"ip": "10.0.3.1"
},
{
"id": "host-002",
Expand All @@ -64,7 +64,7 @@
"last_activity": "3 minutes ago",
"security_level": "medium"
},
"ip": "172.20.3.13"
"ip": "10.0.3.2"
},
{
"id": "host-003",
Expand All @@ -80,7 +80,7 @@
"last_activity": "10 minutes ago",
"security_level": "low"
},
"ip": "172.20.3.14"
"ip": "10.0.3.3"
}
],
"connections": [
Expand Down
Loading