* GET /control/dhcp/interfaces: split IPv4 and IPv6 addresses
This commit is contained in:
parent
89c3926ba5
commit
ec24d18f83
|
@ -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"
|
||||
}
|
||||
...
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue