forked from cafeberry/cafeberry
feat: add smartcmd dedicated server
major bug: when connecting to the server a second time, it gets softlocked and keeps repeating ticking connection A\n in debug logs until it times out.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include "StringUtils.h"
|
||||
|
||||
#include <WS2tcpip.h>
|
||||
|
||||
namespace ServerRuntime
|
||||
{
|
||||
namespace NetworkUtils
|
||||
{
|
||||
inline std::string NormalizeIpToken(const std::string &ip)
|
||||
{
|
||||
return StringUtils::ToLowerAscii(StringUtils::TrimAscii(ip));
|
||||
}
|
||||
|
||||
inline bool IsIpLiteral(const std::string &text)
|
||||
{
|
||||
const std::string trimmed = StringUtils::TrimAscii(text);
|
||||
if (trimmed.empty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
IN_ADDR ipv4 = {};
|
||||
IN6_ADDR ipv6 = {};
|
||||
return InetPtonA(AF_INET, trimmed.c_str(), &ipv4) == 1 || InetPtonA(AF_INET6, trimmed.c_str(), &ipv6) == 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user