Fix IP6Config nameserver data fetch
This commit is contained in:
parent
bdc679ae76
commit
c8c883838e
2 changed files with 16 additions and 16 deletions
24
IP6Config.go
24
IP6Config.go
|
@ -49,10 +49,6 @@ type IP6RouteData struct {
|
||||||
AdditionalAttributes map[string]string
|
AdditionalAttributes map[string]string
|
||||||
}
|
}
|
||||||
|
|
||||||
type IP6NameserverData struct {
|
|
||||||
Address string
|
|
||||||
}
|
|
||||||
|
|
||||||
type IP6Config interface {
|
type IP6Config interface {
|
||||||
|
|
||||||
// Array of IP address data objects. All addresses will include "address" (an IP address string), and "prefix" (a uint). Some addresses may include additional attributes.
|
// Array of IP address data objects. All addresses will include "address" (an IP address string), and "prefix" (a uint). Some addresses may include additional attributes.
|
||||||
|
@ -65,7 +61,7 @@ type IP6Config interface {
|
||||||
GetRouteData() []IP6RouteData
|
GetRouteData() []IP6RouteData
|
||||||
|
|
||||||
// GetNameservers gets the nameservers in use.
|
// GetNameservers gets the nameservers in use.
|
||||||
GetNameservers() []IP6NameserverData
|
GetNameservers() []string
|
||||||
|
|
||||||
// A list of domains this address belongs to.
|
// A list of domains this address belongs to.
|
||||||
GetDomains() []string
|
GetDomains() []string
|
||||||
|
@ -141,19 +137,15 @@ func (c *ip6Config) GetRouteData() []IP6RouteData {
|
||||||
return routes
|
return routes
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ip6Config) GetNameservers() []IP6NameserverData {
|
func (c *ip6Config) GetNameservers() []string {
|
||||||
nameserversData := c.getSliceMapStringVariantProperty(IP6ConfigPropertyNameservers)
|
nameservers := c.getSliceSliceByteProperty(IP6ConfigPropertyNameservers)
|
||||||
nameservers := make([]IP6NameserverData, len(nameserversData))
|
ret := make([]string, len(nameservers))
|
||||||
|
|
||||||
for _, nameserverData := range nameserversData {
|
for i, nameserver := range nameservers {
|
||||||
|
ret[i] = string(nameserver)
|
||||||
nameserver := IP6NameserverData{
|
|
||||||
Address: nameserverData["address"].Value().(string),
|
|
||||||
}
|
|
||||||
|
|
||||||
nameservers = append(nameservers, nameserver)
|
|
||||||
}
|
}
|
||||||
return nameservers
|
|
||||||
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ip6Config) GetDomains() []string {
|
func (c *ip6Config) GetDomains() []string {
|
||||||
|
|
8
utils.go
8
utils.go
|
@ -108,6 +108,14 @@ func (d *dbusBase) getSliceStringProperty(iface string) []string {
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *dbusBase) getSliceSliceByteProperty(iface string) [][]byte {
|
||||||
|
value, ok := d.getProperty(iface).([][]byte)
|
||||||
|
if !ok {
|
||||||
|
panic(makeErrVariantType(iface))
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
func (d *dbusBase) getMapStringVariantProperty(iface string) map[string]dbus.Variant {
|
func (d *dbusBase) getMapStringVariantProperty(iface string) map[string]dbus.Variant {
|
||||||
value, ok := d.getProperty(iface).(map[string]dbus.Variant)
|
value, ok := d.getProperty(iface).(map[string]dbus.Variant)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|
Reference in a new issue