diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..323cc20 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,9 @@ +kind: pipeline +type: docker +name: default + +steps: + - name: build + image: gcc:13 + commands: + - make diff --git a/server.c b/server.c index bee94ce..4c1cd53 100644 --- a/server.c +++ b/server.c @@ -20,6 +20,10 @@ int open_server(int port) { perror("Cannot create socket"); return -1; } + if (setsockopt(serverSocket, SOL_SOCKET, SO_REUSEADDR, &(int){1}, + sizeof(int)) == -1) { + perror("reuseaddr"); + } struct sockaddr_in address; memset(&address, 0, sizeof(address)); address.sin_family = AF_INET; @@ -52,7 +56,8 @@ SSL_CTX *init_ssl_ctx(void) { "methods available, cannot enable TLS compression.\n"); } else { for (int i = 0; i < sk_SSL_COMP_num(s); i++) { - const char *name = SSL_COMP_get_name(sk_SSL_COMP_value(s, i)); + const SSL_COMP *comp = sk_SSL_COMP_value(s, i); + const char *name = SSL_COMP_get_name(comp); printf("Found compression method: %s\n", name); } } @@ -100,20 +105,8 @@ int load_certificates(SSL_CTX *ctx, const char *cert_file, } int handle_request(SSL *ssl, int fd) { - const COMP_METHOD *comp = SSL_get_current_compression(ssl); - if (comp == NULL) { - printf("No compression\n"); - } else { - const char *name = COMP_get_name(comp); - if (name == NULL) { - fprintf(stderr, "Cannot get compression name!\n"); - } else { - printf("Compression: %s\n", name); - } - } - char buf[BUF_LEN]; - int sd, bytes; + int bytes; char output[] = "HTTP/1.1 200 OK\r\nContent-Length: 13\r\nContent-Type: " "text/plain\r\n\r\nHello World!\n"; @@ -132,13 +125,11 @@ int handle_request(SSL *ssl, int fd) { bytes = SSL_read(ssl, buf, sizeof(buf)); if (bytes > 0) { buf[bytes] = 0; - printf("Client msg: \"%s", buf); SSL_write(ssl, output, strlen(output)); } else { ERR_print_errors_fp(stderr); } } - sd = SSL_get_fd(ssl); SSL_free(ssl); return 0; } @@ -180,8 +171,7 @@ int main(int argc, char **argv) { socklen_t len = sizeof(addr); SSL *ssl; - int client = accept(server, (struct sockaddr *)&addr, - &len); + int client = accept(server, (struct sockaddr *)&addr, &len); printf("Connection: %s:%d\n", inet_ntoa(addr.sin_addr), ntohs(addr.sin_port)); ssl = SSL_new(ctx);