]> err.no Git - varnish/commitdiff
Added the variable server.port that holds the port on which the server has answered...
authorpetter <petter@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Tue, 22 Jul 2008 07:52:00 +0000 (07:52 +0000)
committerpetter <petter@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Tue, 22 Jul 2008 07:52:00 +0000 (07:52 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2983 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache_vrt.c
varnish-cache/include/vrt_obj.h
varnish-cache/lib/libvcl/vcc_fixed_token.c
varnish-cache/lib/libvcl/vcc_gen_obj.tcl
varnish-cache/lib/libvcl/vcc_obj.c
varnish-cache/man/vcl.7

index d17fef090c6593135c550c0ca1ec066d69b0cf86..2ac8eada1daf3f62fa32eb24dee31efe1de0955a 100644 (file)
@@ -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.
  */
index 24b5a9a9285d65ebb3acd21f7c691151fa5d4b89..39675c25794ba9f89ad4fb5a8951d6da8c8a76c8 100644 (file)
@@ -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 *);
index 4f5654c99b560a8d24672f5c8efd409332094893..8254a75f8c3037a9f06bddb12611a6dec42e7bf9 100644 (file)
@@ -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");
index 08ce82a28f5bf0df04948d1eb85282e4fca6cec8..ed06f538744b0d8a1cc7943f7ba0a8dbb3a1d910 100755 (executable)
@@ -1,4 +1,4 @@
-#!/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
index 2ab9c03168ca499d5c821cacb0bb4fcbb8742f41..f674d5ff03588ad416d19c6c89ec80c66d18902d 100644 (file)
@@ -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, ",
index 3549ebdaf9c2fc8610fba79109cc1f5273f7f4f3..6d1e0bdc2d866cff59d4cf4cd0567583a087d8ca 100644 (file)
@@ -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