mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
feat(builtin): NAT node returns its interface IP info in asdict()
NAT now includes an 'interfaces' field in its response, filtered to contain only the mapped NAT interface (virbr0 on Linux, vmnet8 on macOS/Windows). This lets connected nodes discover the NAT subnet and gateway address without needing to list all host interfaces. The field format mirrors Cloud.asdict(): name, type, special, and ip_addresses list (both IPv4 and IPv6).
This commit is contained in:
2 files changed
+73
-31
No files matched your search
@@ -87,6 +87,23 @@ class Nat(Cloud):
|
||||
return True
|
||||
|
||||
def asdict(self):
|
||||
|
||||
nat_interface = self._ports_mapping[0].get("interface", "") if self._ports_mapping else ""
|
||||
|
||||
host_interfaces = []
|
||||
network_interfaces = gns3server.utils.interfaces.interfaces()
|
||||
for interface in network_interfaces:
|
||||
if interface["name"] == nat_interface:
|
||||
host_interfaces.append(
|
||||
{
|
||||
"name": interface["name"],
|
||||
"type": interface["type"],
|
||||
"special": interface["special"],
|
||||
"ip_addresses": interface.get("ip_addresses", []),
|
||||
}
|
||||
)
|
||||
break
|
||||
|
||||
return {
|
||||
"name": self.name,
|
||||
"usage": self.usage,
|
||||
@@ -94,4 +111,5 @@ class Nat(Cloud):
|
||||
"project_id": self.project.id,
|
||||
"status": "started",
|
||||
"ports_mapping": self.ports_mapping,
|
||||
"interfaces": host_interfaces,
|
||||
}
|
||||
Reference in new issue
Block a user