]> Repositorios git - sula.git/commitdiff
WIP
authorJavier Sagredo <[email protected]>
Sun, 31 May 2026 23:28:19 +0000 (01:28 +0200)
committerJavier Sagredo <[email protected]>
Sun, 31 May 2026 23:28:19 +0000 (01:28 +0200)
.gitignore
README.md
cert.pl
sula.pl

index 425c5829094b7a0f9374bb6e1ae62a4059eacf70..5efcf514adf8db38708c55c07a602dc03dc1be61 100644 (file)
@@ -1,2 +1,3 @@
-identity.p12
+cert.pem
+key.pem
 site
\ No newline at end of file
index c28809341f12eeda27857ce00db350ebe0ec832e..0bb23e9034c5de95cdfe5657bea586762d4d54b1 100644 (file)
--- 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 f3d4d2ca4e77500773ec117fc5c468359653e8f6..c5bf3ee8ea14d585bbced9d46f25505d26009ac9 100644 (file)
--- 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 17ab2bc85e8df77ef2170207daf38367f94ff5bf..8b911d7b6f0214f29344934eecaa1accc3235c6b 100755 (executable)
--- 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),
     !.