forked from Mirrors/openclonk
Fix local network discovery
parent
97be97c94c
commit
85f5b3cb75
|
@ -64,7 +64,7 @@ bool C4Network2IODiscover::Init(uint16_t iPort)
|
||||||
bool C4Network2IODiscover::Announce()
|
bool C4Network2IODiscover::Announce()
|
||||||
{
|
{
|
||||||
// Announce our presence
|
// Announce our presence
|
||||||
C4Network2IODiscoverReply Reply = { 4, htons(iRefServerPort) };
|
C4Network2IODiscoverReply Reply = { 4, iRefServerPort };
|
||||||
return Send(C4NetIOPacket(&Reply, sizeof(Reply), false, DiscoveryAddr));
|
return Send(C4NetIOPacket(&Reply, sizeof(Reply), false, DiscoveryAddr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -571,9 +571,13 @@ bool C4Network2HTTPClient::SetServer(const char *szServerAddress)
|
||||||
ServerAddr.SetPort(GetDefaultPort());
|
ServerAddr.SetPort(GetDefaultPort());
|
||||||
}
|
}
|
||||||
// Remove port
|
// Remove port
|
||||||
const char *pColon = strchr(Server.getData(), ':');
|
const char *firstColon = strchr(Server.getData(), ':');
|
||||||
if (pColon)
|
const char *lastColon = strrchr(Server.getData(), ':');
|
||||||
Server.SetLength(pColon - Server.getData());
|
if (firstColon)
|
||||||
|
// hostname/IPv4 address or IPv6 address with port (e.g. [::1]:1234)
|
||||||
|
if (firstColon == lastColon || (Server[0] == '[' && *(lastColon - 1) == ']'))
|
||||||
|
Server.SetLength(lastColon - Server.getData());
|
||||||
|
|
||||||
// Done
|
// Done
|
||||||
ResetError();
|
ResetError();
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue