mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-02 03:38:42 -07:00
Merge pull request #31 from apcera/add-addr-helper
Added Server.Addr() helper to allow querying of the server's bound address
This commit is contained in:
@@ -480,3 +480,13 @@ func (s *Server) NumSubscriptions() uint32 {
|
||||
stats := s.sl.Stats()
|
||||
return stats.NumSubs
|
||||
}
|
||||
|
||||
// Addr will return the net.Addr object for the current listener.
|
||||
func (s *Server) Addr() net.Addr {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
if s.listener == nil {
|
||||
return nil
|
||||
}
|
||||
return s.listener.Addr()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user