From e6a415310f7748ee8f177f99df25c72a4e8ba919 Mon Sep 17 00:00:00 2001 From: Houmgaor Date: Sun, 22 Mar 2026 21:25:55 +0100 Subject: [PATCH] fix(startup): detect duplicate channel ports before binding Catches misconfigured port collisions early and reports which channel already claimed the port, rather than failing with a generic OS error. --- main.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/main.go b/main.go index 8014c85d4..47c552eb7 100644 --- a/main.go +++ b/main.go @@ -336,6 +336,7 @@ func main() { si := 0 ci := 0 count := 1 + seenPorts := make(map[uint16]string) for j, ee := range config.Entrance.Entries { for i, ce := range ee.Channels { sid := (4096 + si*256) + (16 + ci) @@ -345,6 +346,13 @@ func main() { count++ continue } + if prev, exists := seenPorts[ce.Port]; exists { + preventClose(config, fmt.Sprintf("Channel %d: port %d already used by %s", count, ce.Port, prev)) + ci++ + count++ + continue + } + seenPorts[ce.Port] = fmt.Sprintf("channel %d", count) c := *channelserver.NewServer(&channelserver.Config{ ID: uint16(sid), Logger: logger.Named("channel-" + fmt.Sprint(count)),