X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=lhnet.c;h=7f9664c05da90dc410509fd7b983224af87579a7;hb=259fc435ccf56dcd2d715d7cc6615163434b8dc4;hp=0d32a0c55b23024569faf0da1cef7dea9a25e5aa;hpb=1e6056400d6d93a7045ffc6be5546c7468a243f3;p=xonotic%2Fdarkplaces.git diff --git a/lhnet.c b/lhnet.c index 0d32a0c5..7f9664c0 100644 --- a/lhnet.c +++ b/lhnet.c @@ -389,8 +389,12 @@ int LHNETADDRESS_FromString(lhnetaddress_t *vaddress, const char *string, int de address->addresstype = LHNETADDRESSTYPE_NONE; port = 0; colon = strrchr(string, ':'); - if (colon) + if (colon && (colon == strchr(string, ':') || (string[0] == '[' && colon - string > 0 && colon[-1] == ']'))) + // EITHER: colon is the ONLY colon OR: colon comes after [...] delimited IPv6 address + // fixes misparsing of IPv6 addresses without port + { port = atoi(colon + 1); + } else colon = string + strlen(string); if (port == 0) @@ -1103,7 +1107,7 @@ int LHNET_Read(lhnetsocket_t *lhnetsocket, void *content, int maxcontentlength, Con_Print("Connection refused\n"); return 0; } - Con_Printf("LHNET_Read: recvfrom returned error: %s\n", LHNETPRIVATE_StrError()); + Con_DPrintf("LHNET_Read: recvfrom returned error: %s\n", LHNETPRIVATE_StrError()); } } #ifdef SUPPORTIPV6 @@ -1112,7 +1116,7 @@ int LHNET_Read(lhnetsocket_t *lhnetsocket, void *content, int maxcontentlength, SOCKLEN_T inetaddresslength; address->addresstype = LHNETADDRESSTYPE_NONE; inetaddresslength = sizeof(address->addr.in6); - value = recvfrom(lhnetsocket->inetsocket, (char *)content, maxcontentlength, 0, &address->addr.sock, &inetaddresslength); + value = recvfrom(lhnetsocket->inetsocket, (char *)content, maxcontentlength, LHNET_RECVFROM_FLAGS, &address->addr.sock, &inetaddresslength); if (value > 0) { address->addresstype = LHNETADDRESSTYPE_INET6; @@ -1130,7 +1134,7 @@ int LHNET_Read(lhnetsocket_t *lhnetsocket, void *content, int maxcontentlength, Con_Print("Connection refused\n"); return 0; } - Con_Printf("LHNET_Read: recvfrom returned error: %s\n", LHNETPRIVATE_StrError()); + Con_DPrintf("LHNET_Read: recvfrom returned error: %s\n", LHNETPRIVATE_StrError()); } } #endif @@ -1171,7 +1175,7 @@ int LHNET_Write(lhnetsocket_t *lhnetsocket, const void *content, int contentleng { if (SOCKETERRNO == EWOULDBLOCK) return 0; - Con_Printf("LHNET_Write: sendto returned error: %s\n", LHNETPRIVATE_StrError()); + Con_DPrintf("LHNET_Write: sendto returned error: %s\n", LHNETPRIVATE_StrError()); } } #ifdef SUPPORTIPV6 @@ -1182,7 +1186,7 @@ int LHNET_Write(lhnetsocket_t *lhnetsocket, const void *content, int contentleng { if (SOCKETERRNO == EWOULDBLOCK) return 0; - Con_Printf("LHNET_Write: sendto returned error: %s\n", LHNETPRIVATE_StrError()); + Con_DPrintf("LHNET_Write: sendto returned error: %s\n", LHNETPRIVATE_StrError()); } } #endif