vlc_value_t lockval;
int i;
+ if( psz_hostname == NULL )
+ psz_hostname = "";
+
psz_host = strdup( psz_hostname );
if( psz_host == NULL )
{
cl->i_mode = HTTPD_CLIENT_BIDIR;
}
-char* httpd_ClientIP( httpd_client_t *cl )
+char* httpd_ClientIP( httpd_client_t *cl, char *psz_ip )
{
- int i;
- char sz_ip[NI_MAXNUMERICHOST + 2];
-
- i = vlc_getnameinfo( (const struct sockaddr *)&cl->sock, cl->i_sock_size,
- sz_ip+1, NI_MAXNUMERICHOST, NULL, NI_NUMERICHOST );
-
- if( i != 0 )
- return NULL;
-
- /* semi-colon in address => must add bracket for HTTP */
- if( strchr( sz_ip + 1, ':' ) != NULL )
- {
- sz_ip[0] = '[';
- i = strlen( sz_ip );
- sz_ip[i++] = ']';
- sz_ip[i] = '\0';
+ return net_GetPeerAddress( cl->fd, psz_ip, NULL ) ? NULL : psz_ip;
+}
- return strdup(sz_ip);
- }
-
- return strdup(sz_ip + 1);
+char* httpd_ServerIP( httpd_client_t *cl, char *psz_ip )
+{
+ return net_GetSockAddress( cl->fd, psz_ip, NULL ) ? NULL : psz_ip;
}
static void httpd_ClientClean( httpd_client_t *cl )
{
if( answer && ( url->p_acl != NULL ) )
{
- char *ip = httpd_ClientIP( cl );
- if( ip != NULL )
+ char ip[NI_MAXNUMERICHOST];
+
+ if( httpd_ClientIP( cl, ip ) != NULL )
{
if( ACL_Check( url->p_acl, ip ) )
{
b_hosts_failed = VLC_TRUE;
- free( ip );
break;
}
- free( ip );
}
+ else
+ b_hosts_failed = VLC_TRUE;
}
if( answer && ( *url->psz_user || *url->psz_password ) )