diff options
| author | fusion32 <marcopuzziello@gmail.com> | 2025-09-12 23:48:00 -0300 |
|---|---|---|
| committer | fusion32 <marcopuzziello@gmail.com> | 2025-09-12 23:48:00 -0300 |
| commit | 5e980ee99afd161d6258e5ea68f7284f715e5577 (patch) | |
| tree | 18d6e5aea316321da83aab9fc3b4cf03724ed2d6 /src | |
| parent | 6694516890d12e11b89f76a480032cc60c1ab4e2 (diff) | |
| download | querymanager-5e980ee99afd161d6258e5ea68f7284f715e5577.tar.gz querymanager-5e980ee99afd161d6258e5ea68f7284f715e5577.zip | |
fix queries where the IP address is optional
Diffstat (limited to 'src')
| -rw-r--r-- | src/connections.cc | 6 | ||||
| -rw-r--r-- | src/querymanager.cc | 10 | ||||
| -rw-r--r-- | src/querymanager.hh | 1 |
3 files changed, 13 insertions, 4 deletions
diff --git a/src/connections.cc b/src/connections.cc index 070b348..d032ce5 100644 --- a/src/connections.cc +++ b/src/connections.cc @@ -918,7 +918,7 @@ void ProcessSetNamelockQuery(TConnection *Connection, TReadBuffer *Buffer){ Buffer->ReadString(Comment, sizeof(Comment)); int IPAddress = 0; - if(!ParseIPAddress(IPString, &IPAddress)){ + if(!ParseOptionalIPAddress(IPString, &IPAddress)){ SendQueryStatusFailed(Connection); return; } @@ -978,7 +978,7 @@ void ProcessBanishAccountQuery(TConnection *Connection, TReadBuffer *Buffer){ bool FinalWarning = Buffer->ReadFlag(); int IPAddress = 0; - if(!ParseIPAddress(IPString, &IPAddress)){ + if(!ParseOptionalIPAddress(IPString, &IPAddress)){ SendQueryStatusFailed(Connection); return; } @@ -1045,7 +1045,7 @@ void ProcessSetNotationQuery(TConnection *Connection, TReadBuffer *Buffer){ Buffer->ReadString(Comment, sizeof(Comment)); int IPAddress = 0; - if(!ParseIPAddress(IPString, &IPAddress)){ + if(!ParseOptionalIPAddress(IPString, &IPAddress)){ SendQueryStatusFailed(Connection); return; } diff --git a/src/querymanager.cc b/src/querymanager.cc index 4fbc465..01db930 100644 --- a/src/querymanager.cc +++ b/src/querymanager.cc @@ -173,7 +173,7 @@ bool StringCopy(char *Dest, int DestCapacity, const char *Src){ bool ParseIPAddress(const char *String, int *OutAddr){ if(StringEmpty(String)){ - LOG_ERR("Empty IP Address string"); + LOG_ERR("Empty IP Address"); return false; } @@ -201,6 +201,14 @@ bool ParseIPAddress(const char *String, int *OutAddr){ return true; } +bool ParseOptionalIPAddress(const char *String, int *OutAddr){ + if(String == NULL || StringEmpty(String)){ + return true; + } + + return ParseIPAddress(String, OutAddr); +} + bool ReadBooleanConfig(bool *Dest, const char *Val){ ASSERT(Dest && Val); *Dest = StringEqCI(Val, "true"); diff --git a/src/querymanager.hh b/src/querymanager.hh index c1e48eb..0137f64 100644 --- a/src/querymanager.hh +++ b/src/querymanager.hh @@ -110,6 +110,7 @@ bool StringEqCI(const char *A, const char *B); bool StringCopyN(char *Dest, int DestCapacity, const char *Src, int SrcLength); bool StringCopy(char *Dest, int DestCapacity, const char *Src); bool ParseIPAddress(const char *String, int *OutAddr); +bool ParseOptionalIPAddress(const char *String, int *OutAddr); bool ReadBooleanConfig(bool *Dest, const char *Val); bool ReadIntegerConfig(int *Dest, const char *Val); |
