diff --git a/DependentExtensions/IrrlichtDemo/slikenetstuff.h b/DependentExtensions/IrrlichtDemo/slikenetstuff.h index 12605ca76..7c6b4b1f1 100644 --- a/DependentExtensions/IrrlichtDemo/slikenetstuff.h +++ b/DependentExtensions/IrrlichtDemo/slikenetstuff.h @@ -7,7 +7,7 @@ * of patent rights can be found in the RakNet Patents.txt file in the same directory. * * - * Modified work: Copyright (c) 2017-2018, SLikeSoft UG (haftungsbeschränkt) + * Modified work: Copyright (c) 2017-2019, SLikeSoft UG (haftungsbeschränkt) * * This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style * license found in the license.txt file in the root directory of this source tree. @@ -62,7 +62,7 @@ extern PlayerReplica *playerReplica; // Network object that represents the playe // A NAT punchthrough and proxy server Jenkins Software is hosting for free, should usually be online #define DEFAULT_NAT_PUNCHTHROUGH_FACILITATOR_PORT 61111 -#define DEFAULT_NAT_PUNCHTHROUGH_FACILITATOR_IP "slikesoft.com" +#define DEFAULT_NAT_PUNCHTHROUGH_FACILITATOR_IP "natpunch.slikesoft.com" void InstantiateRakNetClasses(void); void DeinitializeRakNetClasses(void); diff --git a/Samples/AutopatcherClient/AutopatcherClientTest.cpp b/Samples/AutopatcherClient/AutopatcherClientTest.cpp index cf740eb43..a0e465077 100644 --- a/Samples/AutopatcherClient/AutopatcherClientTest.cpp +++ b/Samples/AutopatcherClient/AutopatcherClientTest.cpp @@ -7,7 +7,7 @@ * of patent rights can be found in the RakNet Patents.txt file in the same directory. * * - * Modified work: Copyright (c) 2016-2017, SLikeSoft UG (haftungsbeschränkt) + * Modified work: Copyright (c) 2016-2019, SLikeSoft UG (haftungsbeschränkt) * * This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style * license found in the license.txt file in the root directory of this source tree. @@ -230,7 +230,7 @@ int main(int argc, char **argv) printf("Enter server IP: "); Gets(buff,sizeof(buff)); if (buff[0]==0) - //strcpy_s(buff, "natpunch.jenkinssoftware.com"); + //strcpy_s(buff, "natpunch.slikesoft.com"); strcpy_s(buff, "127.0.0.1"); } else diff --git a/Samples/BigPacketTest/BigPacketTest.cpp b/Samples/BigPacketTest/BigPacketTest.cpp index b91c20e14..919265aa0 100644 --- a/Samples/BigPacketTest/BigPacketTest.cpp +++ b/Samples/BigPacketTest/BigPacketTest.cpp @@ -7,7 +7,7 @@ * of patent rights can be found in the RakNet Patents.txt file in the same directory. * * - * Modified work: Copyright (c) 2016-2018, SLikeSoft UG (haftungsbeschränkt) + * Modified work: Copyright (c) 2016-2019, SLikeSoft UG (haftungsbeschränkt) * * This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style * license found in the license.txt file in the root directory of this source tree. @@ -62,7 +62,7 @@ int main(void) printf("Enter remote IP: "); Gets(text,BIG_PACKET_SIZE); if (text[0]==0) - strcpy_s(text, BIG_PACKET_SIZE, "slikesoft.com"); // dx in Europe + strcpy_s(text, BIG_PACKET_SIZE, "natpunch.slikesoft.com"); // dx in Europe } else if (ch=='s') { diff --git a/Samples/ChatExample/Client/Chat Example Client.cpp b/Samples/ChatExample/Client/Chat Example Client.cpp index ddb5bd918..83edb4483 100644 --- a/Samples/ChatExample/Client/Chat Example Client.cpp +++ b/Samples/ChatExample/Client/Chat Example Client.cpp @@ -7,7 +7,7 @@ * of patent rights can be found in the RakNet Patents.txt file in the same directory. * * - * Modified work: Copyright (c) 2016-2018, SLikeSoft UG (haftungsbeschränkt) + * Modified work: Copyright (c) 2016-2019, SLikeSoft UG (haftungsbeschränkt) * * This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style * license found in the license.txt file in the root directory of this source tree. @@ -100,7 +100,7 @@ int main(void) client->AllowConnectionResponseIPMigration(false); if (ip[0]==0) strcpy_s(ip, "127.0.0.1"); - // strcpy_s(ip, "natpunch.jenkinssoftware.com"); + // strcpy_s(ip, "natpunch.slikesoft.com"); puts("Enter the port to connect to"); diff --git a/Samples/ComprehensivePCGame/ComprehensivePCGame.cpp b/Samples/ComprehensivePCGame/ComprehensivePCGame.cpp index 49a159d29..9abcb7c8b 100644 --- a/Samples/ComprehensivePCGame/ComprehensivePCGame.cpp +++ b/Samples/ComprehensivePCGame/ComprehensivePCGame.cpp @@ -7,7 +7,7 @@ * of patent rights can be found in the RakNet Patents.txt file in the same directory. * * - * Modified work: Copyright (c) 2016-2018, SLikeSoft UG (haftungsbeschränkt) + * Modified work: Copyright (c) 2016-2019, SLikeSoft UG (haftungsbeschränkt) * * This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style * license found in the license.txt file in the root directory of this source tree. @@ -50,7 +50,7 @@ #define DEFAULT_SERVER_PORT "61111" // Public test server -#define DEFAULT_SERVER_ADDRESS "slikesoft.com" +#define DEFAULT_SERVER_ADDRESS "natpunch.slikesoft.com" #define NAT_TYPE_DETECTION_SERVER 0 #define USE_UPNP 1 #define MASTER_SERVER_ADDRESS "masterserver2.raknet.com" diff --git a/Samples/NATCompleteClient/main.cpp b/Samples/NATCompleteClient/main.cpp index c69e0ea57..1c3ed7ae4 100644 --- a/Samples/NATCompleteClient/main.cpp +++ b/Samples/NATCompleteClient/main.cpp @@ -7,7 +7,7 @@ * of patent rights can be found in the RakNet Patents.txt file in the same directory. * * - * Modified work: Copyright (c) 2016-2018, SLikeSoft UG (haftungsbeschränkt) + * Modified work: Copyright (c) 2016-2019, SLikeSoft UG (haftungsbeschränkt) * * This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style * license found in the license.txt file in the root directory of this source tree. @@ -44,7 +44,7 @@ using namespace SLNet; #define DEFAULT_RAKPEER_PORT 50000 #define RAKPEER_PORT_STR "0" #define DEFAULT_SERVER_PORT "61111" -#define DEFAULT_SERVER_ADDRESS "slikesoft.com" +#define DEFAULT_SERVER_ADDRESS "natpunch.slikesoft.com" enum SampleResult { diff --git a/Samples/PacketConsoleLogger/main.cpp b/Samples/PacketConsoleLogger/main.cpp index fd84338e9..7f0915adc 100644 --- a/Samples/PacketConsoleLogger/main.cpp +++ b/Samples/PacketConsoleLogger/main.cpp @@ -7,7 +7,7 @@ * of patent rights can be found in the RakNet Patents.txt file in the same directory. * * - * Modified work: Copyright (c) 2016-2018, SLikeSoft UG (haftungsbeschränkt) + * Modified work: Copyright (c) 2016-2019, SLikeSoft UG (haftungsbeschränkt) * * This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style * license found in the license.txt file in the root directory of this source tree. @@ -56,7 +56,7 @@ void main(void) RakSleep(30); } - SLNet::ConnectionAttemptResult car = rakPeer->Connect("slikesoft.com", 61111, 0, 0); + SLNet::ConnectionAttemptResult car = rakPeer->Connect("natpunch.slikesoft.com", 61111, 0, 0); (void) car; for(;;) { diff --git a/Samples/RakVoice/main.cpp b/Samples/RakVoice/main.cpp index 59f40c50d..cae4ccac1 100644 --- a/Samples/RakVoice/main.cpp +++ b/Samples/RakVoice/main.cpp @@ -7,7 +7,7 @@ * of patent rights can be found in the RakNet Patents.txt file in the same directory. * * - * Modified work: Copyright (c) 2016-2018, SLikeSoft UG (haftungsbeschränkt) + * Modified work: Copyright (c) 2016-2019, SLikeSoft UG (haftungsbeschränkt) * * This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style * license found in the license.txt file in the root directory of this source tree. @@ -168,7 +168,7 @@ int main(void) printf("Enter IP of facilitator (enter for default): "); Gets(facilitatorIP,sizeof(facilitatorIP)); if (facilitatorIP[0]==0) - strcpy_s(facilitatorIP, "slikesoft.com"); + strcpy_s(facilitatorIP, "natpunch.slikesoft.com"); facilitator.FromString(facilitatorIP); facilitator.SetPortHostOrder(NAT_PUNCHTHROUGH_FACILITATOR_PORT); rakPeer->Connect(facilitatorIP, NAT_PUNCHTHROUGH_FACILITATOR_PORT, 0, 0); diff --git a/Samples/ReliableOrderedTest/ReliableOrderedTest.cpp b/Samples/ReliableOrderedTest/ReliableOrderedTest.cpp index ef96997f0..edc1939d6 100644 --- a/Samples/ReliableOrderedTest/ReliableOrderedTest.cpp +++ b/Samples/ReliableOrderedTest/ReliableOrderedTest.cpp @@ -7,7 +7,7 @@ * of patent rights can be found in the RakNet Patents.txt file in the same directory. * * - * Modified work: Copyright (c) 2016-2018, SLikeSoft UG (haftungsbeschränkt) + * Modified work: Copyright (c) 2016-2019, SLikeSoft UG (haftungsbeschränkt) * * This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style * license found in the license.txt file in the root directory of this source tree. @@ -129,7 +129,7 @@ int main(int argc, char **argv) Gets(ip, sizeof(ip)); if (ip[0]==0) strcpy_s(ip, "127.0.0.1"); - // strcpy_s(ip, "natpunch.jenkinssoftware.com"); + // strcpy_s(ip, "natpunch.slikesoft.com"); printf("Enter remote port: "); Gets(str, sizeof(str)); diff --git a/Source/include/slikenet/types.h b/Source/include/slikenet/types.h index ae9de769d..b3e5e675b 100644 --- a/Source/include/slikenet/types.h +++ b/Source/include/slikenet/types.h @@ -7,7 +7,7 @@ * of patent rights can be found in the RakNet Patents.txt file in the same directory. * * - * Modified work: Copyright (c) 2016-2018, SLikeSoft UG (haftungsbeschränkt) + * Modified work: Copyright (c) 2016-2019, SLikeSoft UG (haftungsbeschränkt) * * This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style * license found in the license.txt file in the root directory of this source tree. @@ -148,7 +148,7 @@ struct RAK_DLL_EXPORT SocketDescriptor char hostAddress[32]; /// IP version: For IPV4, use AF_INET (default). For IPV6, use AF_INET6. To autoselect, use AF_UNSPEC. - /// IPV6 is the newer internet protocol. Instead of addresses such as natpunch.jenkinssoftware.com, you may have an address such as fe80::7c:31f7:fec4:27de%14. + /// IPV6 is the newer internet protocol. Instead of addresses such as natpunch.slikesoft.com, you may have an address such as fe80::7c:31f7:fec4:27de%14. /// Encoding takes 16 bytes instead of 4, so IPV6 is less efficient for bandwidth. /// On the positive side, NAT Punchthrough is not needed and should not be used with IPV6 because there are enough addresses that routers do not need to create address mappings. /// RakPeer::Startup() will fail if this IP version is not supported. diff --git a/Source/src/HTTPConnection2.cpp b/Source/src/HTTPConnection2.cpp index 0ac8be259..97c331f2d 100644 --- a/Source/src/HTTPConnection2.cpp +++ b/Source/src/HTTPConnection2.cpp @@ -54,6 +54,7 @@ bool HTTPConnection2::TransmitRequest(const char* stringToTransmit, const char* } else { + // #med - this should be changed to not extract the port from the passed in host-address (which is overwritten directly below with the provided port anyway) if (request->hostEstimatedAddress.FromString(host, '|', ipVersion)==false) { SLNet::OP_DELETE(request, _FILE_AND_LINE_); diff --git a/Source/src/RakNetSocket2.cpp b/Source/src/RakNetSocket2.cpp index 0e94404ea..e21ff9f9e 100644 --- a/Source/src/RakNetSocket2.cpp +++ b/Source/src/RakNetSocket2.cpp @@ -7,7 +7,7 @@ * of patent rights can be found in the RakNet Patents.txt file in the same directory. * * - * Modified work: Copyright (c) 2017-2018, SLikeSoft UG (haftungsbeschränkt) + * Modified work: Copyright (c) 2017-2019, SLikeSoft UG (haftungsbeschränkt) * * This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style * license found in the license.txt file in the root directory of this source tree. @@ -110,10 +110,6 @@ RNS2EventHandler * RakNetSocket2::GetEventHandler(void) const {return eventHandl void RakNetSocket2::DomainNameToIP( const char *domainName, char ip[65] ) { #if defined(WINDOWS_STORE_RT) return RNS2_WindowsStore8::DomainNameToIP( domainName, ip ); -#elif defined(__native_client__) - return DomainNameToIP_Berkley( domainName, ip ); -#elif defined(_WIN32) - return DomainNameToIP_Berkley( domainName, ip ); #else return DomainNameToIP_Berkley( domainName, ip ); #endif diff --git a/Source/src/RakNetSocket2_Berkley_NativeClient.cpp b/Source/src/RakNetSocket2_Berkley_NativeClient.cpp index 9f7696737..02e3403f8 100644 --- a/Source/src/RakNetSocket2_Berkley_NativeClient.cpp +++ b/Source/src/RakNetSocket2_Berkley_NativeClient.cpp @@ -24,6 +24,7 @@ #if !defined(WINDOWS_STORE_RT) #include "slikenet/Itoa.h" +#include "slikenet/WSAStartupSingleton.h" // used for WSAStartupSingleton // Shared on most platforms, but excluded from the listed @@ -78,7 +79,10 @@ void DomainNameToIP_Berkley_IPV4( const char *domainName, char ip[65] ) { // Use inet_addr instead? What is the difference? struct addrinfo *addressinfo = NULL; + // needed for getaddrinfo + WSAStartupSingleton::AddRef(); int error = getaddrinfo(domainName, NULL, NULL, &addressinfo); + WSAStartupSingleton::Deref(); if ( error != 0 || addressinfo == 0 ) { diff --git a/Source/src/RakNetTypes.cpp b/Source/src/RakNetTypes.cpp index 832fd3a2e..a48e40db2 100644 --- a/Source/src/RakNetTypes.cpp +++ b/Source/src/RakNetTypes.cpp @@ -7,7 +7,7 @@ * of patent rights can be found in the RakNet Patents.txt file in the same directory. * * - * Modified work: Copyright (c) 2016-2018, SLikeSoft UG (haftungsbeschränkt) + * Modified work: Copyright (c) 2016-2019, SLikeSoft UG (haftungsbeschränkt) * * This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style * license found in the license.txt file in the root directory of this source tree. @@ -16,7 +16,6 @@ /// \file /// - #include "slikenet/types.h" #include "slikenet/assert.h" #include @@ -26,7 +25,6 @@ #include "slikenet/SocketDefines.h" #include "slikenet/socket2.h" - #if defined(_WIN32) // extern __int64 _strtoui64(const char*, char**, int); // needed for Code::Blocks. Does not compile on Visual Studio 2010 // IP_DONTFRAGMENT is different between winsock 1 and winsock 2. Therefore, Winsock2.h must be linked againt Ws2_32.lib @@ -40,7 +38,6 @@ #include #endif -#include // strncasecmp #include "slikenet/Itoa.h" #include "slikenet/SocketLayer.h" #include "slikenet/SuperFastHash.h" @@ -83,16 +80,16 @@ void AddressOrGUID::ToString(bool writePort, char *dest, size_t destLength) cons return rakNetGuid.ToString(dest,destLength); return systemAddress.ToString(writePort,dest,destLength); } + +// Return false if IP address. Return true if domain bool SLNet::NonNumericHostString( const char *host ) { - // Return false if IP address. Return true if domain - unsigned int i=0; - while (host[i]) - { - // IPV4: natpunch.jenkinssoftware.com + size_t i = 0; + while (host[i] != '\0') { + // IPV4: natpunch.slikesoft.com // IPV6: fe80::7c:31f7:fec4:27de%14 - if ((host[i]>='g' && host[i]<='z') || - (host[i]>='A' && host[i]<='Z')) + if ((host[i] >= 'g' && host[i] <= 'z') || + (host[i] >= 'G' && host[i] <= 'Z')) return true; ++i; } @@ -105,7 +102,12 @@ SocketDescriptor::SocketDescriptor() { #else blockingSocket=true; #endif - port=0; hostAddress[0]=0; remotePortRakNetWasStartedOn_PS3_PSP2=0; extraSocketOptions=0; socketFamily=AF_INET;} + port=0; + hostAddress[0]=0; + remotePortRakNetWasStartedOn_PS3_PSP2=0; + extraSocketOptions=0; + socketFamily=AF_INET; +} SocketDescriptor::SocketDescriptor(unsigned short _port, const char *_hostAddress) { #ifdef __native_client__ @@ -446,6 +448,8 @@ SystemAddress::SystemAddress(const char *str) { address.addr4.sin_family=AF_INET; SetPortHostOrder(0); + // #med - reconsider this --- doesn't make sense to allow specifying the port using the default delimiter w/o also allowing specifying the used delimiter + // i.e. consider changing to FromString(str, 0) or change the ctor to SystemAddress(str, delimiter = '\0') or alternatively to delimiter = '|' FromString(str); systemIndex=(SystemIndex)-1; } @@ -455,44 +459,6 @@ SystemAddress::SystemAddress(const char *str, unsigned short port) FromStringExplicitPort(str,port); systemIndex=(SystemIndex)-1; } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void SystemAddress::FixForIPVersion(const SystemAddress &boundAddressToSocket) { char str[128]; @@ -532,112 +498,72 @@ bool SystemAddress::IsLANAddress(void) } bool SystemAddress::SetBinaryAddress(const char *str, char portDelineator) { - if ( NonNumericHostString( str ) ) - { - -#if defined(_WIN32) - if (_strnicmp(str,"localhost", 9)==0) -#else - if (strncasecmp(str,"localhost", 9)==0) -#endif - { - - - - - - inet_pton(AF_INET, "127.0.0.1", &address.addr4.sin_addr.s_addr); - - if (str[9]) - { - SetPortHostOrder((unsigned short) atoi(str+9)); - } - return true; + size_t delimiterPos = 0; + size_t stringLength = strlen(str); + for (; delimiterPos < stringLength; ++delimiterPos) { + if (str[delimiterPos] == portDelineator) { + break; // found location of port delimiter } + } + if (NonNumericHostString(str)) { //const char *ip = ( char* ) SocketLayer::DomainNameToIP( str ); char ip[65]; - ip[0]=0; - RakNetSocket2::DomainNameToIP(str, ip); - if (ip[0]) - { - - - + ip[0] = '\0'; + // copy the plain hostname (excluding the (optional) port part) + char* hostname = OP_NEW_ARRAY(delimiterPos + 1, _FILE_AND_LINE_); + strncpy_s(hostname, delimiterPos + 1, str, delimiterPos); + RakNetSocket2::DomainNameToIP(hostname, ip); + OP_DELETE_ARRAY(hostname, _FILE_AND_LINE_); + if (ip[0] != '\0') { inet_pton(AF_INET, ip, &address.addr4.sin_addr.s_addr); - } - else - { + else { *this = UNASSIGNED_SYSTEM_ADDRESS; return false; } } - else - { - //#ifdef _XBOX - // binaryAddress=UNASSIGNED_SYSTEM_ADDRESS.binaryAddress; - //#else + else { // Split the string into the first part, and the : part - int index, portIndex; char IPPart[22]; - char portPart[10]; // Only write the valid parts, don't change existing if invalid // binaryAddress=UNASSIGNED_SYSTEM_ADDRESS.binaryAddress; // port=UNASSIGNED_SYSTEM_ADDRESS.port; - for (index=0; str[index] && str[index]!=portDelineator && index<22; index++) - { - if (str[index]!='.' && (str[index]<'0' || str[index]>'9')) + size_t index = 0; + // #med - revise this --- if the hostname length > 22 we'd reject it rather than skipping what is beyond the max length... + for (; index < delimiterPos && index < 22; ++index) { + if (str[index] != '.' && (str[index] < '0' || str[index] > '9')) { break; - IPPart[index]=str[index]; - } - IPPart[index]=0; - portPart[0]=0; - if (str[index] && str[index+1]) - { - index++; - for (portIndex=0; portIndex<10 && str[index] && index < 22+10; index++, portIndex++) - { - if (str[index]<'0' || str[index]>'9') - break; - - portPart[portIndex]=str[index]; } - portPart[portIndex]=0; + IPPart[index] = str[index]; } - - - - - - - - - - - - - - if (IPPart[0]) - { - - - - - + IPPart[index] = '\0'; + if (index > 0) { inet_pton(AF_INET, IPPart, &address.addr4.sin_addr.s_addr); - } + } + char portPart[10]; + portPart[0] = '\0'; + if (str[delimiterPos] != '\0') { + size_t portIndex; + ++delimiterPos; // skip the delimiter + for (portIndex = 0; portIndex < 10 && str[delimiterPos] != '\0'; ++delimiterPos, ++portIndex) { + if (str[delimiterPos] < '0' || str[delimiterPos] > '9') { + break; + } - if (portPart[0]) - { - address.addr4.sin_port=htons((unsigned short) atoi(portPart)); - debugPort=ntohs(address.addr4.sin_port); + portPart[portIndex] = str[delimiterPos]; } - //#endif + portPart[portIndex] = '\0'; + } + if (portPart[0] != '\0') { + // #med - missing / insufficient port range range + address.addr4.sin_port = htons((unsigned short)atoi(portPart)); + // #med - not set in IPv6 mode + debugPort = ntohs(address.addr4.sin_port); } return true; } @@ -660,54 +586,32 @@ bool SystemAddress::FromString(const char *str, char portDelineator, int ipVersi char ipPart[INET_ADDRSTRLEN]; #endif char portPart[32]; - int i=0,j; // TODO - what about 255.255.255.255? - if (ipVersion==4 && strcmp(str, IPV6_LOOPBACK)==0) - { + if (ipVersion==4 && strcmp(str, IPV6_LOOPBACK) == 0) { strcpy_s(ipPart,IPV4_LOOPBACK); } - else if (ipVersion==6 && strcmp(str, IPV4_LOOPBACK)==0) - { + else if (ipVersion==6 && strcmp(str, IPV4_LOOPBACK) == 0) { address.addr4.sin_family=AF_INET6; strcpy_s(ipPart,IPV6_LOOPBACK); } - else if (NonNumericHostString(str)==false) - { - for (; i < sizeof(ipPart) && str[i]!=0 && str[i]!=portDelineator; i++) - { - if ((str[i]<'0' || str[i]>'9') && (str[i]<'a' || str[i]>'f') && (str[i]<'A' || str[i]>'F') && str[i]!='.' && str[i]!=':' && str[i]!='%' && str[i]!='-' && str[i]!='/') - break; - - ipPart[i]=str[i]; - } - ipPart[i]=0; - } - else - { - strncpy_s(ipPart,str,sizeof(ipPart)); - ipPart[sizeof(ipPart)-1]=0; - } - j=0; - if (str[i]==portDelineator && portDelineator!=0) - { - i++; - for (; j < sizeof(portPart) && str[i]!=0; i++, j++) - { - portPart[j]=str[i]; + int i = 0; + for (; i < sizeof(ipPart) && str[i] != '\0'; ++i) { + if (str[i] == portDelineator) { + // #med - missing error checking, if portPart is non-numeric and/or exceeds max allowed port value + int j = 0; + ++i; // skip the delimiter + for (; j < sizeof(portPart) && str[i] != '\0'; ++i, ++j) { + portPart[j] = str[i]; + } + portPart[j] = '\0'; + i = i - j - 1; // reset the position to the last position, so the trailing '\0'-terminator is set correctly below + break; } + ipPart[i] = str[i]; } - portPart[j]=0; - - - - - - - - - + ipPart[i] = '\0'; // needed for getaddrinfo WSAStartupSingleton::AddRef(); @@ -723,8 +627,8 @@ bool SystemAddress::FromString(const char *str, char portDelineator, int ipVersi hints.ai_family = AF_INET; else hints.ai_family = AF_UNSPEC; - getaddrinfo(ipPart, "", &hints, &servinfo); - if (servinfo==0) + INT error = getaddrinfo(ipPart, "", &hints, &servinfo); + if (servinfo==0 && error != 0) { if (ipVersion==6) { @@ -861,12 +765,8 @@ bool RakNetGUID::FromString(const char *source) if (source==0) return false; - - #if defined(WIN32) g=_strtoui64(source, NULL, 10); - - #else // Changed from g=strtoull(source,0,10); for android g=strtoull(source, (char **)NULL, 10); diff --git a/Source/src/RakPeer.cpp b/Source/src/RakPeer.cpp index 829910477..ca66d1fdb 100644 --- a/Source/src/RakPeer.cpp +++ b/Source/src/RakPeer.cpp @@ -581,7 +581,6 @@ StartupResult RakPeer::Startup( unsigned int maxConnections, SocketDescriptor *s } #endif -// #if !defined(_XBOX) && !defined(_XBOX_720_COMPILE_AS_WINDOWS) && !defined(X360) for (i=0; i < MAXIMUM_NUMBER_OF_INTERNAL_IDS; i++) { if (ipList[i]==UNASSIGNED_SYSTEM_ADDRESS) @@ -598,8 +597,6 @@ StartupResult RakPeer::Startup( unsigned int maxConnections, SocketDescriptor *s #endif // ipList[i].SetPort(((RNS2_360_720*)socketList[0])->GetBoundAddress().GetPort()); } -// #endif - if ( maximumNumberOfPeers == 0 ) { @@ -2633,7 +2630,7 @@ bool RakPeer::IsLocalIP( const char *ip ) if (ip==0 || ip[0]==0) return false; - + // #med - this should also check for "::1" here in IPv6 mode if (strcmp(ip, "127.0.0.1")==0 || strcmp(ip, "localhost")==0) return true; diff --git a/Source/src/TCPInterface.cpp b/Source/src/TCPInterface.cpp index 8a429898b..c5ab47873 100644 --- a/Source/src/TCPInterface.cpp +++ b/Source/src/TCPInterface.cpp @@ -7,7 +7,7 @@ * of patent rights can be found in the RakNet Patents.txt file in the same directory. * * - * Modified work: Copyright (c) 2016-2018, SLikeSoft UG (haftungsbeschränkt) + * Modified work: Copyright (c) 2016-2019, SLikeSoft UG (haftungsbeschränkt) * * This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style * license found in the license.txt file in the root directory of this source tree. @@ -371,6 +371,7 @@ SystemAddress TCPInterface::Connect(const char* host, unsigned short remotePort, if (block) { SystemAddress systemAddress; + // #med - call should be changed to ...FromString(host, '\0') so to not try to extract an optional port (which is overwritten with the removePort directly afterwards) systemAddress.FromString(host); systemAddress.SetPortHostOrder(remotePort); systemAddress.systemIndex=(SystemIndex) newRemoteClientIndex; diff --git a/changelog.txt b/changelog.txt index 2e58d7ce3..159ea8a22 100644 --- a/changelog.txt +++ b/changelog.txt @@ -21,6 +21,8 @@ General: * documentation updates (#130, #160, #257) * updated changelog entries related to security issues in previous versions (#130) Core: + General: + * fixed NonNumericHostString() incorrectly identifying numeric as non-numeric addresses (#262) FullyConnectedMesh2: * fixed incorrect delete in FullyConnectedMesh2::Clear() when using a custom allocator (#249) HTTPConnection2: @@ -29,6 +31,7 @@ Core: * revised RakNetSocket2::GetMyIP() to determine own IPs more reliably (f.e. on OSX) (#217 - SLNET_36) * fixed failure in RNS2_Berkley::BindSharedIPV4() always reporting an "unknown" error on OSX (#258) * fixed RakNetSocket2::DomainNameToIP() not retrieving the proper IP (#260 - SLNET_45) + * fixed RakNetSocket2::DomainNameToIP() failing to resolve the domain name (#264) RakPeer: * improve handling of disconnecting peers (#123 - SLNET_16) * fixed crash in RakPeer::GetNumberOfAddresses() when the machine has >= 10 IPs (#261) @@ -40,6 +43,10 @@ Core: ReplicaManager3: * fixed multiple threading issues, with using ReplicaManager3 (#248) * fixed incorrect delete in ReplicaManager3::Clear() when using a custom allocator (#249) + SystemAddress: + * fixed multiple issues related to port resolution in hostnames upon construction or through SystemAddress::FromString() (#263 - SLNET_46) + * fixed cases where using a hostname to create a system address, calling SystemAddress::FromString(), or SystemAddress::SetBinaryAddress() can fail in IPv4 mode (#264) + * fixed localhost not being resolved properly, if set to something other than 127.0.0.1 on the current system (#265) TeamManager: * fixed incorrect delete in TeamManager::Clear() when using a custom allocator (#249) WindowsStore8: