forked from Mirrors/openclonk
Fix local network discovery
parent
65d8c11450
commit
60560125dc
|
@ -64,7 +64,7 @@ bool C4Network2IODiscover::Init(uint16_t iPort)
|
|||
bool C4Network2IODiscover::Announce()
|
||||
{
|
||||
// Announce our presence
|
||||
C4Network2IODiscoverReply Reply = { 4, htons(iRefServerPort) };
|
||||
C4Network2IODiscoverReply Reply = { 4, iRefServerPort };
|
||||
return Send(C4NetIOPacket(&Reply, sizeof(Reply), false, DiscoveryAddr));
|
||||
}
|
||||
|
||||
|
|
|
@ -571,9 +571,13 @@ bool C4Network2HTTPClient::SetServer(const char *szServerAddress)
|
|||
ServerAddr.SetPort(GetDefaultPort());
|
||||
}
|
||||
// Remove port
|
||||
const char *pColon = strchr(Server.getData(), ':');
|
||||
if (pColon)
|
||||
Server.SetLength(pColon - Server.getData());
|
||||
const char *firstColon = strchr(Server.getData(), ':');
|
||||
const char *lastColon = strrchr(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
|
||||
ResetError();
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue