Skip to content

Commit daa7057

Browse files
committed
Add secure telnet port configuration and improve web display
Added: - SecureTelnetPort configuration field to Network struct - SecureTelnetPorts tracking in web Stats struct - Secure telnet port parsing in world stats update - Conditional display of secure telnet ports on homepage Changed: - Web request logging to show real client IPs behind proxy - Underlay width for ports display reduced for better visual balance
1 parent 8d48b19 commit daa7057

File tree

5 files changed

+57
-14
lines changed

5 files changed

+57
-14
lines changed

_datafiles/config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,11 @@ Network:
383383
# The port the server listens on for telnet connections. Listen on multiple
384384
# ports by separating them with commas. For example, [33333, 33334, 33335]
385385
TelnetPort: [33333, 44444]
386+
# - SecureTelnetPort -
387+
# The port the server listens on for secure telnet connections. Listen on multiple
388+
# ports by separating them with commas. For example, [33334, 33335]
389+
# Set to [0] to disable secure telnet.
390+
SecureTelnetPort: [0]
386391
# - LocalPort -
387392
# A port that can only be accessed via localhost, but will not limit based on connection count
388393
LocalPort: 9999

_datafiles/html/public/index.html

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,40 @@
11
{{template "header" .}}
22

3-
<div class="play-button">
4-
<a href="/webclient">
5-
<img src="{{ .CONFIG.FilePaths.WebCDNLocation }}/static/images/btn_play.png" alt="Play" />
6-
</a>
3+
<div class="play-button">
4+
<a href="/webclient">
5+
<img
6+
src="{{ .CONFIG.FilePaths.WebCDNLocation }}/static/images/btn_play.png"
7+
alt="Play"
8+
/>
9+
</a>
10+
</div>
11+
<p>&nbsp;</p>
12+
<div style="text-align: center;">
13+
<div class="underlay" style="width: auto; display: inline-block; padding-left: 20px; padding-right: 20px;">
14+
<div style="display: table; margin: 0 auto">
15+
<div style="display: table-row">
16+
<h3 style="display: table-cell; text-align: right; padding-right: 0.5em">
17+
Telnet Port{{ if gt (len .CONFIG.Network.TelnetPort) 1 }}s{{end}}
18+
</h3>
19+
<h3 style="display: table-cell; text-align: left">
20+
: {{ join .CONFIG.Network.TelnetPort ", " }}
21+
</h3>
22+
</div>
23+
{{ if and .CONFIG.Network.SecureTelnetPort (ne (index
24+
.CONFIG.Network.SecureTelnetPort 0) "0") }}
25+
<br />
26+
<div style="display: table-row">
27+
<h3 style="display: table-cell; text-align: right; padding-right: 0.5em">
28+
Secure Telnet Port{{ if gt (len .CONFIG.Network.SecureTelnetPort) 1
29+
}}s{{end}}
30+
</h3>
31+
<h3 style="display: table-cell; text-align: left">
32+
: {{ join .CONFIG.Network.SecureTelnetPort ", " }}
33+
</h3>
34+
</div>
35+
{{ end }}
736
</div>
8-
<p>&nbsp;</p>
9-
<div class="underlay">
10-
<h3>Telnet Port{{ if gt (len .CONFIG.Network.TelnetPort) 1 }}s{{end}}: {{ join .CONFIG.Network.TelnetPort ", " }}</h3>
1137
</div>
38+
</div>
1239

13-
{{template "footer" .}}
40+
{{template "footer" .}}

internal/configs/config.network.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package configs
33
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
6+
SecureTelnetPort ConfigSliceString `yaml:"SecureTelnetPort"` // One or more Ports used to accept secure telnet connections
67
LocalPort ConfigInt `yaml:"LocalPort"` // Port used for admin connections, localhost only
78
HttpPort ConfigInt `yaml:"HttpPort"` // Port used for web requests
89
HttpsPort ConfigInt `yaml:"HttpsPort"` // Port used for web https requests

internal/web/stats.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,19 @@ import (
77
)
88

99
type Stats struct {
10-
OnlineUsers []users.OnlineInfo
11-
TelnetPorts []int
12-
WebSocketPort int
10+
OnlineUsers []users.OnlineInfo
11+
TelnetPorts []int
12+
SecureTelnetPorts []int
13+
WebSocketPort int
1314
}
1415

1516
var (
1617
statsLock = sync.RWMutex{}
1718
serverStats = Stats{
18-
WebSocketPort: 0,
19-
OnlineUsers: []users.OnlineInfo{},
20-
TelnetPorts: []int{},
19+
WebSocketPort: 0,
20+
OnlineUsers: []users.OnlineInfo{},
21+
TelnetPorts: []int{},
22+
SecureTelnetPorts: []int{},
2123
}
2224
)
2325

@@ -41,4 +43,5 @@ func (s *Stats) Reset() {
4143
s.WebSocketPort = 0
4244
s.OnlineUsers = []users.OnlineInfo{}
4345
s.TelnetPorts = []int{}
46+
s.SecureTelnetPorts = []int{}
4447
}

world.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,13 @@ func (w *World) UpdateStats() {
10571057
}
10581058
}
10591059

1060+
for _, t := range c.SecureTelnetPort {
1061+
p, _ := strconv.Atoi(t)
1062+
if p > 0 {
1063+
s.SecureTelnetPorts = append(s.SecureTelnetPorts, p)
1064+
}
1065+
}
1066+
10601067
s.WebSocketPort = int(c.HttpPort)
10611068

10621069
web.UpdateStats(s)

0 commit comments

Comments
 (0)