refactor(config): rename package _config to config with cfg alias

The config package used `package _config` with a leading underscore,
which is unconventional in Go. Rename to `package config` (matching the
directory name) and use `cfg` as the standard import alias across all
93 importing files.
This commit is contained in:
Houmgaor
2026-02-21 13:20:15 +01:00
parent ad73f2fb55
commit f17cb96b52
98 changed files with 719 additions and 719 deletions

View File

@@ -5,7 +5,7 @@ import (
"testing"
"time"
"erupe-ce/config"
cfg "erupe-ce/config"
"github.com/DATA-DOG/go-sqlmock"
"github.com/jmoiron/sqlx"
"go.uber.org/zap"
@@ -304,7 +304,7 @@ func newTestServerWithMock(t *testing.T) (*Server, sqlmock.Sqlmock) {
server := &Server{
logger: zap.NewNop(),
db: sqlxDB,
erupeConfig: &_config.Config{},
erupeConfig: &cfg.Config{},
}
return server, mock

View File

@@ -4,7 +4,7 @@ import (
"erupe-ce/common/byteframe"
ps "erupe-ce/common/pascalstring"
"erupe-ce/common/stringsupport"
_config "erupe-ce/config"
cfg "erupe-ce/config"
"erupe-ce/common/gametime"
"fmt"
"strings"
@@ -83,7 +83,7 @@ func (s *Session) makeSignResponse(uid uint32) []byte {
bf.WriteBool(true) // Use uint16 GR, no reason not to
bf.WriteBytes(stringsupport.PaddedString(char.Name, 16, true)) // Character name
bf.WriteBytes(stringsupport.PaddedString(char.UnkDescString, 32, false)) // unk str
if s.server.erupeConfig.RealClientMode >= _config.G7 {
if s.server.erupeConfig.RealClientMode >= cfg.G7 {
bf.WriteUint16(char.GR)
bf.WriteUint8(0) // Unk
bf.WriteUint8(0) // Unk

View File

@@ -7,7 +7,7 @@ import (
"go.uber.org/zap"
_config "erupe-ce/config"
cfg "erupe-ce/config"
)
// TestMakeSignResponse_EmptyCapLinkValues verifies the crash is FIXED when CapLink.Values is empty
@@ -15,16 +15,16 @@ import (
// From erupe.log.1:659796 and 659853
// After fix: Should handle empty array gracefully with defaults
func TestMakeSignResponse_EmptyCapLinkValues(t *testing.T) {
config := &_config.Config{
DebugOptions: _config.DebugOptions{
CapLink: _config.CapLinkOptions{
config := &cfg.Config{
DebugOptions: cfg.DebugOptions{
CapLink: cfg.CapLinkOptions{
Values: []uint16{}, // Empty array - should now use defaults instead of panicking
Key: "test",
Host: "localhost",
Port: 8080,
},
},
GameplayOptions: _config.GameplayOptions{
GameplayOptions: cfg.GameplayOptions{
MezFesSoloTickets: 100,
MezFesGroupTickets: 100,
ClanMemberLimits: [][]uint8{
@@ -69,16 +69,16 @@ func TestMakeSignResponse_EmptyCapLinkValues(t *testing.T) {
// Previously panicked: runtime error: index out of range [1]
// After fix: Should handle small array gracefully with defaults
func TestMakeSignResponse_InsufficientCapLinkValues(t *testing.T) {
config := &_config.Config{
DebugOptions: _config.DebugOptions{
CapLink: _config.CapLinkOptions{
config := &cfg.Config{
DebugOptions: cfg.DebugOptions{
CapLink: cfg.CapLinkOptions{
Values: []uint16{51728}, // Only 1 element, code used to panic accessing [1]
Key: "test",
Host: "localhost",
Port: 8080,
},
},
GameplayOptions: _config.GameplayOptions{
GameplayOptions: cfg.GameplayOptions{
MezFesSoloTickets: 100,
MezFesGroupTickets: 100,
ClanMemberLimits: [][]uint8{
@@ -118,16 +118,16 @@ func TestMakeSignResponse_InsufficientCapLinkValues(t *testing.T) {
// Previously panicked: runtime error: index out of range [2/3/4]
// After fix: Should handle small array gracefully with defaults
func TestMakeSignResponse_MissingCapLinkValues234(t *testing.T) {
config := &_config.Config{
DebugOptions: _config.DebugOptions{
CapLink: _config.CapLinkOptions{
config := &cfg.Config{
DebugOptions: cfg.DebugOptions{
CapLink: cfg.CapLinkOptions{
Values: []uint16{100, 200}, // Only 2 elements, code used to panic accessing [2][3][4]
Key: "test",
Host: "localhost",
Port: 8080,
},
},
GameplayOptions: _config.GameplayOptions{
GameplayOptions: cfg.GameplayOptions{
MezFesSoloTickets: 100,
MezFesGroupTickets: 100,
ClanMemberLimits: [][]uint8{

View File

@@ -9,7 +9,7 @@ import (
"time"
"erupe-ce/common/byteframe"
_config "erupe-ce/config"
cfg "erupe-ce/config"
"erupe-ce/network"
"go.uber.org/zap"
@@ -75,7 +75,7 @@ func TestSessionStruct(t *testing.T) {
logger: logger,
server: nil,
rawConn: conn,
cryptConn: network.NewCryptConn(conn, _config.ZZ, nil),
cryptConn: network.NewCryptConn(conn, cfg.ZZ, nil),
}
if s.logger != logger {
@@ -132,7 +132,7 @@ func TestSessionMutex(t *testing.T) {
func TestHandlePacketUnknownRequest(t *testing.T) {
logger := zap.NewNop()
erupeConfig := &_config.Config{}
erupeConfig := &cfg.Config{}
server := &Server{
logger: logger,
@@ -144,7 +144,7 @@ func TestHandlePacketUnknownRequest(t *testing.T) {
logger: logger,
server: server,
rawConn: conn,
cryptConn: network.NewCryptConn(conn, _config.ZZ, nil),
cryptConn: network.NewCryptConn(conn, cfg.ZZ, nil),
}
bf := byteframe.NewByteFrame()
@@ -159,8 +159,8 @@ func TestHandlePacketUnknownRequest(t *testing.T) {
func TestHandlePacketWithDevModeLogging(t *testing.T) {
logger := zap.NewNop()
erupeConfig := &_config.Config{
DebugOptions: _config.DebugOptions{
erupeConfig := &cfg.Config{
DebugOptions: cfg.DebugOptions{
LogInboundMessages: true,
},
}
@@ -175,7 +175,7 @@ func TestHandlePacketWithDevModeLogging(t *testing.T) {
logger: logger,
server: server,
rawConn: conn,
cryptConn: network.NewCryptConn(conn, _config.ZZ, nil),
cryptConn: network.NewCryptConn(conn, cfg.ZZ, nil),
}
bf := byteframe.NewByteFrame()
@@ -202,7 +202,7 @@ func TestHandlePacketRequestTypes(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
logger := zap.NewNop()
erupeConfig := &_config.Config{}
erupeConfig := &cfg.Config{}
server := &Server{
logger: logger,
erupeConfig: erupeConfig,
@@ -213,7 +213,7 @@ func TestHandlePacketRequestTypes(t *testing.T) {
logger: logger,
server: server,
rawConn: conn,
cryptConn: network.NewCryptConn(conn, _config.ZZ, nil),
cryptConn: network.NewCryptConn(conn, cfg.ZZ, nil),
}
bf := byteframe.NewByteFrame()
@@ -323,7 +323,7 @@ func TestMockConnDeadlines(t *testing.T) {
func TestSessionWithCryptConn(t *testing.T) {
conn := newMockConn()
cryptConn := network.NewCryptConn(conn, _config.ZZ, nil)
cryptConn := network.NewCryptConn(conn, cfg.ZZ, nil)
if cryptConn == nil {
t.Fatal("NewCryptConn() returned nil")
@@ -341,8 +341,8 @@ func TestSessionWithCryptConn(t *testing.T) {
func TestSessionWorkWithDevModeLogging(t *testing.T) {
logger := zap.NewNop()
erupeConfig := &_config.Config{
DebugOptions: _config.DebugOptions{
erupeConfig := &cfg.Config{
DebugOptions: cfg.DebugOptions{
LogInboundMessages: true,
},
}
@@ -360,7 +360,7 @@ func TestSessionWorkWithDevModeLogging(t *testing.T) {
logger: logger,
server: server,
rawConn: serverConn,
cryptConn: network.NewCryptConn(serverConn, _config.ZZ, nil),
cryptConn: network.NewCryptConn(serverConn, cfg.ZZ, nil),
}
_ = clientConn.Close()
@@ -370,7 +370,7 @@ func TestSessionWorkWithDevModeLogging(t *testing.T) {
func TestSessionWorkWithEmptyRead(t *testing.T) {
logger := zap.NewNop()
erupeConfig := &_config.Config{}
erupeConfig := &cfg.Config{}
server := &Server{
logger: logger,
@@ -384,7 +384,7 @@ func TestSessionWorkWithEmptyRead(t *testing.T) {
logger: logger,
server: server,
rawConn: serverConn,
cryptConn: network.NewCryptConn(serverConn, _config.ZZ, nil),
cryptConn: network.NewCryptConn(serverConn, cfg.ZZ, nil),
}
_ = clientConn.Close()

View File

@@ -6,7 +6,7 @@ import (
"net"
"sync"
"erupe-ce/config"
cfg "erupe-ce/config"
"erupe-ce/network"
"github.com/jmoiron/sqlx"
"go.uber.org/zap"
@@ -16,14 +16,14 @@ import (
type Config struct {
Logger *zap.Logger
DB *sqlx.DB
ErupeConfig *_config.Config
ErupeConfig *cfg.Config
}
// Server is a MHF sign server.
type Server struct {
sync.Mutex
logger *zap.Logger
erupeConfig *_config.Config
erupeConfig *cfg.Config
db *sqlx.DB
listener net.Listener
isShuttingDown bool

View File

@@ -6,7 +6,7 @@ import (
"testing"
"time"
_config "erupe-ce/config"
cfg "erupe-ce/config"
"go.uber.org/zap"
)
@@ -263,8 +263,8 @@ func TestConfigFields(t *testing.T) {
func TestServerStartAndShutdown(t *testing.T) {
logger := zap.NewNop()
erupeConfig := &_config.Config{
Sign: _config.Sign{
erupeConfig := &cfg.Config{
Sign: cfg.Sign{
Port: 0,
},
}
@@ -305,8 +305,8 @@ func TestServerStartAndShutdown(t *testing.T) {
func TestServerStartWithInvalidPort(t *testing.T) {
logger := zap.NewNop()
erupeConfig := &_config.Config{
Sign: _config.Sign{
erupeConfig := &cfg.Config{
Sign: cfg.Sign{
Port: -1,
},
}
@@ -351,8 +351,8 @@ func TestServerMutex(t *testing.T) {
func TestServerShutdownIdempotent(t *testing.T) {
logger := zap.NewNop()
erupeConfig := &_config.Config{
Sign: _config.Sign{
erupeConfig := &cfg.Config{
Sign: cfg.Sign{
Port: 0,
},
}
@@ -379,8 +379,8 @@ func TestServerShutdownIdempotent(t *testing.T) {
func TestServerAcceptClientsExitsOnShutdown(t *testing.T) {
logger := zap.NewNop()
erupeConfig := &_config.Config{
Sign: _config.Sign{
erupeConfig := &cfg.Config{
Sign: cfg.Sign{
Port: 0,
},
}
@@ -411,8 +411,8 @@ func TestServerAcceptClientsExitsOnShutdown(t *testing.T) {
func TestServerHandleConnection(t *testing.T) {
logger := zap.NewNop()
erupeConfig := &_config.Config{
Sign: _config.Sign{
erupeConfig := &cfg.Config{
Sign: cfg.Sign{
Port: 0,
},
}
@@ -447,8 +447,8 @@ func TestServerHandleConnection(t *testing.T) {
func TestServerHandleConnectionWithShortInit(t *testing.T) {
logger := zap.NewNop()
erupeConfig := &_config.Config{
Sign: _config.Sign{
erupeConfig := &cfg.Config{
Sign: cfg.Sign{
Port: 0,
},
}
@@ -479,8 +479,8 @@ func TestServerHandleConnectionWithShortInit(t *testing.T) {
func TestServerHandleConnectionImmediateClose(t *testing.T) {
logger := zap.NewNop()
erupeConfig := &_config.Config{
Sign: _config.Sign{
erupeConfig := &cfg.Config{
Sign: cfg.Sign{
Port: 0,
},
}
@@ -509,8 +509,8 @@ func TestServerHandleConnectionImmediateClose(t *testing.T) {
func TestServerMultipleConnections(t *testing.T) {
logger := zap.NewNop()
erupeConfig := &_config.Config{
Sign: _config.Sign{
erupeConfig := &cfg.Config{
Sign: cfg.Sign{
Port: 0,
},
}
@@ -550,8 +550,8 @@ func TestServerMultipleConnections(t *testing.T) {
func TestServerListenerAddress(t *testing.T) {
logger := zap.NewNop()
erupeConfig := &_config.Config{
Sign: _config.Sign{
erupeConfig := &cfg.Config{
Sign: cfg.Sign{
Port: 0,
},
}