add www logging
This commit is contained in:
parent
19440f3654
commit
4498a11ab5
1
bbs.h
1
bbs.h
@ -227,6 +227,7 @@ extern void chomp(char *string);
|
||||
|
||||
#if defined(ENABLE_WWW)
|
||||
extern void www_init();
|
||||
extern void *www_logger(void * cls, const char * uri, struct MHD_Connection *con);
|
||||
extern void www_request_completed(void *cls, struct MHD_Connection *connection, void **con_cls, enum MHD_RequestTerminationCode toe);
|
||||
extern int www_handler(void * cls, struct MHD_Connection * connection, const char * url, const char * method, const char * version, const char * upload_data, size_t * upload_data_size, void ** ptr);
|
||||
extern char *www_email_summary(struct user_record *user);
|
||||
|
2
main.c
2
main.c
@ -697,7 +697,7 @@ void server(int port) {
|
||||
#if defined(ENABLE_WWW)
|
||||
if (conf.www_server && conf.www_path != NULL) {
|
||||
www_init();
|
||||
www_daemon = MHD_start_daemon(MHD_USE_SELECT_INTERNALLY, conf.www_port, NULL, NULL, &www_handler, NULL, MHD_OPTION_NOTIFY_COMPLETED, &www_request_completed, NULL, MHD_OPTION_END);
|
||||
www_daemon = MHD_start_daemon(MHD_USE_SELECT_INTERNALLY, conf.www_port, NULL, NULL, &www_handler, NULL, MHD_OPTION_NOTIFY_COMPLETED, &www_request_completed, NULL, MHD_OPTION_URI_LOG_CALLBACK, &www_logger, NULL, MHD_OPTION_END);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
11
www.c
11
www.c
@ -6,6 +6,8 @@
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <b64/cdecode.h>
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
#include "bbs.h"
|
||||
|
||||
#define GET 1
|
||||
@ -14,6 +16,7 @@
|
||||
#define POSTBUFFERSIZE 65536
|
||||
|
||||
extern struct bbs_config conf;
|
||||
extern char *ipaddress;
|
||||
|
||||
struct mime_type {
|
||||
char *ext;
|
||||
@ -33,6 +36,13 @@ struct connection_info_s {
|
||||
struct MHD_PostProcessor *pp;
|
||||
};
|
||||
|
||||
void *www_logger(void * cls, const char * uri, struct MHD_Connection *con) {
|
||||
struct sockaddr_in *so = (struct sockaddr_in *)MHD_get_connection_info(con, MHD_CONNECTION_INFO_CLIENT_ADDRESS)->client_addr;
|
||||
ipaddress = strdup(inet_ntoa(so->sin_addr));
|
||||
dolog("%s", uri);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void www_request_completed(void *cls, struct MHD_Connection *connection, void **con_cls, enum MHD_RequestTerminationCode toe) {
|
||||
struct connection_info_s *con_info = *con_cls;
|
||||
int i;
|
||||
@ -66,6 +76,7 @@ void www_request_completed(void *cls, struct MHD_Connection *connection, void **
|
||||
|
||||
free(con_info->url);
|
||||
free(con_info);
|
||||
free(ipaddress);
|
||||
}
|
||||
|
||||
static int iterate_post (void *coninfo_cls, enum MHD_ValueKind kind, const char *key, const char *filename, const char *content_type, const char *transfer_encoding, const char *data, uint64_t off, size_t size) {
|
||||
|
Reference in New Issue
Block a user