all: watch link state on Linux using netlink

So we can detect changed to link and trigger re-bootstrap.
This commit is contained in:
Cuong Manh Le
2023-05-13 12:24:16 +07:00
committed by Cuong Manh Le
parent 56d8dc865f
commit 5cad0d6be1
8 changed files with 60 additions and 43 deletions
+4
View File
@@ -9,6 +9,7 @@ import (
"net/url"
"os"
"strings"
"sync"
"sync/atomic"
"time"
@@ -127,6 +128,7 @@ type UpstreamConfig struct {
u *url.URL `mapstructure:"-" toml:"-"`
g singleflight.Group
mu sync.Mutex
bootstrapIPs []string
nextBootstrapIP atomic.Uint32
}
@@ -268,6 +270,8 @@ func (uc *UpstreamConfig) setupDOHTransport() {
}
func (uc *UpstreamConfig) setupDOHTransportWithoutPingUpstream() {
uc.mu.Lock()
defer uc.mu.Unlock()
uc.transport = http.DefaultTransport.(*http.Transport).Clone()
uc.transport.IdleConnTimeout = 5 * time.Second
uc.transport.TLSClientConfig = &tls.Config{RootCAs: uc.certPool}