kopia lustrzana https://github.com/cyoung/stratux
dhcpd removing files, causing refresh issues.
Reverting to timer method for now.pull/27/head
rodzic
8b4fea41f2
commit
e1e44010da
16
network.go
16
network.go
|
@ -1,7 +1,6 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"golang.org/x/exp/inotify"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
|
@ -139,21 +138,12 @@ func sendGDL90(msg []byte) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func monitorDHCPLeases() {
|
func monitorDHCPLeases() {
|
||||||
watcher, err := inotify.NewWatcher()
|
//TODO: inotify or dhcp event hook.
|
||||||
if err != nil {
|
timer := time.NewTicker(30 * time.Second)
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
err = watcher.AddWatch(dhcp_lease_file, inotify.IN_MODIFY)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-watcher.Event:
|
case <-timer.C:
|
||||||
log.Println("file modified, attempting to refresh DHCP")
|
|
||||||
refreshConnectedClients()
|
refreshConnectedClients()
|
||||||
case err := <-watcher.Error:
|
|
||||||
log.Println("error with DHCP file system watcher:", err)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue