Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
b38c3d32
Commit
b38c3d32
authored
Mar 07, 2018
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement VCL var local.endpoint (VCL >= 4.1).
parent
bd74e05a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
17 deletions
+57
-17
cache_vrt_var.c
bin/varnishd/cache/cache_vrt_var.c
+20
-0
c00087.vtc
bin/varnishtest/tests/c00087.vtc
+5
-1
v00025.vtc
bin/varnishtest/tests/v00025.vtc
+16
-0
vcl_var.rst
doc/sphinx/reference/vcl_var.rst
+16
-16
No files found.
bin/varnishd/cache/cache_vrt_var.c
View file @
b38c3d32
...
@@ -747,6 +747,26 @@ GIP(server)
...
@@ -747,6 +747,26 @@ GIP(server)
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
VCL_STRING
VRT_r_local_endpoint
(
VRT_CTX
)
{
struct
sess
*
sp
;
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
if
(
VALID_OBJ
(
ctx
->
req
,
REQ_MAGIC
))
sp
=
ctx
->
req
->
sp
;
else
{
CHECK_OBJ_NOTNULL
(
ctx
->
bo
,
BUSYOBJ_MAGIC
);
sp
=
ctx
->
bo
->
sp
;
}
CHECK_OBJ_NOTNULL
(
sp
->
listen_sock
,
LISTEN_SOCK_MAGIC
);
AN
(
sp
->
listen_sock
->
endpoint
);
return
(
sp
->
listen_sock
->
endpoint
);
}
/*--------------------------------------------------------------------*/
VCL_STRING
VCL_STRING
VRT_r_server_identity
(
VRT_CTX
)
VRT_r_server_identity
(
VRT_CTX
)
{
{
...
...
bin/varnishtest/tests/c00087.vtc
View file @
b38c3d32
...
@@ -5,7 +5,7 @@ server s1 -listen "${tmpdir}/s1.sock" {
...
@@ -5,7 +5,7 @@ server s1 -listen "${tmpdir}/s1.sock" {
txresp
txresp
} -start
} -start
varnish v1 -arg "-a ${tmpdir}/v1.sock" -vcl+backend {
varnish v1 -
syntax 4.1 -
arg "-a ${tmpdir}/v1.sock" -vcl+backend {
acl acl1 {
acl acl1 {
"${localhost}";
"${localhost}";
}
}
...
@@ -16,6 +16,7 @@ varnish v1 -arg "-a ${tmpdir}/v1.sock" -vcl+backend {
...
@@ -16,6 +16,7 @@ varnish v1 -arg "-a ${tmpdir}/v1.sock" -vcl+backend {
set beresp.http.b-local = local.ip;
set beresp.http.b-local = local.ip;
set beresp.http.b-remote = remote.ip;
set beresp.http.b-remote = remote.ip;
set beresp.http.b-compare = local.ip == remote.ip;
set beresp.http.b-compare = local.ip == remote.ip;
set beresp.http.b-endpoint = local.endpoint;
}
}
sub vcl_deliver {
sub vcl_deliver {
...
@@ -28,6 +29,7 @@ varnish v1 -arg "-a ${tmpdir}/v1.sock" -vcl+backend {
...
@@ -28,6 +29,7 @@ varnish v1 -arg "-a ${tmpdir}/v1.sock" -vcl+backend {
set resp.http.server_acl = server.ip ~ acl1;
set resp.http.server_acl = server.ip ~ acl1;
set resp.http.local_acl = local.ip ~ acl1;
set resp.http.local_acl = local.ip ~ acl1;
set resp.http.remote_acl = remote.ip ~ acl1;
set resp.http.remote_acl = remote.ip ~ acl1;
set resp.http.c-endpoint = local.endpoint;
}
}
} -start
} -start
...
@@ -40,11 +42,13 @@ client c1 -connect "${tmpdir}/v1.sock" {
...
@@ -40,11 +42,13 @@ client c1 -connect "${tmpdir}/v1.sock" {
expect resp.http.c-local == "0.0.0.0"
expect resp.http.c-local == "0.0.0.0"
expect resp.http.c-remote == "0.0.0.0"
expect resp.http.c-remote == "0.0.0.0"
expect resp.http.c-compare == "true"
expect resp.http.c-compare == "true"
expect resp.http.c-endpoint == "${tmpdir}/v1.sock"
expect resp.http.b-client == "0.0.0.0"
expect resp.http.b-client == "0.0.0.0"
expect resp.http.b-server == "0.0.0.0"
expect resp.http.b-server == "0.0.0.0"
expect resp.http.b-local == "0.0.0.0"
expect resp.http.b-local == "0.0.0.0"
expect resp.http.b-remote == "0.0.0.0"
expect resp.http.b-remote == "0.0.0.0"
expect resp.http.b-compare == "true"
expect resp.http.b-compare == "true"
expect resp.http.b-endpoint == "${tmpdir}/v1.sock"
expect resp.http.client_acl == "false"
expect resp.http.client_acl == "false"
expect resp.http.server_acl == "false"
expect resp.http.server_acl == "false"
expect resp.http.local_acl == "false"
expect resp.http.local_acl == "false"
...
...
bin/varnishtest/tests/v00025.vtc
View file @
b38c3d32
...
@@ -106,13 +106,27 @@ varnish v1 -syntax 4.0 -errvcl {Symbol not found: 'sess.xid' (Only available whe
...
@@ -106,13 +106,27 @@ varnish v1 -syntax 4.0 -errvcl {Symbol not found: 'sess.xid' (Only available whe
}
}
}
}
varnish v1 -syntax 4.0 -errvcl {Symbol not found: 'local.endpoint' (Only available when 4.1 <= VCL syntax)} {
sub vcl_recv {
set req.http.Endpoint = local.endpoint;
}
}
varnish v1 -syntax 4.0 -errvcl {Symbol not found: 'local.endpoint' (Only available when 4.1 <= VCL syntax)} {
sub vcl_backend_fetch {
set bereq.http.Endpoint = local.endpoint;
}
}
varnish v1 -syntax 4.1 -vcl+backend {
varnish v1 -syntax 4.1 -vcl+backend {
sub vcl_backend_response {
sub vcl_backend_response {
set beresp.http.B-Sess-XID = sess.xid;
set beresp.http.B-Sess-XID = sess.xid;
set beresp.http.B-Endpoint = local.endpoint;
}
}
sub vcl_deliver {
sub vcl_deliver {
set resp.http.C-Sess-XID = sess.xid;
set resp.http.C-Sess-XID = sess.xid;
set resp.http.C-Endpoint = local.endpoint;
}
}
}
}
...
@@ -123,4 +137,6 @@ client c1 {
...
@@ -123,4 +137,6 @@ client c1 {
expect resp.http.C-Sess-XID ~ "^[0-9]+$"
expect resp.http.C-Sess-XID ~ "^[0-9]+$"
expect resp.http.B-Sess-XID ~ "^[0-9]+$"
expect resp.http.B-Sess-XID ~ "^[0-9]+$"
expect resp.http.C-Sess-XID == resp.http.B-Sess-XID
expect resp.http.C-Sess-XID == resp.http.B-Sess-XID
expect resp.http.C-Endpoint == "${v1_addr}:${v1_port}"
expect resp.http.B-Endpoint == "${v1_addr}:${v1_port}"
} -run
} -run
doc/sphinx/reference/vcl_var.rst
View file @
b38c3d32
...
@@ -52,22 +52,34 @@ With PROXY protocol::
...
@@ -52,22 +52,34 @@ With PROXY protocol::
CLIENT ------------ PROXY ------------ VARNISHD
CLIENT ------------ PROXY ------------ VARNISHD
local.endpoint
local.ip
Type: IP
Readable from: client, backend
The IP address (and port number) of the local end of the
TCP connection, for instance `192.168.1.1:81`
If the connection is a UNIX domain socket, the value
will be `0.0.0.0:0`
local.endpoint ``VCL >= 4.1``
Type: STRING
Type: STRING
Readable from: client
Readable from: client
, backend
The address of the '-a' socket the session was accepted on.
The address of the '-a' socket the session was accepted on.
If the argument was `-a foo=:81` this would be ":81"
If the argument was `-a foo=:81` this would be ":81"
local.socket
local.socket
``VCL >= 4.1``
Type: STRING
Type: STRING
Readable from: client
Readable from: client
, backend
The name of the '-a' socket the session was accepted on.
The name of the '-a' socket the session was accepted on.
...
@@ -76,18 +88,6 @@ local.socket
...
@@ -76,18 +88,6 @@ local.socket
Note that all '-a' gets a default name on the form `a%d`
Note that all '-a' gets a default name on the form `a%d`
if no name is provided.
if no name is provided.
local.ip
Type: IP
Readable from: client, backend
The IP address (and port number) of the local end of the
TCP connection, for instance `192.168.1.1:81`
If the connection is a UNIX domain socket, the value
will be `0.0.0.0:0`
remote.ip
remote.ip
Type: IP
Type: IP
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment