mirror of
https://github.com/netbirdio/netbird.git
synced 2024-12-14 10:50:45 +01:00
parent
eea02a4220
commit
589456a393
4
.github/workflows/golangci-lint.yml
vendored
4
.github/workflows/golangci-lint.yml
vendored
@ -46,7 +46,7 @@ jobs:
|
|||||||
if: matrix.os == 'ubuntu-latest'
|
if: matrix.os == 'ubuntu-latest'
|
||||||
run: sudo apt update && sudo apt install -y -q libgtk-3-dev libayatana-appindicator3-dev libgl1-mesa-dev xorg-dev libpcap-dev
|
run: sudo apt update && sudo apt install -y -q libgtk-3-dev libayatana-appindicator3-dev libgl1-mesa-dev xorg-dev libpcap-dev
|
||||||
- name: golangci-lint
|
- name: golangci-lint
|
||||||
uses: golangci/golangci-lint-action@v3
|
uses: golangci/golangci-lint-action@v4
|
||||||
with:
|
with:
|
||||||
version: latest
|
version: latest
|
||||||
args: --timeout=12m
|
args: --timeout=12m --out-format colored-line-number
|
||||||
|
@ -14,9 +14,14 @@ type MockServer struct {
|
|||||||
StopFunc func()
|
StopFunc func()
|
||||||
UpdateDNSServerFunc func(serial uint64, update nbdns.Config) error
|
UpdateDNSServerFunc func(serial uint64, update nbdns.Config) error
|
||||||
RegisterHandlerFunc func([]string, dns.Handler) error
|
RegisterHandlerFunc func([]string, dns.Handler) error
|
||||||
|
UnregisterHandlerFunc func([]string) error
|
||||||
DeregisterHandlerFunc func([]string) error
|
DeregisterHandlerFunc func([]string) error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *MockServer) UnregisterHandler(domains []string) error {
|
||||||
|
panic("implement me")
|
||||||
|
}
|
||||||
|
|
||||||
func (m *MockServer) RegisterHandler(domains []string, handler dns.Handler) error {
|
func (m *MockServer) RegisterHandler(domains []string, handler dns.Handler) error {
|
||||||
if m.RegisterHandlerFunc != nil {
|
if m.RegisterHandlerFunc != nil {
|
||||||
return m.RegisterHandlerFunc(domains, handler)
|
return m.RegisterHandlerFunc(domains, handler)
|
||||||
|
@ -1566,15 +1566,13 @@ func (e *Engine) updateDNSForwarder(domains []string) {
|
|||||||
log.Infof("update domain router service for domains: %v", domains)
|
log.Infof("update domain router service for domains: %v", domains)
|
||||||
e.dnsForwardMgr.UpdateDomains(domains)
|
e.dnsForwardMgr.UpdateDomains(domains)
|
||||||
}
|
}
|
||||||
} else {
|
} else if e.dnsForwardMgr != nil {
|
||||||
if e.dnsForwardMgr != nil {
|
|
||||||
log.Infof("disable domain router service")
|
log.Infof("disable domain router service")
|
||||||
if err := e.dnsForwardMgr.Stop(context.Background()); err != nil {
|
if err := e.dnsForwardMgr.Stop(context.Background()); err != nil {
|
||||||
log.Errorf("failed to stop DNS forward: %v", err)
|
log.Errorf("failed to stop DNS forward: %v", err)
|
||||||
}
|
}
|
||||||
e.dnsForwardMgr = nil
|
e.dnsForwardMgr = nil
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// isChecksEqual checks if two slices of checks are equal.
|
// isChecksEqual checks if two slices of checks are equal.
|
||||||
|
@ -394,8 +394,8 @@ func TestEngine_UpdateNetworkMap(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(engine.peerConns) != c.expectedLen {
|
if len(engine.peerStore.PeersPubKey()) != c.expectedLen {
|
||||||
t.Errorf("expecting Engine.peerConns to be of size %d, got %d", c.expectedLen, len(engine.peerConns))
|
t.Errorf("expecting Engine.peerConns to be of size %d, got %d", c.expectedLen, len(engine.peerStore.PeersPubKey()))
|
||||||
}
|
}
|
||||||
|
|
||||||
if engine.networkSerial != c.expectedSerial {
|
if engine.networkSerial != c.expectedSerial {
|
||||||
@ -403,7 +403,7 @@ func TestEngine_UpdateNetworkMap(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, p := range c.expectedPeers {
|
for _, p := range c.expectedPeers {
|
||||||
conn, ok := engine.peerConns[p.GetWgPubKey()]
|
conn, ok := engine.peerStore.PeerConn(p.GetWgPubKey())
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Errorf("expecting Engine.peerConns to contain peer %s", p)
|
t.Errorf("expecting Engine.peerConns to contain peer %s", p)
|
||||||
}
|
}
|
||||||
@ -1240,7 +1240,8 @@ func getConnectedPeers(e *Engine) int {
|
|||||||
e.syncMsgMux.Lock()
|
e.syncMsgMux.Lock()
|
||||||
defer e.syncMsgMux.Unlock()
|
defer e.syncMsgMux.Unlock()
|
||||||
i := 0
|
i := 0
|
||||||
for _, conn := range e.peerConns {
|
for _, id := range e.peerStore.PeersPubKey() {
|
||||||
|
conn, _ := e.peerStore.PeerConn(id)
|
||||||
if conn.Status() == peer.StatusConnected {
|
if conn.Status() == peer.StatusConnected {
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
@ -1252,5 +1253,5 @@ func getPeers(e *Engine) int {
|
|||||||
e.syncMsgMux.Lock()
|
e.syncMsgMux.Lock()
|
||||||
defer e.syncMsgMux.Unlock()
|
defer e.syncMsgMux.Unlock()
|
||||||
|
|
||||||
return len(e.peerConns)
|
return len(e.peerStore.PeersPubKey())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user