From: Javier Sagredo Date: Sun, 31 May 2026 23:28:19 +0000 (+0200) Subject: WIP X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=4731bc618a265b4c8588c44bb1029375f8f057d3;p=sula.git WIP --- diff --git a/.gitignore b/.gitignore index 425c582..5efcf51 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ -identity.p12 +cert.pem +key.pem site \ No newline at end of file diff --git a/README.md b/README.md index c288093..0bb23e9 100644 --- a/README.md +++ b/README.md @@ -111,3 +111,9 @@ banner.pl Reads banner.txt and emits it line-by-line via display_banner/1. - [x] Client certificates - [ ] Load configuration from a configuration file - [ ] Run CGI scripts +- [ ] All status codes +- [ ] Rate limiting +- [ ] Virtual hosting +- [ ] File logging +- [ ] Multi-threading or kind of? +- [ ] Hot reload? diff --git a/cert.pl b/cert.pl index f3d4d2c..c5bf3ee 100644 --- a/cert.pl +++ b/cert.pl @@ -56,7 +56,7 @@ create_new_certificate(Context) :- process_wait(P0, _), cert(Cert), - cert(Key), + key(Key), log_msg("tls", "Generated new certificate `~s` and key `~s`~n", [Cert, Key]), load_existing_certificate(Context). @@ -68,7 +68,7 @@ create_new_certificate(Context) :- % Open a TLS connection on Stream with Context and pass it to F_2 with_tls_connection(S0, Context, Kont) :- setup_call_cleanup( - ( log_msg("tls-conn", "Received connection, authenticating TLS~n", []), + ( log_msg("tls-conn", "Handshaking TLS~n", []), tls_server_negotiate(Context, S0, S, ClientCert), log_msg("tls-conn", "Client cert ~q~n", [ClientCert]) ), diff --git a/sula.pl b/sula.pl index 17ab2bc..8b911d7 100755 --- a/sula.pl +++ b/sula.pl @@ -56,11 +56,11 @@ with_socket(Context, Kont, Kont2) :- addr(Addr), port(Port), ( setup_call_cleanup( - (log_msg("tcp", "Opening socket ~q~n", [Addr:Port]), + (log_msg("socket", "Opening socket ~q~n", [Addr:Port]), socket_server_open(Addr:Port, Socket) ), call(Kont, Context, Socket, Kont2), - (log_msg("tcp", "Closing socket~n", []), + (log_msg("socket", "Closing socket~n", []), socket_server_close(Socket) ) ) @@ -71,9 +71,15 @@ with_socket(Context, Kont, Kont2) :- with_connection_loop(Context, Socket, Kont) :- catch( setup_call_cleanup( - socket_server_accept(Socket, _, S0, []), + ( + log_msg("tcp", "Accepting connections...~n", []), + socket_server_accept(Socket, Client, S0, []), + log_msg("tcp", "Connected client ~q~n", [Client]) + ), with_tls_connection(S0, Context, Kont), - close(S0) + ( close(S0), + log_msg("tcp", "Closed connection for client ~q~n", [Client]) + ) ), Error, handle_conn_error(Error) @@ -88,7 +94,7 @@ handle_conn_error(Error) :- % log_msg("debug", "Re-throwing from conn loop: ~q~n", [Error]), throw(Error). -req_serve(S, ClientCert) :- +req_serve(S, _ClientCert) :- read_request(S, Path, Query), serve(S, Path, Query), !.