diff --git a/cmd/logger.go b/cmd/logger.go index 3589577..e05245a 100644 --- a/cmd/logger.go +++ b/cmd/logger.go @@ -50,11 +50,14 @@ func NewAppLoggerToFile (id string, file_name string, max_size int64, rotate int f, err = os.OpenFile(file_name, os.O_CREATE | os.O_APPEND | os.O_WRONLY, 0666) if err != nil { return nil, err } - matched, _ = filepath.Match("/dev/*", file_name) - if matched { - // if the log file is under /dev, disable rotation - max_size = 0 - rotate = 0 + if os.PathSeparator == '/' { + // this check is performed only on systems where the path separator is /. + matched, _ = filepath.Match("/dev/*", file_name) + if matched { + // if the log file is under /dev, disable rotation + max_size = 0 + rotate = 0 + } } l = &AppLogger{ diff --git a/server-ctl.go b/server-ctl.go index 55be9ad..0b8ab92 100644 --- a/server-ctl.go +++ b/server-ctl.go @@ -34,6 +34,8 @@ type json_out_server_stats struct { ServerConns int64 `json:"server-conns"` ServerRoutes int64 `json:"server-routes"` ServerPeers int64 `json:"server-peers"` + + SshProxySessions int64 `json:"ssh-proxy-session"` } // ------------------------------------ @@ -402,6 +404,7 @@ func (ctl *server_ctl_stats) ServeHTTP(w http.ResponseWriter, req *http.Request) stats.ServerConns = s.stats.conns.Load() stats.ServerRoutes = s.stats.routes.Load() stats.ServerPeers = s.stats.peers.Load() + stats.SshProxySessions = s.stats.ssh_proxy_sessions.Load() status_code = http.StatusOK; w.WriteHeader(status_code) if err = je.Encode(stats); err != nil { goto oops } diff --git a/server-proxy.go b/server-proxy.go index e0b1fa9..e1c6d86 100644 --- a/server-proxy.go +++ b/server-proxy.go @@ -572,6 +572,7 @@ func (pxy *server_proxy_ssh_ws) ServeWebsocket(ws *websocket.Conn) { var n int var err error + s.stats.ssh_proxy_sessions.Add(1) buf = make([]byte, 2048) for { n, err = out.Read(buf) @@ -589,6 +590,7 @@ func (pxy *server_proxy_ssh_ws) ServeWebsocket(ws *websocket.Conn) { } } } + s.stats.ssh_proxy_sessions.Add(-1) } }() diff --git a/server.go b/server.go index 1f39c56..4ae435d 100644 --- a/server.go +++ b/server.go @@ -69,6 +69,7 @@ type Server struct { conns atomic.Int64 routes atomic.Int64 peers atomic.Int64 + ssh_proxy_sessions atomic.Int64 } UnimplementedHoduServer @@ -998,6 +999,7 @@ func NewServer(ctx context.Context, logger Logger, ctl_addrs []string, rpc_addrs s.stats.conns.Store(0) s.stats.routes.Store(0) s.stats.peers.Store(0) + s.stats.ssh_proxy_sessions.Store(0) return &s, nil