From ff19827321355eaa51c950717c9190f0a3f11317 Mon Sep 17 00:00:00 2001 From: pg9182 <96569817+pg9182@users.noreply.github.com> Date: Wed, 8 Mar 2023 19:48:51 -0500 Subject: pkg/atlas: Add support for configuring UDP listen address --- pkg/atlas/config.go | 4 ++++ pkg/atlas/server.go | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/atlas/config.go b/pkg/atlas/config.go index 4dea103..ed108c1 100644 --- a/pkg/atlas/config.go +++ b/pkg/atlas/config.go @@ -31,6 +31,10 @@ type Config struct { // The addresses to listen on with TLS (comma-separated). AddrTLS []string `env:"ATLAS_ADDR_HTTPS"` + // The address to listen on and use to send connectionless packets. If the + // port is 0, a random one is chosen. + AddrUDP netip.AddrPort `env:"ATLAS_ADDR_UDP=:0"` + // Whether to trust Cloudflare headers like CF-Connecting-IP. // // This is not safe to use unless you: diff --git a/pkg/atlas/server.go b/pkg/atlas/server.go index 2956401..a713af8 100644 --- a/pkg/atlas/server.go +++ b/pkg/atlas/server.go @@ -41,6 +41,7 @@ type Server struct { Addr []string AddrTLS []string + AddrUDP netip.AddrPort Handler http.Handler Web http.Handler Redirects map[string]string @@ -73,6 +74,7 @@ func NewServer(c *Config) (*Server, error) { s.Addr = c.Addr s.AddrTLS = c.AddrTLS + s.AddrUDP = c.AddrUDP s.NotifySocket = c.NotifySocket @@ -916,7 +918,7 @@ func (s *Server) Run(ctx context.Context) error { }() } go func() { - errch <- s.API0.NSPkt.ListenAndServe(netip.AddrPort{}) + errch <- s.API0.NSPkt.ListenAndServe(s.AddrUDP) }() select { -- cgit v1.2.3