@@ -814,8 +814,7 @@ STATUS getStunAddr(PStunIpAddrContext pStunIpAddrCtx)
814814 // # if not defined (USE_DUAL_STACK_CANDIDATES)
815815 // ipv6Resolved = TRUE;
816816
817- DLOGD ("Resolving STUN address..." );
818-
817+ DLOGD ("Resolving STUN server address for hostname: %s" , pStunIpAddrCtx -> hostname );
819818
820819 errCode = getaddrinfo (pStunIpAddrCtx -> hostname , NULL , NULL , & res );
821820 if (errCode != 0 ) {
@@ -824,21 +823,21 @@ STATUS getStunAddr(PStunIpAddrContext pStunIpAddrCtx)
824823 } else {
825824 for (rp = res ; rp != NULL && !(ipv4Resolved && ipv6Resolved ); rp = rp -> ai_next ) {
826825 if (!ipv4Resolved && rp -> ai_family == AF_INET ) {
827- DLOGD ("Found an IPv4 STUN addresss" );
826+ DLOGD ("Found an IPv4 STUN addresss for hostname: %s" , pStunIpAddrCtx -> hostname );
828827 ipv4Addr = (struct sockaddr_in * ) rp -> ai_addr ;
829828 pStunIpAddrCtx -> kvsIpAddresses .ipv4Address .family = KVS_IP_FAMILY_TYPE_IPV4 ;
830829 pStunIpAddrCtx -> kvsIpAddresses .ipv4Address .port = 0 ;
831830 MEMCPY (pStunIpAddrCtx -> kvsIpAddresses .ipv4Address .address , & ipv4Addr -> sin_addr , IPV4_ADDRESS_LENGTH );
832831 ipv4Resolved = TRUE;
833832 } else if (!ipv6Resolved && rp -> ai_family == AF_INET6 ) {
834- DLOGD ("Found an IPv6 STUN addresss" );
833+ DLOGD ("Found an IPv6 STUN addresss for hostname: %s" , pStunIpAddrCtx -> hostname );
835834 ipv6Addr = (struct sockaddr_in6 * ) rp -> ai_addr ;
836835 pStunIpAddrCtx -> kvsIpAddresses .ipv6Address .family = KVS_IP_FAMILY_TYPE_IPV6 ;
837836 pStunIpAddrCtx -> kvsIpAddresses .ipv6Address .port = 0 ;
838837 MEMCPY (pStunIpAddrCtx -> kvsIpAddresses .ipv6Address .address , & ipv6Addr -> sin6_addr , IPV6_ADDRESS_LENGTH );
839838 ipv6Resolved = TRUE;
840839 } else {
841- DLOGD ("Invalid family STUN addresss" );
840+ DLOGD ("Invalid family STUN addresss for hostname: %s" , pStunIpAddrCtx -> hostname );
842841 }
843842 }
844843 freeaddrinfo (res );
@@ -884,6 +883,7 @@ STATUS onSetStunServerIp(UINT64 customData, PCHAR url, PDualKvsIpAddresses pIpAd
884883 CHK_ERR (getStunAddr (pWebRtcClientContext -> pStunIpAddrCtx ) == STATUS_SUCCESS , retStatus , "Failed to resolve after cache expiry" );
885884 }
886885 MEMCPY (pIpAddresses , & pWebRtcClientContext -> pStunIpAddrCtx -> kvsIpAddresses .ipv4Address , SIZEOF (pWebRtcClientContext -> pStunIpAddrCtx -> kvsIpAddresses .ipv4Address ));
886+ MEMCPY (pIpAddresses , & pWebRtcClientContext -> pStunIpAddrCtx -> kvsIpAddresses .ipv6Address , SIZEOF (pWebRtcClientContext -> pStunIpAddrCtx -> kvsIpAddresses .ipv6Address ));
887887 } else {
888888 DLOGE ("Initialization failed" );
889889 }
@@ -906,7 +906,8 @@ PVOID resolveStunIceServerIp(PVOID args)
906906 UNUSED_PARAM (args );
907907 PWebRtcClientContext pWebRtcClientContext = getWebRtcClientInstance ();
908908 BOOL locked = FALSE;
909- CHAR addressResolved [KVS_IP_ADDRESS_STRING_BUFFER_LEN + 1 ] = {'\0' };
909+ CHAR addressResolvedIPv4 [KVS_IP_ADDRESS_STRING_BUFFER_LEN + 1 ] = {'\0' };
910+ CHAR addressResolvedIPv6 [KVS_IP_ADDRESS_STRING_BUFFER_LEN + 1 ] = {'\0' };
910911 PCHAR pRegion ;
911912 PCHAR pHostnamePostfix ;
912913 UINT64 stunDnsResolutionStartTime = 0 ;
@@ -932,9 +933,20 @@ PVOID resolveStunIceServerIp(PVOID args)
932933 KINESIS_VIDEO_STUN_URL_WITHOUT_PORT , pRegion , pHostnamePostfix );
933934 stunDnsResolutionStartTime = GETTIME ();
934935 if (getStunAddr (pWebRtcClientContext -> pStunIpAddrCtx ) == STATUS_SUCCESS ) {
935- getIpAddrStr (& pWebRtcClientContext -> pStunIpAddrCtx -> kvsIpAddresses .ipv4Address , addressResolved , ARRAY_SIZE (addressResolved ));
936- DLOGI ("ICE Server address for %s with getaddrinfo: %s" , pWebRtcClientContext -> pStunIpAddrCtx -> hostname , addressResolved );
937- pWebRtcClientContext -> pStunIpAddrCtx -> isIpInitialized = TRUE;
936+ if (pWebRtcClientContext -> pStunIpAddrCtx -> kvsIpAddresses .ipv4Address .family == KVS_IP_FAMILY_TYPE_IPV4 ) {
937+ // If IP family is set, then there must have been an IPv4 address resolved.
938+ getIpAddrStr (& pWebRtcClientContext -> pStunIpAddrCtx -> kvsIpAddresses .ipv4Address , addressResolvedIPv4 , ARRAY_SIZE (addressResolvedIPv4 ));
939+ DLOGI ("ICE Server address for %s with getaddrinfo: %s" , pWebRtcClientContext -> pStunIpAddrCtx -> hostname , addressResolvedIPv4 );
940+ pWebRtcClientContext -> pStunIpAddrCtx -> isIpInitialized = TRUE;
941+ }
942+ if (pWebRtcClientContext -> pStunIpAddrCtx -> kvsIpAddresses .ipv6Address .family == KVS_IP_FAMILY_TYPE_IPV4 ) {
943+ // If IP family is set, then there must have been an IPv6 address resolved.
944+ getIpAddrStr (& pWebRtcClientContext -> pStunIpAddrCtx -> kvsIpAddresses .ipv6Address , addressResolvedIPv6 , ARRAY_SIZE (addressResolvedIPv6 ));
945+ DLOGI ("ICE Server address for %s with getaddrinfo: %s" , pWebRtcClientContext -> pStunIpAddrCtx -> hostname , addressResolvedIPv6 );
946+ pWebRtcClientContext -> pStunIpAddrCtx -> isIpInitialized = TRUE;
947+
948+ }
949+
938950 } else {
939951 DLOGE ("Failed to resolve %s" , pWebRtcClientContext -> pStunIpAddrCtx -> hostname );
940952 }
0 commit comments