From 3a91ad9f215e019acf6c699aeeb5c963fdc5d2b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=BCller?= Date: Mon, 27 May 2019 14:59:39 +0200 Subject: [PATCH] Return nil when optional DHCP / IP config is unavailable --- ActiveConnection.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ActiveConnection.go b/ActiveConnection.go index 36fc71f..e7c3018 100644 --- a/ActiveConnection.go +++ b/ActiveConnection.go @@ -143,6 +143,10 @@ func (a *activeConnection) GetDefault() bool { func (a *activeConnection) GetIP4Config() IP4Config { path := a.getObjectProperty(ActiveConnectionPropertyIp4Config) + if path == "/" { + return nil + } + r, err := NewIP4Config(path) if err != nil { panic(err) @@ -152,6 +156,10 @@ func (a *activeConnection) GetIP4Config() IP4Config { func (a *activeConnection) GetDHCP4Config() DHCP4Config { path := a.getObjectProperty(ActiveConnectionPropertyDhcp4Config) + if path == "/" { + return nil + } + r, err := NewDHCP4Config(path) if err != nil { panic(err) @@ -166,6 +174,10 @@ func (a *activeConnection) GetDefault6() bool { func (a *activeConnection) GetIP6Config() IP6Config { path := a.getObjectProperty(ActiveConnectionPropertyIp6Config) + if path == "/" { + return nil + } + r, err := NewIP6Config(path) if err != nil { panic(err) @@ -175,6 +187,10 @@ func (a *activeConnection) GetIP6Config() IP6Config { //func (a *activeConnection) GetDHCP6Config() DHCP6Config { // path := a.getObjectProperty(ActiveConnectionPropertyDhcp6Config) +// if path == "/" { +// return nil +// } + // r, err := NewDHCP6Config(path) // if err != nil { // panic(err)