Skip to content

Commit a1e72a9

Browse files
author
Datanoise
committed
feat: prevent multiple MPD servers from using the same port
1 parent 297d2cc commit a1e72a9

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

relay/streamer.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,16 @@ func (sm *StreamerManager) StartStreamer(name, mount, musicDir string, loop bool
272272
}
273273

274274
if mpdEnabled && mpdPort != "" {
275+
// Check for port conflicts within our own instances
276+
for _, inst := range sm.instances {
277+
inst.mu.RLock()
278+
if inst.MPDServer != nil && inst.MPDServer.Port == mpdPort {
279+
inst.mu.RUnlock()
280+
return nil, fmt.Errorf("MPD port %s is already in use by AutoDJ %s", mpdPort, inst.Name)
281+
}
282+
inst.mu.RUnlock()
283+
}
284+
275285
s.MPDServer = NewMPDServer(mpdPort, mpdPassword, s)
276286
if err := s.MPDServer.Start(); err != nil {
277287
logrus.WithError(err).Errorf("Failed to start MPD server for AutoDJ %s", name)

0 commit comments

Comments
 (0)