feat(get_iface): add type information in response

This commit is contained in:
Mark Paronyan 2025-03-23 14:28:27 +00:00
parent ea2856289a
commit bab173ee52
No known key found for this signature in database
GPG Key ID: 8DC7338A87FE22F8
2 changed files with 5 additions and 1 deletions
gns3server
api/routes/controller
schemas/controller

@ -324,17 +324,19 @@ async def get_iface(link: Link = Depends(dep_link)) -> dict[str, schemas.UdpPort
port_type = port.get("type", "")
if "udp" in port_type.lower():
ifaces_info[node.id] = {
"type": f"{port_type}",
"rhost": port["rhost"],
"lport": port["lport"],
"rport": port["rport"],
}
else:
ifaces_info[node.id] = {
"type": f"{port_type}",
"interface": port["interface"],
}
if not ifaces_info:
raise ControllerError(
"Link not connected to Cloud/NAT with UDP tunnel"
"Link not connected to Cloud/NAT"
)
return ifaces_info

@ -102,6 +102,7 @@ class UdpPort(BaseModel):
lport: int
rhost: str
rport: int
type: str
class EthernetPort(BaseModel):
@ -110,3 +111,4 @@ class EthernetPort(BaseModel):
"""
interface: str
type: str