mirror of
https://github.com/slackhq/nebula.git
synced 2026-05-16 04:47:38 +02:00
Some checks failed
gofmt / Run gofmt (push) Failing after 2s
smoke-extra / freebsd-amd64 (push) Failing after 2s
smoke-extra / linux-amd64-ipv6disable (push) Failing after 3s
smoke-extra / netbsd-amd64 (push) Failing after 3s
smoke-extra / openbsd-amd64 (push) Failing after 3s
smoke-extra / linux-386 (push) Failing after 3s
smoke / Run multi node smoke test (push) Failing after 2s
Build and test / Build all and test on ubuntu-linux (push) Failing after 3s
Build and test / Build and test on linux with boringcrypto (push) Failing after 2s
Build and test / Build and test on linux with pkcs11 (push) Failing after 2s
smoke-extra / Run windows smoke test (push) Has been cancelled
Build and test / Build and test on macos-latest (push) Has been cancelled
Build and test / Build and test on windows-latest (push) Has been cancelled
58 lines
1.3 KiB
Go
58 lines
1.3 KiB
Go
//go:build (amd64 || arm64) && !e2e_testing
|
|
// +build amd64 arm64
|
|
// +build !e2e_testing
|
|
|
|
package udp
|
|
|
|
import (
|
|
"log/slog"
|
|
"sync"
|
|
|
|
"github.com/slackhq/nebula/config"
|
|
"github.com/slackhq/nebula/wfp"
|
|
)
|
|
|
|
// wrapWithWDFBypass wraps a Conn so that the first ReloadConfig consults listen.windows_bypass_wdf
|
|
// and installs a WFP PERMIT filter for the listener's bound UDP port. The session is released when Close runs.
|
|
func wrapWithWDFBypass(l *slog.Logger, conn Conn) Conn {
|
|
return &bypassConn{Conn: conn, l: l}
|
|
}
|
|
|
|
type bypassConn struct {
|
|
Conn
|
|
|
|
l *slog.Logger
|
|
installOnce sync.Once
|
|
session *wfp.Session
|
|
}
|
|
|
|
func (b *bypassConn) ReloadConfig(c *config.C) {
|
|
b.installOnce.Do(func() {
|
|
if !c.GetBool("listen.windows_bypass_wdf", true) {
|
|
return
|
|
}
|
|
addr, err := b.Conn.LocalAddr()
|
|
if err != nil {
|
|
b.l.Warn("Failed to query listener port for WFP bypass", "error", err)
|
|
return
|
|
}
|
|
s, err := wfp.PermitUDPPort(addr.Port())
|
|
if err != nil {
|
|
b.l.Warn("Failed to install WFP bypass filters for listener", "error", err)
|
|
return
|
|
}
|
|
b.l.Info("Installed WFP filters bypassing Windows Defender Firewall on UDP listener port",
|
|
"port", addr.Port())
|
|
b.session = s
|
|
})
|
|
b.Conn.ReloadConfig(c)
|
|
}
|
|
|
|
func (b *bypassConn) Close() error {
|
|
if b.session != nil {
|
|
b.session.Close()
|
|
b.session = nil
|
|
}
|
|
return b.Conn.Close()
|
|
}
|