Skip to content

Commit b67b066

Browse files
committed
Change SecureTelnetLocalPort to support multiple ports
- Changed SecureTelnetLocalPort from single ConfigInt to ConfigSliceString - Now supports multiple secure local ports: [9998, 9997] - Updated connection detection to check all ports in the slice - Allows multiple TLS proxies to forward to different local ports - Consistent with SecureTelnetPort being a slice
1 parent 65c9814 commit b67b066

File tree

4 files changed

+22
-15
lines changed

4 files changed

+22
-15
lines changed

_datafiles/config.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -390,11 +390,12 @@ Network:
390390
# Set to [0] to disable display.
391391
SecureTelnetPort: [0]
392392
# - SecureTelnetLocalPort -
393-
# Internal port where TLS proxy forwards secure connections (localhost only).
394-
# Game server binds to this port to receive forwarded TLS connections.
395-
# Example: 9998 if stunnel4 forwards to localhost:9998
396-
# Set to 0 to disable.
397-
SecureTelnetLocalPort: 0
393+
# Internal ports where TLS proxy forwards secure connections (localhost only).
394+
# Game server binds to these ports to receive forwarded TLS connections.
395+
# Example: [9998] if stunnel4 forwards to localhost:9998
396+
# Multiple ports supported: [9998, 9997] for multiple TLS proxies
397+
# Set to [0] to disable.
398+
SecureTelnetLocalPort: [0]
398399
# - LocalPort -
399400
# A port that can only be accessed via localhost, but will not limit based on connection count
400401
LocalPort: 9999

internal/configs/config.network.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ type Network struct {
44
MaxTelnetConnections ConfigInt `yaml:"MaxTelnetConnections"` // Maximum number of telnet connections to accept
55
TelnetPort ConfigSliceString `yaml:"TelnetPort"` // One or more Ports used to accept telnet connections
66
SecureTelnetPort ConfigSliceString `yaml:"SecureTelnetPort"` // Display-only: external ports where users connect via TLS
7-
SecureTelnetLocalPort ConfigInt `yaml:"SecureTelnetLocalPort"` // Internal port where TLS proxy forwards to (localhost only)
7+
SecureTelnetLocalPort ConfigSliceString `yaml:"SecureTelnetLocalPort"` // Internal ports where TLS proxy forwards to (localhost only)
88
LocalPort ConfigInt `yaml:"LocalPort"` // Port used for admin connections, localhost only
99
HttpPort ConfigInt `yaml:"HttpPort"` // Port used for web requests
1010
HttpsPort ConfigInt `yaml:"HttpsPort"` // Port used for web https requests

internal/users/userrecord.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -625,15 +625,19 @@ func (u *UserRecord) GetOnlineInfo() OnlineInfo {
625625
if connections.IsWebsocket(u.connectionId) {
626626
connectionType = "Web"
627627
} else {
628-
// Check if connected through the secure telnet local port (where TLS proxy forwards)
628+
// Check if connected through a secure telnet local port (where TLS proxy forwards)
629629
port := connections.GetConnectionPort(u.connectionId)
630630
networkConfig := configs.GetNetworkConfig()
631631

632632
// Debug logging
633-
mudlog.Debug("Connection type check", "connectionId", u.connectionId, "port", port, "secureLocalPort", networkConfig.SecureTelnetLocalPort)
633+
mudlog.Debug("Connection type check", "connectionId", u.connectionId, "port", port, "secureLocalPorts", networkConfig.SecureTelnetLocalPort)
634634

635-
if networkConfig.SecureTelnetLocalPort > 0 && port == int(networkConfig.SecureTelnetLocalPort) {
636-
connectionType = "TLS"
635+
for _, securePortStr := range networkConfig.SecureTelnetLocalPort {
636+
securePort, _ := strconv.Atoi(securePortStr)
637+
if securePort > 0 && port == securePort {
638+
connectionType = "TLS"
639+
break
640+
}
637641
}
638642
}
639643

main.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -271,11 +271,13 @@ func main() {
271271
TelnetListenOnPort(`127.0.0.1`, int(c.Network.LocalPort), &wg, 0)
272272
}
273273

274-
// Secure telnet local port - where TLS proxy forwards to
275-
if c.Network.SecureTelnetLocalPort > 0 {
276-
mudlog.Info("Telnet", "stage", "Listening on secure local port (localhost only)", "port", c.Network.SecureTelnetLocalPort)
277-
// Same as LocalPort - localhost only, no connection limit
278-
TelnetListenOnPort(`127.0.0.1`, int(c.Network.SecureTelnetLocalPort), &wg, 0)
274+
// Secure telnet local ports - where TLS proxy forwards to
275+
for _, port := range c.Network.SecureTelnetLocalPort {
276+
if p, err := strconv.Atoi(port); err == nil && p > 0 {
277+
mudlog.Info("Telnet", "stage", "Listening on secure local port (localhost only)", "port", p)
278+
// Same as LocalPort - localhost only, no connection limit
279+
TelnetListenOnPort(`127.0.0.1`, p, &wg, 0)
280+
}
279281
}
280282

281283
go worldManager.InputWorker(workerShutdownChan, &wg)

0 commit comments

Comments
 (0)