Commit 8ff29534 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Introduce local.ip and remote.ip VCL variables.

These reference the actual TCP connection, whereas client.ip and server.ip
may (in a near future) talk about another TCP connection terminating in
a proxy in front of Varnish.
parent ea4e783f
......@@ -551,7 +551,7 @@ pool_mkpool(unsigned pool_no)
AZ(pthread_create(&pp->herder_thr, NULL, pool_herder, pp));
while (VTAILQ_EMPTY(&pp->idle_queue))
usleep(10000);
(void)usleep(10000);
pp->sesspool = SES_NewPool(pp, pool_no);
AN(pp->sesspool);
......
......@@ -593,29 +593,26 @@ VRT_r_req_##field(VRT_CTX) \
/*--------------------------------------------------------------------*/
VCL_IP
VRT_r_client_ip(VRT_CTX)
{
struct suckaddr *sa;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC);
CHECK_OBJ_NOTNULL(ctx->req->sp, SESS_MAGIC);
AZ(SES_Get_remote_addr(ctx->req->sp, &sa));
return (sa);
}
#define GIP(fld) \
VCL_IP \
VRT_r_##fld##_ip(VRT_CTX) \
{ \
struct suckaddr *sa; \
\
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \
CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); \
CHECK_OBJ_NOTNULL(ctx->req->sp, SESS_MAGIC); \
AZ(SES_Get_##fld##_addr(ctx->req->sp, &sa)); \
return (sa); \
}
VCL_IP
VRT_r_server_ip(VRT_CTX)
{
struct suckaddr *sa;
GIP(local)
GIP(remote)
GIP(client)
GIP(server)
#undef GIP
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC);
CHECK_OBJ_NOTNULL(ctx->req->sp, SESS_MAGIC);
AZ(SES_Get_local_addr(ctx->req->sp, &sa));
return (sa);
}
/*--------------------------------------------------------------------*/
const char*
VRT_r_server_identity(VRT_CTX)
......
......@@ -157,6 +157,15 @@ returns =(
# 'both' means all methods tagged "B" or "C"
sp_variables = [
('remote.ip',
'IP',
( 'client',),
( ), """
The IP address of the other end of the TCP connection.
This can either be the clients IP, or the outgoing IP
of a proxy server.
"""
),
('client.ip',
'IP',
( 'client',),
......@@ -172,6 +181,13 @@ sp_variables = [
in the client director.
"""
),
('local.ip',
'IP',
( 'client',),
( ), """
The IP address of the local end of the TCP connection.
"""
),
('server.ip',
'IP',
( 'client',),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment