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

@@ -3,7 +3,7 @@ package network
import (
"bytes"
"errors"
_config "erupe-ce/config"
cfg "erupe-ce/config"
"erupe-ce/network/crypto"
"io"
"net"
@@ -54,7 +54,7 @@ func (m *mockConn) SetWriteDeadline(t time.Time) error { return nil }
func TestNewCryptConn(t *testing.T) {
mockConn := newMockConn(nil)
cc := NewCryptConn(mockConn, _config.ZZ, nil)
cc := NewCryptConn(mockConn, cfg.ZZ, nil)
if cc == nil {
t.Fatal("NewCryptConn() returned nil")
@@ -84,8 +84,8 @@ func TestNewCryptConn(t *testing.T) {
t.Errorf("prevSendPacketCombinedCheck = %d, want 0", cc.prevSendPacketCombinedCheck)
}
if cc.realClientMode != _config.ZZ {
t.Errorf("realClientMode = %d, want %d", cc.realClientMode, _config.ZZ)
if cc.realClientMode != cfg.ZZ {
t.Errorf("realClientMode = %d, want %d", cc.realClientMode, cfg.ZZ)
}
}
@@ -111,7 +111,7 @@ func TestCryptConn_SendPacket(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
mockConn := newMockConn(nil)
cc := NewCryptConn(mockConn, _config.ZZ, nil)
cc := NewCryptConn(mockConn, cfg.ZZ, nil)
err := cc.SendPacket(tt.data)
if err != nil {
@@ -155,7 +155,7 @@ func TestCryptConn_SendPacket(t *testing.T) {
func TestCryptConn_SendPacket_MultiplePackets(t *testing.T) {
mockConn := newMockConn(nil)
cc := NewCryptConn(mockConn, _config.ZZ, nil)
cc := NewCryptConn(mockConn, cfg.ZZ, nil)
// Send first packet
err := cc.SendPacket([]byte{0x01, 0x02})
@@ -190,7 +190,7 @@ func TestCryptConn_SendPacket_MultiplePackets(t *testing.T) {
func TestCryptConn_SendPacket_KeyRotation(t *testing.T) {
mockConn := newMockConn(nil)
cc := NewCryptConn(mockConn, _config.ZZ, nil)
cc := NewCryptConn(mockConn, cfg.ZZ, nil)
initialKey := cc.sendKeyRot
@@ -209,7 +209,7 @@ func TestCryptConn_SendPacket_KeyRotation(t *testing.T) {
func TestCryptConn_SendPacket_WriteError(t *testing.T) {
mockConn := newMockConn(nil)
mockConn.writeErr = errors.New("write error")
cc := NewCryptConn(mockConn, _config.ZZ, nil)
cc := NewCryptConn(mockConn, cfg.ZZ, nil)
err := cc.SendPacket([]byte{0x01, 0x02, 0x03})
// Note: Current implementation doesn't return write error
@@ -244,7 +244,7 @@ func TestCryptConn_ReadPacket_Success(t *testing.T) {
packet := append(headerBytes, encryptedData...)
mockConn := newMockConn(packet)
cc := NewCryptConn(mockConn, _config.Z1, nil)
cc := NewCryptConn(mockConn, cfg.Z1, nil)
// Set the key to match what we used for encryption
cc.readKeyRot = key
@@ -290,7 +290,7 @@ func TestCryptConn_ReadPacket_KeyRotation(t *testing.T) {
packet := append(headerBytes, encryptedData...)
mockConn := newMockConn(packet)
cc := NewCryptConn(mockConn, _config.Z1, nil)
cc := NewCryptConn(mockConn, cfg.Z1, nil)
cc.readKeyRot = key
result, err := cc.ReadPacket()
@@ -330,7 +330,7 @@ func TestCryptConn_ReadPacket_NoKeyRotation(t *testing.T) {
packet := append(headerBytes, encryptedData...)
mockConn := newMockConn(packet)
cc := NewCryptConn(mockConn, _config.Z1, nil)
cc := NewCryptConn(mockConn, cfg.Z1, nil)
cc.readKeyRot = key
originalKeyRot := cc.readKeyRot
@@ -352,7 +352,7 @@ func TestCryptConn_ReadPacket_NoKeyRotation(t *testing.T) {
func TestCryptConn_ReadPacket_HeaderReadError(t *testing.T) {
mockConn := newMockConn([]byte{0x01, 0x02}) // Only 2 bytes, header needs 14
cc := NewCryptConn(mockConn, _config.ZZ, nil)
cc := NewCryptConn(mockConn, cfg.ZZ, nil)
_, err := cc.ReadPacket()
if err == nil {
@@ -368,7 +368,7 @@ func TestCryptConn_ReadPacket_InvalidHeader(t *testing.T) {
// Create invalid header data (wrong endianness or malformed)
invalidHeader := []byte{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}
mockConn := newMockConn(invalidHeader)
cc := NewCryptConn(mockConn, _config.ZZ, nil)
cc := NewCryptConn(mockConn, cfg.ZZ, nil)
_, err := cc.ReadPacket()
if err == nil {
@@ -395,7 +395,7 @@ func TestCryptConn_ReadPacket_BodyReadError(t *testing.T) {
packet := append(headerBytes, incompleteBody...)
mockConn := newMockConn(packet)
cc := NewCryptConn(mockConn, _config.Z1, nil)
cc := NewCryptConn(mockConn, cfg.Z1, nil)
_, err := cc.ReadPacket()
if err == nil {
@@ -425,7 +425,7 @@ func TestCryptConn_ReadPacket_ChecksumMismatch(t *testing.T) {
packet := append(headerBytes, encryptedData...)
mockConn := newMockConn(packet)
cc := NewCryptConn(mockConn, _config.Z1, nil)
cc := NewCryptConn(mockConn, cfg.Z1, nil)
cc.readKeyRot = key
_, err := cc.ReadPacket()