mirror of
https://github.com/pi-hole/FTL.git
synced 2024-10-26 16:52:18 +02:00
Rename existing telnet socket functions to contain "telnet" in their names to avoid confusion when adding Unix sockets
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
@@ -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')
|
||||
|
||||
@@ -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;
|
||||
|
||||
+2
-2
@@ -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);
|
||||
|
||||
+11
-11
@@ -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));
|
||||
Reference in New Issue
Block a user