Added IP to logs
This commit is contained in:
parent
641124174a
commit
254d73a72e
8
bbs.c
8
bbs.c
@ -25,6 +25,8 @@ int gSocket;
|
|||||||
int usertimeout;
|
int usertimeout;
|
||||||
int timeoutpaused;
|
int timeoutpaused;
|
||||||
|
|
||||||
|
char *ipaddress;
|
||||||
|
|
||||||
void dolog(char *fmt, ...) {
|
void dolog(char *fmt, ...) {
|
||||||
char buffer[512];
|
char buffer[512];
|
||||||
struct tm time_now;
|
struct tm time_now;
|
||||||
@ -48,7 +50,7 @@ void dolog(char *fmt, ...) {
|
|||||||
vsnprintf(buffer, 512, fmt, ap);
|
vsnprintf(buffer, 512, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
fprintf(logfptr, "%02d:%02d:%02d %s\n", time_now.tm_hour, time_now.tm_min, time_now.tm_sec, buffer);
|
fprintf(logfptr, "%02d:%02d:%02d [%s] %s\n", time_now.tm_hour, time_now.tm_min, time_now.tm_sec, ipaddress, buffer);
|
||||||
|
|
||||||
fclose(logfptr);
|
fclose(logfptr);
|
||||||
}
|
}
|
||||||
@ -658,7 +660,7 @@ void display_info(int socket) {
|
|||||||
s_getc(socket);
|
s_getc(socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
void runbbs(int socket, char *config_path) {
|
void runbbs(int socket, char *config_path, char *ip) {
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
char password[17];
|
char password[17];
|
||||||
|
|
||||||
@ -676,6 +678,8 @@ void runbbs(int socket, char *config_path) {
|
|||||||
lua_State *L;
|
lua_State *L;
|
||||||
int do_internal_login = 0;
|
int do_internal_login = 0;
|
||||||
|
|
||||||
|
ipaddress = ip;
|
||||||
|
|
||||||
write(socket, iac_echo, 3);
|
write(socket, iac_echo, 3);
|
||||||
write(socket, iac_sga, 3);
|
write(socket, iac_sga, 3);
|
||||||
|
|
||||||
|
2
bbs.h
2
bbs.h
@ -133,7 +133,7 @@ struct user_record {
|
|||||||
};
|
};
|
||||||
|
|
||||||
extern void dolog(char *fmt, ...);
|
extern void dolog(char *fmt, ...);
|
||||||
extern void runbbs(int sock, char *config);
|
extern void runbbs(int sock, char *config, char *ipaddress);
|
||||||
extern struct fido_addr *parse_fido_addr(const char *str);
|
extern struct fido_addr *parse_fido_addr(const char *str);
|
||||||
extern void s_putchar(int socket, char c);
|
extern void s_putchar(int socket, char c);
|
||||||
extern void s_putstring(int socket, char *c);
|
extern void s_putstring(int socket, char *c);
|
||||||
|
3
main.c
3
main.c
@ -9,6 +9,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
#include <string.h>
|
||||||
#include "bbs.h"
|
#include "bbs.h"
|
||||||
|
|
||||||
void sigchld_handler(int s)
|
void sigchld_handler(int s)
|
||||||
@ -72,7 +73,7 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
close(socket_desc);
|
close(socket_desc);
|
||||||
runbbs(client_sock, argv[1]);
|
runbbs(client_sock, argv[1], strdup(inet_ntoa(client.sin_addr)));
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user