aboutsummaryrefslogtreecommitdiff
path: root/hotline/tracker.go
diff options
context:
space:
mode:
authorJeff Halter <868228+jhalter@users.noreply.github.com>2025-11-25 10:30:30 -0800
committerJeff Halter <868228+jhalter@users.noreply.github.com>2025-11-25 10:31:39 -0800
commit8ddb9bb228389b198a76d6df21de005da4fad66b (patch)
treee6e1d8de46beaf8e79fc8aa7edfe4c7263799fe9 /hotline/tracker.go
parentab16c7d82c8381a4df80fef4b2fe81e7ff23dad8 (diff)
Add TLS port field to tracker registration protocol
Repurpose the previously unused 2-byte field in the tracker protocol to advertise the server's TLS port. This allows clients to discover which servers support TLS connections. Note: currently only the official, original, 1990's Tracker software sends this server provided 2-byte field to tracker clients. I'm adding this to Mobius in the hope that the modern day trackers might update their behavior to match the original software, which would put these unused 2 bytes to a useful purpose.
Diffstat (limited to 'hotline/tracker.go')
-rw-r--r--hotline/tracker.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/hotline/tracker.go b/hotline/tracker.go
index bfba69d..ee4fc05 100644
--- a/hotline/tracker.go
+++ b/hotline/tracker.go
@@ -15,6 +15,7 @@ import (
type TrackerRegistration struct {
Port [2]byte // Server's listening TCP port number
UserCount int // Number of users connected to this particular server
+ TLSPort [2]byte // TLSPort
PassID [4]byte // Random number generated by the server
Name string // Server Name
Description string // Description of the server
@@ -32,7 +33,7 @@ func (tr *TrackerRegistration) Read(p []byte) (int, error) {
[]byte{0x00, 0x01}, // Magic number, always 1
tr.Port[:],
userCount,
- []byte{0x00, 0x00}, // Magic number, always 0
+ tr.TLSPort[:],
tr.PassID[:],
[]byte{uint8(len(tr.Name))},
[]byte(tr.Name),
@@ -114,7 +115,7 @@ type ServerRecord struct {
IPAddr [4]byte
Port [2]byte
NumUsers [2]byte // Number of users connected to this particular server
- Unused [2]byte
+ TLSPort [2]byte
NameSize byte // Length of Name string
Name []byte // Server Name
DescriptionSize byte
@@ -182,7 +183,7 @@ func GetListing(conn io.ReadWriteCloser) ([]ServerRecord, error) {
func readServerRecord(reader *bufio.Reader) (ServerRecord, error) {
var srv ServerRecord
- // Read fixed header: IP (4) + Port (2) + NumUsers (2) + Unused (2) = 10 bytes
+ // Read fixed header: IP (4) + Port (2) + NumUsers (2) + TLSPort (2) = 10 bytes
header := make([]byte, 10)
if _, err := io.ReadFull(reader, header); err != nil {
return srv, fmt.Errorf("failed to read server header: %w", err)
@@ -191,7 +192,7 @@ func readServerRecord(reader *bufio.Reader) (ServerRecord, error) {
copy(srv.IPAddr[:], header[0:4])
copy(srv.Port[:], header[4:6])
copy(srv.NumUsers[:], header[6:8])
- copy(srv.Unused[:], header[8:10])
+ copy(srv.TLSPort[:], header[8:10])
// Read name size
nameSizeByte, err := reader.ReadByte()