From e82244360090ce65dfdcc9c1a3052253e682c9a3 Mon Sep 17 00:00:00 2001 From: Simon Zolin Date: Thu, 19 Mar 2020 14:22:16 +0300 Subject: [PATCH] minor --- home/openwrt.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/home/openwrt.go b/home/openwrt.go index a7f5012a..528a620f 100644 --- a/home/openwrt.go +++ b/home/openwrt.go @@ -120,6 +120,8 @@ func (oc *openwrtConfig) readConf(data []byte, section string, iface string) { } } } + +// Parse static DHCP leases from system configuration data func (oc *openwrtConfig) readConfDHCPStatic(data []byte) error { state := 0 sr := strings.NewReader(string(data)) @@ -254,7 +256,8 @@ func (oc *openwrtConfig) prepareOutput() error { return nil } -func (oc *openwrtConfig) Start() error { +// Process - read and process system configuration data +func (oc *openwrtConfig) Process() error { data, err := ioutil.ReadFile("/etc/config/network") if err != nil { return err @@ -272,7 +275,7 @@ func (oc *openwrtConfig) Start() error { return err } - oc.readConfDHCPStatic(data) + err = oc.readConfDHCPStatic(data) if err != nil { return err } @@ -283,7 +286,7 @@ func (oc *openwrtConfig) Start() error { // Read system configuration files and write our configuration files func autoConfig(configFn string) error { oc := openwrtConfig{} - err := oc.Start() + err := oc.Process() if err != nil { return err } @@ -334,7 +337,10 @@ func autoConfig(configFn string) error { IP: ocl.IP.To4(), Hostname: ocl.Hostname, } - ds.AddStaticLeaseWithFlags(l, false) + err = ds.AddStaticLeaseWithFlags(l, false) + if err != nil { + continue + } log.Debug("Static DHCP lease: %s -> %s (%s)", l.HWAddr, l.IP, l.Hostname) }