diff options
author | pg9182 <96569817+pg9182@users.noreply.github.com> | 2023-03-08 19:48:51 -0500 |
---|---|---|
committer | pg9182 <96569817+pg9182@users.noreply.github.com> | 2023-04-17 14:49:47 -0400 |
commit | ff19827321355eaa51c950717c9190f0a3f11317 (patch) | |
tree | 3f53fce22506614ad95346ccad2d0527c85e60f0 /pkg/atlas | |
parent | 40bf23b43937053ca7fba5695eb5a7b4dfd814de (diff) | |
download | Atlas-ff19827321355eaa51c950717c9190f0a3f11317.tar.gz Atlas-ff19827321355eaa51c950717c9190f0a3f11317.zip |
pkg/atlas: Add support for configuring UDP listen address
Diffstat (limited to 'pkg/atlas')
-rw-r--r-- | pkg/atlas/config.go | 4 | ||||
-rw-r--r-- | pkg/atlas/server.go | 4 |
2 files changed, 7 insertions, 1 deletions
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 { |