diff options
Diffstat (limited to 'internal/server')
-rw-r--r-- | internal/server/tcp.go | 17 | ||||
-rw-r--r-- | internal/server/tls.go | 10 |
2 files changed, 7 insertions, 20 deletions
diff --git a/internal/server/tcp.go b/internal/server/tcp.go index 4dc3314..b38da3d 100644 --- a/internal/server/tcp.go +++ b/internal/server/tcp.go @@ -1,26 +1,13 @@ package server import ( - "net" - "website/internal/listenfd" - "website/internal/log" - - "github.com/pkg/errors" ) func (s *Server) serveTCP() error { - l, err := listenfd.GetListener(0) + l, err := listenfd.GetListener(0, s.Addr) if err != nil { - log.Warn("could not create listener from listenfd", "error", err) - } - - log.Debug("listener from listenfd?", "passed", l != nil) - if l == nil { - l, err = net.Listen("tcp", s.Addr) - if err != nil { - return errors.Wrap(err, "could not create listener") - } + return err } return s.Serve(l) diff --git a/internal/server/tls.go b/internal/server/tls.go index f538f88..565958f 100644 --- a/internal/server/tls.go +++ b/internal/server/tls.go @@ -2,11 +2,11 @@ package server import ( "context" - "crypto/tls" "crypto/x509" "net" "net/http" "strconv" + "website/internal/listenfd" "website/internal/log" "github.com/ardanlabs/conf/v3" @@ -95,8 +95,8 @@ func (s *Server) serveTLS() (err error) { tlsConfig := cfg.TLSConfig() tlsConfig.NextProtos = append([]string{"h2", "http/1.1"}, tlsConfig.NextProtos...) - sln, err := tls.Listen( - "tcp", + sln, err := listenfd.GetListenerTLS( + 0, net.JoinHostPort(s.runtimeConfig.ListenAddress, strconv.Itoa(s.runtimeConfig.TLSPort)), tlsConfig, ) @@ -104,8 +104,8 @@ func (s *Server) serveTLS() (err error) { return errors.Wrap(err, "could not bind tls socket") } - ln, err := net.Listen( - "tcp", + ln, err := listenfd.GetListener( + 1, net.JoinHostPort(s.runtimeConfig.ListenAddress, strconv.Itoa(s.runtimeConfig.Port)), ) if err != nil { |