"GOT", but the "O" is a cute, smiling sun Index | Thread

From:
Omar Polo <op@omarpolo.com>
Subject:
Re: gotwebd.conf: remove fcgi_socket keyword
To:
Stefan Sperling <stsp@stsp.name>
Cc:
gameoftrees@openbsd.org
Date:
Sat, 20 Aug 2022 17:08:36 +0200

Download raw body.

On 2022/08/20 06:16:50 +0200, Stefan Sperling <stsp@stsp.name> wrote:
> Drop the fgci_socket keyword and move "listen on" into the per-server context.
> 
> A valid config now looks like this:
> 
> [[[
> prefork 1
> 
> server "localhost-unix" {
> 	repos_path "/got/public"
> 	unix_socket_name "/run/gotweb.sock"
> }
> 
> server "localhost-tcp" {
> 	repos_path "/got/public"
> 	unix_socket		off
> 	listen on 127.0.0.1
> 	port 9000
> }
> ]]]
> 
> ok?

i like it, ok for me.

I had an issue with it: gotwebd binds the wrong port.  I think there's
an extra `htons' in the fcgiport rule.  with that dropped, i can
happily have gotwebd listen on localhost:9000.

> My end goal is to allow a server instance to listen on multiple ports
> and/or addresses, like this:
> 
> server "default" {
> 	unix_socket_name "/run/gotweb.sock"
> 	listen on 127.0.0.1 port 9000
> 	listen on ::1 port 9000
> 	listen on 192.168.1.1 port 9001
> }

would be nice to have

	listen on socket "/run/gotweb.sock"

too for consistency while we're here.  What do you think?

diff /home/op/w/got
commit - 438e87b74a836380405f370795b7846968f79212
path + /home/op/w/got
blob - 8f4ee1d28753902fcec64871a26da0743969ae6d
file + gotwebd/parse.y
--- gotwebd/parse.y
+++ gotwebd/parse.y
@@ -119,7 +119,7 @@ typedef struct {
 %token	LOGO_URL SHOW_REPO_OWNER SHOW_REPO_AGE SHOW_REPO_DESCRIPTION
 %token	MAX_REPOS_DISPLAY REPOS_PATH MAX_COMMITS_DISPLAY ON ERROR
 %token	SHOW_SITE_OWNER SHOW_REPO_CLONEURL PORT PREFORK
-%token	UNIX_SOCKET UNIX_SOCKET_NAME SERVER CHROOT CUSTOM_CSS
+%token	UNIX_SOCKET SOCKET SERVER CHROOT CUSTOM_CSS
 
 %token	<v.string>	STRING
 %type	<v.port>	fcgiport
@@ -159,7 +159,7 @@ fcgiport	: NUMBER {
 				yyerror("invalid port: %lld", $1);
 				YYERROR;
 			}
-			$$ = htons($1);
+			$$ = $1;
 		}
 		| STRING {
 			int	 val;
@@ -360,19 +360,19 @@ serveropts1	: REPOS_PATH STRING {
 		| UNIX_SOCKET boolean {
 			new_srv->unix_socket = $2;
 		}
-		| UNIX_SOCKET_NAME STRING {
+		| LISTEN ON SOCKET STRING {
 			n = snprintf(new_srv->unix_socket_name,
 			    sizeof(new_srv->unix_socket_name), "%s%s",
 			    strlen(gotwebd->httpd_chroot) ?
-			    gotwebd->httpd_chroot : D_HTTPD_CHROOT, $2);
+			    gotwebd->httpd_chroot : D_HTTPD_CHROOT, $4);
 			if (n < 0 ||
 			    (size_t)n >= sizeof(new_srv->unix_socket_name)) {
 				yyerror("%s: unix_socket_name truncated",
 				    __func__);
-				free($2);
+				free($4);
 				YYERROR;
 			}
-			free($2);
+			free($4);
 		}
 		;
 
@@ -442,8 +442,8 @@ lookup(char *s)
 		{ "site_link",			SITE_LINK },
 		{ "site_name",			SITE_NAME },
 		{ "site_owner",			SITE_OWNER },
+		{ "socket",			SOCKET },
 		{ "unix_socket",		UNIX_SOCKET },
-		{ "unix_socket_name",		UNIX_SOCKET_NAME },
 	};
 	const struct keywords *p;