mirror of
https://github.com/mmatczuk/go-http-tunnel.git
synced 2026-05-15 14:16:17 -06:00
server: introduction of AutoSubscribe flag
This commit is contained in:
parent
1b22420dac
commit
c2c50bfba6
1 changed files with 6 additions and 1 deletions
|
|
@ -28,6 +28,9 @@ type ServerConfig struct {
|
|||
// Addr is TCP address to listen for client connections. If empty ":0"
|
||||
// is used.
|
||||
Addr string
|
||||
// AutoSubscribe if enabled will automatically subscribe new clients on
|
||||
// first call.
|
||||
AutoSubscribe bool
|
||||
// TLSConfig specifies the tls configuration to use with tls.Listener.
|
||||
TLSConfig *tls.Config
|
||||
// Listener specifies optional listener for client connections. If nil
|
||||
|
|
@ -207,7 +210,9 @@ func (s *Server) handleClient(conn net.Conn) {
|
|||
|
||||
logger = logger.With("identifier", identifier)
|
||||
|
||||
if !s.IsSubscribed(identifier) {
|
||||
if s.config.AutoSubscribe {
|
||||
s.Subscribe(identifier)
|
||||
} else if !s.IsSubscribed(identifier) {
|
||||
logger.Log(
|
||||
"level", 2,
|
||||
"msg", "unknown client",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue