Skip to content

Commit

Permalink
New sphere.ini settings
Browse files Browse the repository at this point in the history
Added ClientSeedMaxLength
#Issue 1337
  • Loading branch information
canerksk committed Dec 2, 2024
1 parent 3faad4d commit b844f26
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
4 changes: 4 additions & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3947,3 +3947,7 @@ Added: 'H' shortcut for variables to get the value as hexadecimal.

02-11-2024, raydie
- Added: Add LAYER_SPELL_Explosion for use delayed explosion spell. Now if set Duration to spell explosion, these duration is the delay to execute the explosion (From UOGuide, explosion spell: 2 second delay between targetting and explosion)

02-12-2024, canerksk
- Added: New sphere.ini settings ClientSeedMaxLength
Maximum length setting for the seed sent by the client Needed for customizable clients. (Can be either 127 or 255)
14 changes: 12 additions & 2 deletions src/game/CServerConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ CServerConfig::CServerConfig()
m_iDeadSocketTime = 5ll * 60 * MSECS_PER_SEC;
m_iMinCharDeleteTime = 7ll * 24*60*60 * MSECS_PER_SEC;
m_iMaxCharsPerAccount = 5;
m_bClientSeedMaxLength = INT8_MAX;
m_fLocalIPAdmin = true;
_iMaxHousesAccount = 1;
_iMaxHousesGuild = 1;
Expand Down Expand Up @@ -494,6 +495,7 @@ enum RC_TYPE
RC_CLIENTMAX, // m_iClientsMax
RC_CLIENTMAXIP, // m_iClientsMaxIP
RC_CLIENTS,
RC_CLIENTSEEDMAXLENGTH,
RC_COLORHIDDEN,
RC_COLORINVIS,
RC_COLORINVISITEM,
Expand Down Expand Up @@ -785,8 +787,9 @@ const CAssocReg CServerConfig::sm_szLoadKeys[RC_QTY + 1]
{ "CLIENTLOGINMAXTRIES", { ELEM_INT, static_cast<uint>OFFSETOF(CServerConfig,m_iClientLoginMaxTries) }},
{ "CLIENTLOGINTEMPBAN", { ELEM_INT, static_cast<uint>OFFSETOF(CServerConfig,m_iClientLoginTempBan) }},
{ "CLIENTMAX", { ELEM_INT, static_cast<uint>OFFSETOF(CServerConfig,m_iClientsMax) }},
{ "CLIENTMAXIP", { ELEM_INT, static_cast<uint>OFFSETOF(CServerConfig,m_iClientsMaxIP) }},
{ "CLIENTS", { ELEM_VOID, 0 }}, // duplicate
{ "CLIENTMAXIP", { ELEM_INT, static_cast<uint>OFFSETOF(CServerConfig,m_iClientsMaxIP) }},
{ "CLIENTS", { ELEM_VOID, 0 }}, // duplicate
{ "CLIENTSEEDMAXLENGTH", { ELEM_BYTE, static_cast<uint>OFFSETOF(CServerConfig,m_bClientSeedMaxLength) }},
{ "COLORHIDDEN", { ELEM_VOID, static_cast<uint>OFFSETOF(CServerConfig,m_iColorHidden) }},
{ "COLORINVIS", { ELEM_VOID, static_cast<uint>OFFSETOF(CServerConfig,m_iColorInvis) }},
{ "COLORINVISITEM", { ELEM_VOID, static_cast<uint>OFFSETOF(CServerConfig,m_iColorInvisItem) }},
Expand Down Expand Up @@ -1207,6 +1210,13 @@ bool CServerConfig::r_LoadVal( CScript &s )
else if (m_iClientsMax < 0)
m_iClientsMax = 0;
break;
case RC_CLIENTSEEDMAXLENGTH:
m_bClientSeedMaxLength = (uchar)(s.GetArgVal());
if (m_bClientSeedMaxLength < INT8_MAX)
m_bClientSeedMaxLength = INT8_MAX;
else if (m_bClientSeedMaxLength > UINT8_MAX)
m_bClientSeedMaxLength = UINT8_MAX;
break;
case RC_COLORHIDDEN:
m_iColorHidden = (HUE_TYPE)(s.GetArgVal());
break;
Expand Down
3 changes: 2 additions & 1 deletion src/game/CServerConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,8 @@ extern class CServerConfig : public CResourceHolder
int64 _iMaxSizeClientIn; // Maximum number of bytes a client can receive from the server in 10 seconds before being disconnected
int _iMaxConnectRequestsPerIP; // Maximum number of connection requests before rejecting/blocking IP.
int64 _iTimeoutIncompleteConnectionMs; // Maximum time in milliseconds to wait before closing a connection request wich did not make it into a successful login
int m_iNetMaxQueueSize; // max packets to hold per queue (comment out for unlimited)
byte m_bClientSeedMaxLength; // Maximum length of seed under processUnknownClientData
int m_iNetMaxQueueSize; // max packets to hold per queue (comment out for unlimited)
bool m_fUsePacketPriorities; // true to prioritise sending packets
bool m_fUseExtraBuffer; // true to queue packet data in an extra buffer

Expand Down
7 changes: 5 additions & 2 deletions src/network/CNetworkInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,17 +532,20 @@ bool CNetworkInput::processUnknownClientData(CNetState* state, Packet* buffer)
ASSERT(client != nullptr);

bool fHTTPReq = false;
const byte uiOrigRemainingMaxLength = g_Cfg.m_bClientSeedMaxLength ? g_Cfg.m_bClientSeedMaxLength : INT8_MAX;
const uint uiOrigRemainingLength = buffer->getRemainingLength();
const byte* const pOrigRemainingData = buffer->getRemainingData();
if (state->m_seeded == false)
{
fHTTPReq = (uiOrigRemainingLength >= 5 && memcmp(pOrigRemainingData, "GET /", 5) == 0) ||
(uiOrigRemainingLength >= 6 && memcmp(pOrigRemainingData, "POST /", 6) == 0);
}
if (!fHTTPReq && (uiOrigRemainingLength > INT8_MAX))
if (!fHTTPReq && (uiOrigRemainingLength > uiOrigRemainingMaxLength))
{
g_Log.EventWarn("%x:Client connected with a seed length of %u exceeding max length limit of %d, disconnecting.\n",
state->id(), uiOrigRemainingLength, INT8_MAX);
state->id(),
uiOrigRemainingLength,
uiOrigRemainingMaxLength);
return false;
}

Expand Down

0 comments on commit b844f26

Please sign in to comment.