From 70e482eaeaac3042d10d8bc1898afbffb3fc8dfa Mon Sep 17 00:00:00 2001 From: =?utf8?q?Cl=C3=A9ment=20Stenac?= Date: Sat, 18 Mar 2006 17:52:31 +0000 Subject: [PATCH] Display IP of client in debug --- include/vlc_httpd.h | 33 +++++++++++++++++++++++++++++++++ include/vlc_objects.h | 1 + src/misc/messages.c | 3 ++- src/misc/objects.c | 6 +++++- src/network/httpd.c | 37 ++++--------------------------------- 5 files changed, 45 insertions(+), 35 deletions(-) diff --git a/include/vlc_httpd.h b/include/vlc_httpd.h index 3edd0f95e7..02b1b44781 100644 --- a/include/vlc_httpd.h +++ b/include/vlc_httpd.h @@ -61,6 +61,39 @@ enum HTTPD_MSG_MAX }; +/* each host run in his own thread */ +struct httpd_host_t +{ + VLC_COMMON_MEMBERS + + httpd_t *httpd; + + /* ref count */ + int i_ref; + + /* address/port and socket for listening at connections */ + char *psz_hostname; + int i_port; + int *fd; + + vlc_mutex_t lock; + + /* all registered url (becarefull that 2 httpd_url_t could point at the same url) + * This will slow down the url research but make my live easier + * All url will have their cb trigger, but only the first one can answer + * */ + int i_url; + httpd_url_t **url; + + int i_client; + httpd_client_t **client; + + /* TLS data */ + tls_server_t *p_tls; +}; + + + enum { HTTPD_PROTO_NONE, diff --git a/include/vlc_objects.h b/include/vlc_objects.h index 79b8f63f33..009b9f5488 100644 --- a/include/vlc_objects.h +++ b/include/vlc_objects.h @@ -61,6 +61,7 @@ #define VLC_OBJECT_XML (-27) #define VLC_OBJECT_OSDMENU (-28) #define VLC_OBJECT_STATS (-29) +#define VLC_OBJECT_HTTPD_HOST (-30) #define VLC_OBJECT_GENERIC (-666) diff --git a/src/misc/messages.c b/src/misc/messages.c index 644101d8ce..c26ab93456 100644 --- a/src/misc/messages.c +++ b/src/misc/messages.c @@ -574,7 +574,8 @@ static void PrintMsg ( vlc_object_t * p_this, msg_item_t * p_item ) case VLC_OBJECT_VOUT: psz_object = "video output"; break; case VLC_OBJECT_AOUT: psz_object = "audio output"; break; case VLC_OBJECT_SOUT: psz_object = "stream output"; break; - case VLC_OBJECT_HTTPD: psz_object = "http daemon"; break; + case VLC_OBJECT_HTTPD: psz_object = "http server"; break; + case VLC_OBJECT_HTTPD_HOST: psz_object = "http server"; break; case VLC_OBJECT_DIALOGS: psz_object = "dialogs provider"; break; case VLC_OBJECT_VLM: psz_object = "vlm"; break; case VLC_OBJECT_ANNOUNCE: psz_object = "announce handler"; break; diff --git a/src/misc/objects.c b/src/misc/objects.c index 95aa7b14b4..919838bfe7 100644 --- a/src/misc/objects.c +++ b/src/misc/objects.c @@ -182,7 +182,11 @@ void * __vlc_object_create( vlc_object_t *p_this, int i_type ) break; case VLC_OBJECT_HTTPD: i_size = sizeof( httpd_t ); - psz_type = "http daemon"; + psz_type = "http server"; + break; + case VLC_OBJECT_HTTPD_HOST: + i_size = sizeof( httpd_host_t ); + psz_type = "http server"; break; case VLC_OBJECT_VLM: i_size = sizeof( vlm_t ); diff --git a/src/network/httpd.c b/src/network/httpd.c index f238ec203a..4c914dbfec 100644 --- a/src/network/httpd.c +++ b/src/network/httpd.c @@ -62,37 +62,6 @@ static void httpd_ClientClean( httpd_client_t *cl ); -/* each host run in his own thread */ -struct httpd_host_t -{ - VLC_COMMON_MEMBERS - - httpd_t *httpd; - - /* ref count */ - int i_ref; - - /* address/port and socket for listening at connections */ - char *psz_hostname; - int i_port; - int *fd; - - vlc_mutex_t lock; - - /* all registered url (becarefull that 2 httpd_url_t could point at the same url) - * This will slow down the url research but make my live easier - * All url will have their cb trigger, but only the first one can answer - * */ - int i_url; - httpd_url_t **url; - - int i_client; - httpd_client_t **client; - - /* TLS data */ - tls_server_t *p_tls; -}; - struct httpd_url_t { httpd_host_t *host; @@ -1079,7 +1048,7 @@ httpd_host_t *httpd_TLSHostNew( vlc_object_t *p_this, const char *psz_hostname, p_tls = NULL; /* create the new host */ - host = vlc_object_create( p_this, sizeof( httpd_host_t ) ); + host = vlc_object_create( p_this, VLC_OBJECT_HTTPD_HOST ); host->httpd = httpd; vlc_mutex_init( httpd, &host->lock ); host->i_ref = 1; @@ -2441,7 +2410,6 @@ static void httpd_HostThread( httpd_host_t *host ) struct sockaddr_storage sock; fd = accept( fd, (struct sockaddr *)&sock, &i_sock_size ); - msg_Info( host, "Accepting" ); if( fd >= 0 ) { int i_state = 0; @@ -2480,11 +2448,14 @@ static void httpd_HostThread( httpd_host_t *host ) if( fd >= 0 ) { httpd_client_t *cl; + char ip[NI_MAXNUMERICHOST]; stats_UpdateInteger( host, STATS_CLIENT_CONNECTIONS, 1, NULL ); stats_UpdateInteger( host, STATS_ACTIVE_CONNECTIONS, 1, NULL ); cl = httpd_ClientNew( fd, &sock, i_sock_size, p_tls ); + httpd_ClientIP( cl, ip ); + msg_Dbg( host, "Connection from %s", ip ); p_tls = NULL; vlc_mutex_lock( &host->lock ); TAB_APPEND( host->i_client, host->client, cl ); -- 2.39.2