[master] fbbcf28 Add the vtc variable remote.path -- the path for a UDS.
Geoff Simmons
geoff at uplex.de
Thu Feb 22 09:23:10 UTC 2018
commit fbbcf28b3ff90ca8f804b49d0590801d887c6416
Author: Geoff Simmons <geoff at uplex.de>
Date: Sun Feb 18 17:08:28 2018 +0100
Add the vtc variable remote.path -- the path for a UDS.
NULL for an IP address (matches <undef>).
Also verify that remote.ip and remote.port correspond to the
bogo-IP 0.0.0.0:0 for a UDS connection.
diff --git a/bin/varnishtest/tests/a00020.vtc b/bin/varnishtest/tests/a00020.vtc
new file mode 100644
index 0000000..aba786e
--- /dev/null
+++ b/bin/varnishtest/tests/a00020.vtc
@@ -0,0 +1,34 @@
+varnishtest "vtc remote.ip, remote.port and remote.path"
+
+server s1 {
+ rxreq
+ expect remote.ip == "${localhost}"
+ expect remote.port > 0
+ expect remote.path == <undef>
+ txresp
+} -start
+
+varnish v1 -vcl+backend {} -start
+
+client c1 {
+ txreq
+ rxresp
+ expect remote.ip == "${v1_addr}"
+ expect remote.port == "${v1_port}"
+ expect remote.path == <undef>
+} -run
+
+varnish v1 -stop
+
+server s1 -wait
+server s1 -start
+
+varnish v2 -arg "-a ${tmpdir}/v2.sock" -vcl+backend {} -start
+
+client c1 -connect "${tmpdir}/v2.sock" {
+ txreq
+ rxresp
+ expect remote.ip == "0.0.0.0"
+ expect remote.port == 0
+ expect remote.path == "${tmpdir}/v2.sock"
+} -run
diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c
index 62df449..8a9f911 100644
--- a/bin/varnishtest/vtc_http.c
+++ b/bin/varnishtest/vtc_http.c
@@ -277,6 +277,7 @@ http_count_header(char * const *hh, const char *hdr)
*
* - remote.ip
* - remote.port
+ * - remote.path
* - req.method
* - req.url
* - req.proto
@@ -300,6 +301,8 @@ cmd_var_resolve(struct http *hp, char *spec)
return(hp->rem_ip);
if (!strcmp(spec, "remote.port"))
return(hp->rem_port);
+ if (!strcmp(spec, "remote.path"))
+ return(hp->rem_path);
if (!strcmp(spec, "req.method"))
return(hp->req[0]);
if (!strcmp(spec, "req.url"))
@@ -1871,12 +1874,15 @@ http_process(struct vtclog *vl, const char *spec, int sock, int *sfd,
hp->gziplevel = 0;
hp->gzipresidual = -1;
- if (*addr != '/')
+ if (*addr != '/') {
VTCP_hisname(sock, hp->rem_ip, VTCP_ADDRBUFSIZE, hp->rem_port,
VTCP_PORTBUFSIZE);
+ hp->rem_path = NULL;
+ }
else {
strcpy(hp->rem_ip, "0.0.0.0");
strcpy(hp->rem_port, "0");
+ hp->rem_path = strdup(addr);
}
parse_string(spec, http_cmds, hp, vl);
if (hp->h2)
diff --git a/bin/varnishtest/vtc_http.h b/bin/varnishtest/vtc_http.h
index f944f36..a6c5a95 100644
--- a/bin/varnishtest/vtc_http.h
+++ b/bin/varnishtest/vtc_http.h
@@ -14,6 +14,7 @@ struct http {
char *rxbuf;
char *rem_ip;
char *rem_port;
+ char *rem_path;
int prxbuf;
char *body;
unsigned bodyl;
More information about the varnish-commit
mailing list