1 parent
98b65945f6
commit
0b6dcbd547
13 files changed
+417
-68
No files matched your search
@@ -0,0 +1,35 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
)
|
||||
|
||||
func (a *App) watchAddressOverrides(ctx context.Context) {
|
||||
if a.zones == nil || a.blocks == nil {
|
||||
return
|
||||
}
|
||||
t := time.NewTicker(2 * time.Second)
|
||||
defer t.Stop()
|
||||
var last string
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case <-t.C:
|
||||
content, ok, err := a.zones.Data(ctx, "address-overrides.rpz")
|
||||
if err != nil || !ok || content == last {
|
||||
continue
|
||||
}
|
||||
a.overrideMu.Lock()
|
||||
a.blocks.SetManagedRPZ(content)
|
||||
if _, err := a.blocks.RefreshAll(ctx); err == nil {
|
||||
if a.cache != nil {
|
||||
a.cache.Flush()
|
||||
}
|
||||
last = content
|
||||
}
|
||||
a.overrideMu.Unlock()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user