diff --git a/AGHTechDoc.md b/AGHTechDoc.md index 809b0c72..76e1171c 100644 --- a/AGHTechDoc.md +++ b/AGHTechDoc.md @@ -444,7 +444,8 @@ Response: "name":"iface_name", "mtu":1500, "hardware_address":"...", - "ip_addresses":["ipv4 addr","ipv6 addr", ...], + "ipv4_addresses":["ipv4 addr", ...], + "ipv6_addresses":["ipv6 addr", ...], "flags":"up|broadcast|multicast" } ... diff --git a/dhcpd/dhcp_http.go b/dhcpd/dhcp_http.go index 7ae6075a..f85c00b4 100644 --- a/dhcpd/dhcp_http.go +++ b/dhcpd/dhcp_http.go @@ -202,7 +202,8 @@ type netInterfaceJSON struct { Name string `json:"name"` MTU int `json:"mtu"` HardwareAddr string `json:"hardware_address"` - Addresses []string `json:"ip_addresses"` + Addrs4 []string `json:"ipv4_addresses"` + Addrs6 []string `json:"ipv6_addresses"` Flags string `json:"flags"` } @@ -251,9 +252,13 @@ func (s *Server) handleDHCPInterfaces(w http.ResponseWriter, r *http.Request) { if ipnet.IP.IsLinkLocalUnicast() { continue } - jsonIface.Addresses = append(jsonIface.Addresses, ipnet.IP.String()) + if ipnet.IP.To4() != nil { + jsonIface.Addrs4 = append(jsonIface.Addrs4, ipnet.IP.String()) + } else { + jsonIface.Addrs6 = append(jsonIface.Addrs6, ipnet.IP.String()) + } } - if len(jsonIface.Addresses) != 0 { + if len(jsonIface.Addrs4)+len(jsonIface.Addrs6) != 0 { response[iface.Name] = jsonIface } diff --git a/openapi/openapi.yaml b/openapi/openapi.yaml index 7b29f96c..ef288f04 100644 --- a/openapi/openapi.yaml +++ b/openapi/openapi.yaml @@ -1626,12 +1626,14 @@ components: name: type: string example: eth0 - ip_addresses: + ipv4_addresses: + type: array + items: + type: string + ipv6_addresses: type: array items: type: string - example: - - 127.0.0.1 AddressInfo: type: object description: Port information