@@ -34,6 +34,7 @@ const (
3434 Shutdown
3535)
3636
37+ //nolint:interfacebloat
3738type IServer interface {
3839 OnBoot () Action
3940 OnOpen (conn * ConnWrapper ) ([]byte , Action )
@@ -44,7 +45,10 @@ type IServer interface {
4445 Run () * gerr.GatewayDError
4546 Shutdown ()
4647 IsRunning () bool
48+ IsTLSEnabled () bool
4749 CountConnections () int
50+ GetProxyForConnection (conn * ConnWrapper ) (IProxy , bool )
51+ RemoveConnectionFromMap (conn * ConnWrapper )
4852}
4953
5054type Server struct {
@@ -69,12 +73,13 @@ type Server struct {
6973 KeyFile string
7074 HandshakeTimeout time.Duration
7175
72- listener net.Listener
73- host string
74- port int
75- connections uint32
76- running * atomic.Bool
77- stopServer chan struct {}
76+ listener net.Listener
77+ host string
78+ port int
79+ connections uint32
80+ running * atomic.Bool
81+ isTLSEnabled * atomic.Bool
82+ stopServer chan struct {}
7883
7984 // loadbalancer
8085 loadbalancerStrategy LoadBalancerStrategy
@@ -543,6 +548,9 @@ func (s *Server) Run() *gerr.GatewayDError {
543548 return gerr .ErrCastFailed .Wrap (origErr )
544549 }
545550
551+ s .isTLSEnabled = & atomic.Bool {}
552+ s .running = & atomic.Bool {}
553+
546554 go func (server * Server ) {
547555 <- server .stopServer
548556 server .OnShutdown ()
@@ -582,6 +590,7 @@ func (s *Server) Run() *gerr.GatewayDError {
582590 return gerr .ErrGetTLSConfigFailed .Wrap (origErr )
583591 }
584592 s .Logger .Info ().Msg ("TLS is enabled" )
593+ s .isTLSEnabled .Store (true )
585594 } else {
586595 s .Logger .Debug ().Msg ("TLS is disabled" )
587596 }
@@ -767,6 +776,14 @@ func (s *Server) CountConnections() int {
767776 return int (s .connections )
768777}
769778
779+ // IsTLSEnabled returns true if TLS is enabled.
780+ func (s * Server ) IsTLSEnabled () bool {
781+ if s .isTLSEnabled == nil {
782+ return false
783+ }
784+ return s .isTLSEnabled .Load ()
785+ }
786+
770787// GetProxyForConnection returns the proxy associated with the given connection.
771788func (s * Server ) GetProxyForConnection (conn * ConnWrapper ) (IProxy , bool ) {
772789 proxy , exists := s .connectionToProxyMap .Load (conn )
0 commit comments