diff options
| author | Syndamia <kamen@syndamia.com> | 2024-01-07 18:50:17 +0200 |
|---|---|---|
| committer | Syndamia <kamen@syndamia.com> | 2024-01-07 18:50:23 +0200 |
| commit | 51fd795aa6f25ef3b06e5ddf2a30a349d9c0c5db (patch) | |
| tree | 5d010333795d344dd335d500c1d9d5a530f6ac43 | |
| parent | 040b61cd625848e09ea2d3376f3b74382efe06a9 (diff) | |
| download | pico-web-51fd795aa6f25ef3b06e5ddf2a30a349d9c0c5db.tar pico-web-51fd795aa6f25ef3b06e5ddf2a30a349d9c0c5db.tar.gz pico-web-51fd795aa6f25ef3b06e5ddf2a30a349d9c0c5db.zip | |
(server-connection) Added disconnected messages to log
| -rw-r--r-- | src/server-connection.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/server-connection.c b/src/server-connection.c index 34d3bbe..466b259 100644 --- a/src/server-connection.c +++ b/src/server-connection.c @@ -12,6 +12,8 @@ sds constructFilePath(const sds root, const char* file); void sanitizeAddress(char* address); sds* findVhost(char* address, sds** vhosts, const int vhostsc); +#define DISCONNECT printf("[%s@%d] Disconnected\n", client, fd_client); return; + void on_connection(const char* client, const int fd_client, sds **vhosts, const int vhostsc) { printf("[%s@%d] Connected successfully!\n", client, fd_client); @@ -27,7 +29,8 @@ void on_connection(const char* client, const int fd_client, sds **vhosts, const const sds *vhost = findVhost(address, vhosts, vhostsc); if (vhost == NULL) { fprintf(stderr, "[%s@%d] Unknown username in address %s\n", client, fd_client, address); - return; + printf("[%s@%d] Requested %s\n", client, fd_client, address); + DISCONNECT } /* Try to open the requested file or the error file */ @@ -67,7 +70,7 @@ void on_connection(const char* client, const int fd_client, sds **vhosts, const if (fd < 0) { fprintf(stderr, "[%s@%d] Error opening error file %s\n", client, fd_client, filePath); sdsfree(filePath); - return; + DISCONNECT } /* Send the file to the client */ @@ -84,6 +87,7 @@ void on_connection(const char* client, const int fd_client, sds **vhosts, const /* Finalize */ close(fd); printf("[%s@%d] Served!\n", client, fd_client); + DISCONNECT } sds constructFilePath(const sds root, const char* file) { |
