RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
RET_VAL_IF(webrtc->dns.client_pa != NULL, WEBRTC_ERROR_INVALID_OPERATION, "client_pa has been already registered");
- RET_VAL_IF(webrtc->dns.client != NULL, WEBRTC_ERROR_INVALID_OPERATION, "client_pa has been already registered");
+ RET_VAL_IF(webrtc->dns.client != NULL, WEBRTC_ERROR_INVALID_OPERATION, "client has been already registered");
ip = __get_my_private_ip();
RET_VAL_IF(ip == NULL, WEBRTC_ERROR_INVALID_OPERATION, "ip is NULL");
LOG_INFO("client_pa[%p] client[%p] name[%s] host[%s] ip[%s]", webrtc->dns.client_pa, webrtc->dns.client, DNSS_REGISTER_NAME, host, ip);
- g_free(ip);
+ webrtc->dns.hostname = g_strdup(host);
+ webrtc->dns.ip = ip;
return WEBRTC_ERROR_NONE;
RET_IF(webrtc->dns.client_pa == NULL, "client_pa is NULL");
RET_IF(webrtc->dns.client == NULL, "client is NULL");
- LOG_INFO("client_pa[%p] client[%p]", webrtc->dns.client_pa, webrtc->dns.client);
+ LOG_INFO("client_pa[%p] client[%p] hostname[%s]", webrtc->dns.client_pa, webrtc->dns.client, webrtc->dns.hostname);
DNSServiceRefDeallocate(webrtc->dns.client_pa);
DNSServiceRefDeallocate(webrtc->dns.client);
+ g_free(webrtc->dns.hostname);
+ g_free(webrtc->dns.ip);
webrtc->dns.client_pa = NULL;
webrtc->dns.client = NULL;
+ webrtc->dns.hostname = NULL;
+ webrtc->dns.ip = NULL;
+}
+
+gchar *_replace_ip_with_hostname(webrtc_s *webrtc, const gchar *candidate)
+{
+ GString *candidate_str;
+
+ RET_VAL_IF(webrtc == NULL, NULL, "webrtc is NULL");
+ RET_VAL_IF(candidate == NULL, NULL, "candidate is NULL");
+
+ if (!webrtc->ini.general.conceal_private_ip)
+ return NULL;
+
+ RET_VAL_IF(webrtc->dns.hostname == NULL, NULL, "dns.hostname is NULL");
+ RET_VAL_IF(webrtc->dns.ip == NULL, NULL, "dns.ip is NULL");
+
+ candidate_str = g_string_new(candidate);
+ if (g_string_replace(candidate_str, webrtc->dns.ip, webrtc->dns.hostname, 1) > 0)
+ LOG_INFO("%s", candidate_str->str);
+
+ return g_string_free(candidate_str, FALSE);
}
//LCOV_EXCL_STOP
{
webrtc_s *webrtc = (webrtc_s *)user_data;
gchar *_candidate;
+ gchar *candidate_with_hostname = NULL;
char *_param_candidate;
RET_IF(webrtcbin == NULL, "webrtcbin is NULL");
LOG_DEBUG("webrtc[%p] mlineindex[%u] candidate[%s]", webrtc, mlineindex, candidate);
- _candidate = __make_ice_candidate_message(mlineindex, candidate);
+ candidate_with_hostname = _replace_ip_with_hostname(webrtc, (const gchar *)candidate);
+ _candidate = __make_ice_candidate_message(mlineindex, candidate_with_hostname ? candidate_with_hostname : candidate);
+ g_free(candidate_with_hostname);
if (!_candidate)
return;