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
|
||||
|
||||
import (
|
||||
"golang.org/x/exp/inotify"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net"
|
||||
|
@ -139,21 +138,12 @@ func sendGDL90(msg []byte) {
|
|||
}
|
||||
|
||||
func monitorDHCPLeases() {
|
||||
watcher, err := inotify.NewWatcher()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = watcher.AddWatch(dhcp_lease_file, inotify.IN_MODIFY)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
//TODO: inotify or dhcp event hook.
|
||||
timer := time.NewTicker(30 * time.Second)
|
||||
for {
|
||||
select {
|
||||
case <-watcher.Event:
|
||||
log.Println("file modified, attempting to refresh DHCP")
|
||||
case <-timer.C:
|
||||
refreshConnectedClients()
|
||||
case err := <-watcher.Error:
|
||||
log.Println("error with DHCP file system watcher:", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue