mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-23 16:13:04 +01:00
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.
This commit is contained in:
8
main.go
8
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)),
|
||||
|
||||
Reference in New Issue
Block a user