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:
Derek Collison
2014-05-27 09:23:53 -07:00

View File

@@ -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()
}