add remote IP logging

This commit is contained in:
Xuan Sang LE 2018-03-14 10:51:46 +01:00
parent 3c170bb2f9
commit 5f12b8917a
2 changed files with 14 additions and 1 deletions

View File

@ -952,11 +952,15 @@ int execute_plugin(void* client, const char *path, const char *method, dictionar
//load the plugin
if((plugin = plugin_lookup(pname)) == NULL)
if((plugin= plugin_load(pname)) == NULL)
{
if(orgs) free(orgs);
return -1;
}
// load the function
fn = (void (*)(void*, const char *, const char*, dictionary))dlsym(plugin->handle, PLUGIN_HANDLER);
if ((error = dlerror()) != NULL)
{
if(orgs) free(orgs);
LOG("Problem when finding %s method from %s : %s \n", PLUGIN_HANDLER, pname,error);
return -1;
}

11
httpd.c
View File

@ -189,7 +189,7 @@ int main(int argc, char* argv[])
struct sockaddr_in client_name;
socklen_t client_name_len = sizeof(client_name);
pthread_t newthread;
char* client_ip = NULL;
// ignore the broken PIPE error when writing
//or reading to/from a closed socked connection
signal(SIGPIPE, SIG_IGN);
@ -224,6 +224,15 @@ int main(int argc, char* argv[])
perror("Cannot accept client request\n");
continue;
}
/*
get the remote IP
*/
if (client_name.sin_family == AF_INET)
{
client_ip = inet_ntoa(client_name.sin_addr);
LOG("Client IP: %s\n", client_ip);
}
//return &(((struct sockaddr_in6*)sa)->sin6_addr);
/* accept_request(client_sock); */
client->sock = client_sock;
server_config.connection++;