multi: let subserver manager handle disabled sub-server

Modify the sub-server Manager's AddServer method to take an `enabled`
boolean so that it can handle what to do with a disabled sub-server.
This will come into play in a future commit which adds a status server.
This commit is contained in:
Elle Mouton 2023-07-19 13:34:40 +02:00
parent 59ebfe4e93
commit b0931f49b0
No known key found for this signature in database
GPG key ID: D7D916376026F177
2 changed files with 16 additions and 8 deletions

View file

@ -45,15 +45,23 @@ func NewManager(permsMgr *perms.Manager) *Manager {
}
// AddServer adds a new subServer to the manager's set.
func (s *Manager) AddServer(ss SubServer) {
func (s *Manager) AddServer(ss SubServer, enable bool) {
// If the sub-server has explicitly been disabled, then we don't add it
// to the set of servers tracked by the Manager.
if !enable {
return
}
s.mu.Lock()
defer s.mu.Unlock()
// Add the enabled server to the set of servers tracked by the Manager.
s.servers = append(s.servers, &subServerWrapper{
SubServer: ss,
quit: make(chan struct{}),
})
// Register the sub-server's permissions with the permission manager.
s.permsMgr.RegisterSubServer(
ss.Name(), ss.Permissions(), ss.WhiteListedURLs(),
)