Stop server if started with old curl and incompatible sv_register

This prevents accidentally falling victim to the bug #5858.
This commit is contained in:
heinrich5991 2022-09-22 00:09:02 +02:00
parent 4f2f3f4bba
commit 884cf75cb8
3 changed files with 18 additions and 1 deletions

View file

@ -508,7 +508,16 @@ CRegister::CRegister(CConfig *pConfig, IConsole *pConsole, IEngine *pEngine, int
void CRegister::Update()
{
m_GotFirstUpdateCall = true;
if(!m_GotFirstUpdateCall)
{
bool Ipv6 = m_aProtocolEnabled[PROTOCOL_TW6_IPV6] || m_aProtocolEnabled[PROTOCOL_TW7_IPV6];
bool Ipv4 = m_aProtocolEnabled[PROTOCOL_TW6_IPV4] || m_aProtocolEnabled[PROTOCOL_TW7_IPV4];
if(Ipv6 && Ipv4)
{
dbg_assert(!HttpHasIpresolveBug(), "curl version < 7.77.0 does not support registering via both IPv4 and IPv6, set `sv_register ipv6` or `sv_register ipv4`");
}
m_GotFirstUpdateCall = true;
}
if(!m_GotServerInfo)
{
return;

View file

@ -116,6 +116,13 @@ void EscapeUrl(char *pBuf, int Size, const char *pStr)
curl_free(pEsc);
}
bool HttpHasIpresolveBug()
{
// curl < 7.77.0 doesn't use CURLOPT_IPRESOLVE correctly wrt.
// connection caches.
return curl_version_info(CURLVERSION_NOW)->version_num < 0x074d00;
}
CHttpRequest::CHttpRequest(const char *pUrl)
{
str_copy(m_aUrl, pUrl);

View file

@ -194,4 +194,5 @@ inline std::unique_ptr<CHttpRequest> HttpPostJson(const char *pUrl, const char *
bool HttpInit(IStorage *pStorage);
void EscapeUrl(char *pBuf, int Size, const char *pStr);
bool HttpHasIpresolveBug();
#endif // ENGINE_SHARED_HTTP_H