Commit 435ea12e authored by Petter Knudsen's avatar Petter Knudsen

Added the variable server.port that holds the port on which the server has...

Added the variable server.port that holds the port on which the server has answered the request in the same way that server.ip holds the IP number. Fixes #264.


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@2983 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent f54228c8
......@@ -478,6 +478,19 @@ VRT_r_server_ip(struct sess *sp)
return (sp->mysockaddr);
}
int
VRT_r_server_port(struct sess *sp)
{
char abuf[TCP_ADDRBUFSIZE];
char pbuf[TCP_PORTBUFSIZE];
if (sp->mysockaddr->sa_family == AF_UNSPEC)
AZ(getsockname(sp->fd, sp->mysockaddr, &sp->mysockaddrlen));
TCP_name(sp->mysockaddr, sp->mysockaddrlen, abuf, sizeof abuf, pbuf, sizeof pbuf);
return (atoi(pbuf));
}
/*--------------------------------------------------------------------
* Add an element to the array/list of hash bits.
*/
......
......@@ -8,6 +8,7 @@
struct sockaddr * VRT_r_client_ip(const struct sess *);
struct sockaddr * VRT_r_server_ip(struct sess *);
int VRT_r_server_port(struct sess *);
const char * VRT_r_req_request(const struct sess *);
void VRT_l_req_request(const struct sess *, const char *, ...);
const char * VRT_r_req_url(const struct sess *);
......
......@@ -465,6 +465,7 @@ vcl_output_lang_h(struct vsb *sb)
vsb_cat(sb, "\n");
vsb_cat(sb, "struct sockaddr * VRT_r_client_ip(const struct sess *);\n");
vsb_cat(sb, "struct sockaddr * VRT_r_server_ip(struct sess *);\n");
vsb_cat(sb, "int VRT_r_server_port(struct sess *);\n");
vsb_cat(sb, "const char * VRT_r_req_request(const struct sess *);\n");
vsb_cat(sb, "void VRT_l_req_request(const struct sess *, const char *, ...);\n");
vsb_cat(sb, "const char * VRT_r_req_url(const struct sess *);\n");
......
#!/usr/local/bin/tclsh8.4
#!/usr/bin/tclsh8.4
#-
# Copyright (c) 2006 Verdens Gang AS
# Copyright (c) 2006-2008 Linpro AS
......@@ -51,7 +51,11 @@ set spobj {
{recv pipe pass hash miss hit fetch deliver }
"struct sess *"
}
{ server.port
RO INT
{recv pipe pass hash miss hit fetch deliver }
"struct sess *"
}
# Request paramters
{ req.request
RW STRING
......
......@@ -25,6 +25,13 @@ struct var vcc_vars[] = {
0,
VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER
},
{ "server.port", INT, 11,
"VRT_r_server_port(sp)",
NULL,
V_RO,
0,
VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER
},
{ "req.request", STRING, 11,
"VRT_r_req_request(sp)",
"VRT_l_req_request(sp, ",
......
......@@ -394,6 +394,9 @@ The client's IP address.
.It Va server.ip
The IP address of the socket on which the client connection was
received.
.It Va server.port
The port number of the socket on which the client connection was
received.
.It Va req.request
The request type (e.g. "GET", "HEAD").
.It Va req.url
......
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