diff --git a/Makefile b/Makefile index 5f38b5b7..8ea6d95b 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ # Please see LICENSE file for your rights under this license. DEPS = FTL.h routines.h version.h -OBJ = main.o structs.o log.o daemon.o parser.o signals.o socket.o request.o grep.o setupVars.o args.o flush.o threads.o gc.o config.o database.o +OBJ = main.o structs.o log.o daemon.o parser.o signals.o telnet.o request.o grep.o setupVars.o args.o flush.o threads.o gc.o config.o database.o # Get git commit version and date GIT_BRANCH := $(shell git branch | sed -n 's/^\* //p') diff --git a/main.c b/main.c index ec4db0b3..81767569 100644 --- a/main.c +++ b/main.c @@ -70,10 +70,10 @@ int main (int argc, char* argv[]) { killed = 1; } - pthread_t socket_listenthread; - if(pthread_create( &socket_listenthread, &attr, socket_listenting_thread, NULL ) != 0) + pthread_t telnet_listenthread; + if(pthread_create( &telnet_listenthread, &attr, telnet_listenting_thread, NULL ) != 0) { - logg("Unable to open socket listening thread. Exiting..."); + logg("Unable to open telnet listening thread. Exiting..."); killed = 1; } @@ -152,8 +152,8 @@ int main (int argc, char* argv[]) { logg("Shutting down..."); pthread_cancel(piholelogthread); - pthread_cancel(socket_listenthread); - close_socket(SOCKET); + pthread_cancel(telnet_listenthread); + close_telnet_socket(SOCKET); removepid(); logg("########## FTL terminated! ##########"); return 1; diff --git a/routines.h b/routines.h index 87489877..6b1a17f6 100644 --- a/routines.h +++ b/routines.h @@ -38,10 +38,10 @@ void pihole_log_flushed(bool message); void memory_check(int which); -void close_socket(char type); +void close_telnet_socket(char type); void seom(char server_message[], int sock); void swrite(char server_message[], int sock); -void *socket_listenting_thread(void *args); +void *telnet_listenting_thread(void *args); void process_request(char *client_message, int *sock); bool command(char *client_message, const char* cmd); diff --git a/socket.c b/telnet.c similarity index 93% rename from socket.c rename to telnet.c index 9a88c8c0..7073ba9c 100644 --- a/socket.c +++ b/telnet.c @@ -12,7 +12,7 @@ // The backlog argument defines the maximum length // to which the queue of pending connections for -// socketfd may grow. If a connection request arrives +// telnetfd may grow. If a connection request arrives // when the queue is full, the client may receive an // error with an indication of ECONNREFUSED or, if // the underlying protocol supports retransmission, @@ -21,7 +21,7 @@ #define BACKLOG 5 // File descriptors -int socketfd; +int telnetfd; void saveport(int port) { @@ -38,7 +38,7 @@ void saveport(int port) } } -void bind_to_port(char type, int *socketdescriptor) +void bind_to_telnet_port(char type, int *socketdescriptor) { *socketdescriptor = socket(AF_INET, SOCK_STREAM, 0); @@ -144,7 +144,7 @@ void swrite(char server_message[SOCKETBUFFERLEN], int sock) logg("WARNING: Socket write returned error code %i", errno); } -int listener(int sockfd) +int telnet_listener(int sockfd) { struct sockaddr_in cli_addr; // set all values in the buffer to zero @@ -158,14 +158,14 @@ int listener(int sockfd) return clientsocket; } -void close_socket(char type) +void close_telnet_socket(char type) { switch(type) { case SOCKET: removeport(); // Using global variable here - close(socketfd); + close(telnetfd); break; default: logg("Incompatible socket type %i, cannot close",(int)type); @@ -174,7 +174,7 @@ void close_socket(char type) } } -void *socket_connection_handler_thread(void *socket_desc) +void *telnet_connection_handler_thread(void *socket_desc) { //Get the socket descriptor int sock = *(int*)socket_desc; @@ -231,7 +231,7 @@ void *socket_connection_handler_thread(void *socket_desc) return 0; } -void *socket_listenting_thread(void *args) +void *telnet_listenting_thread(void *args) { int *newsock; // We will use the attributes object later to start all threads in detached mode @@ -246,13 +246,13 @@ void *socket_listenting_thread(void *args) prctl(PR_SET_NAME,"socket listener",0,0,0); // Initialize sockets only after initial log parsing in listenting_thread - bind_to_port(SOCKET, &socketfd); + bind_to_telnet_port(SOCKET, &telnetfd); // Listen as long as FTL is not killed while(!killed) { // Look for new clients that want to connect - int csck = listener(socketfd); + int csck = telnet_listener(telnetfd); // Allocate memory used to transport client socket ID to client listening thread newsock = calloc(1,sizeof(int)); @@ -260,7 +260,7 @@ void *socket_listenting_thread(void *args) pthread_t socket_connection_thread; // Create a new thread - if(pthread_create( &socket_connection_thread, &attr, socket_connection_handler_thread, (void*) newsock ) != 0) + if(pthread_create( &socket_connection_thread, &attr, telnet_connection_handler_thread, (void*) newsock ) != 0) { // Log the error code description logg("WARNING: Unable to open clients processing thread, error: %s", strerror(errno));