Commit e56c5d2b authored by Tollef Fog Heen's avatar Tollef Fog Heen

Merge r3947: Add server.hostname

Add server.hostname to get the hostname, it is only checked once so if the
machine changes hostname it won't detect it until restart of varnish



git-svn-id: http://www.varnish-cache.org/svn/branches/2.0@3990 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 60129dae
......@@ -54,6 +54,7 @@
#include "cache_backend.h"
void *vrt_magic_string_end = &vrt_magic_string_end;
char vrt_hostname[255] = "";
/*--------------------------------------------------------------------*/
......@@ -565,6 +566,15 @@ VRT_r_server_ip(struct sess *sp)
return (sp->mysockaddr);
}
const char*
VRT_r_server_hostname(struct sess *sp)
{
if (vrt_hostname[0] == '\0')
gethostname(vrt_hostname, 255);
return (const char*) &vrt_hostname;
}
int
VRT_r_server_port(struct sess *sp)
{
......
......@@ -8,6 +8,7 @@
struct sockaddr * VRT_r_client_ip(const struct sess *);
struct sockaddr * VRT_r_server_ip(struct sess *);
const char * VRT_r_server_hostname(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 *, ...);
......
......@@ -329,7 +329,8 @@ vcl_output_lang_h(struct vsb *sb)
vsb_cat(sb, "DO NOT EDIT!\n *\n * Edit vcc_gen_obj.tcl instead\n");
vsb_cat(sb, " */\n\nstruct sockaddr * VRT_r_client_ip(const struct ");
vsb_cat(sb, "sess *);\nstruct sockaddr * VRT_r_server_ip(struct ses");
vsb_cat(sb, "s *);\nint VRT_r_server_port(struct sess *);\n");
vsb_cat(sb, "s *);\nconst char * VRT_r_server_hostname(struct sess ");
vsb_cat(sb, "*);\nint 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");
vsb_cat(sb, " *, ...);\nconst char * VRT_r_req_url(const struct ses");
......
......@@ -51,6 +51,11 @@ set spobj {
{recv pipe pass hash miss hit fetch deliver error }
"struct sess *"
}
{ server.hostname
RO STRING
{recv pipe pass hash miss hit fetch deliver error }
"struct sess *"
}
{ server.port
RO INT
{recv pipe pass hash miss hit fetch deliver error }
......
......@@ -25,6 +25,13 @@ struct var vcc_vars[] = {
| VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER
| VCL_MET_ERROR
},
{ "server.hostname", STRING, 15,
"VRT_r_server_hostname(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
| VCL_MET_ERROR
},
{ "server.port", INT, 11,
"VRT_r_server_port(sp)", NULL,
V_RO, 0,
......
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