[master] 0f5b435 Support Unix domain sockets for the -b arg.

Geoff Simmons geoff at uplex.de
Mon Mar 12 09:45:10 UTC 2018


commit 0f5b4350bc4ab59f38c36a94d6395f11d63aed1f
Author: Geoff Simmons <geoff at uplex.de>
Date:   Mon Feb 19 02:48:30 2018 +0100

    Support Unix domain sockets for the -b arg.

diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c
index d6a4141..6e33f8d 100644
--- a/bin/varnishd/mgt/mgt_main.c
+++ b/bin/varnishd/mgt/mgt_main.c
@@ -593,7 +593,12 @@ main(int argc, char * const *argv)
 			AN(vsb);
 			VSB_printf(vsb, "vcl 4.0;\n");
 			VSB_printf(vsb, "backend default {\n");
-			VSB_printf(vsb, "    .host = \"%s\";\n", optarg);
+			if (*optarg != '/')
+				VSB_printf(vsb, "    .host = \"%s\";\n",
+					   optarg);
+			else
+				VSB_printf(vsb, "    .path = \"%s\";\n",
+					   optarg);
 			VSB_printf(vsb, "}\n");
 			AZ(VSB_finish(vsb));
 			fa->src = strdup(VSB_data(vsb));
diff --git a/bin/varnishtest/tests/b00061.vtc b/bin/varnishtest/tests/b00061.vtc
new file mode 100644
index 0000000..d06f3c6
--- /dev/null
+++ b/bin/varnishtest/tests/b00061.vtc
@@ -0,0 +1,15 @@
+varnishtest "-b arg with a Unix domain socket"
+
+server s1 -listen "${tmpdir}/s1.sock" {
+	rxreq
+	txresp -hdr "s1: got it"
+} -start
+
+varnish v1 -arg "-b ${s1_sock}" -start
+
+client c1 {
+	txreq
+	rxresp
+	expect resp.status == 200
+	expect resp.http.s1 == "got it"
+} -run


More information about the varnish-commit mailing list