Commit 9fc08708 authored by Artur Bergman's avatar Artur Bergman

add new option to set the identity of a varnish instance and allow it to be...

add new option to set the identity of a varnish instance and allow it to be accessed using server.identity

git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@3949 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent abe538c5
......@@ -622,6 +622,16 @@ VRT_r_server_ip(struct sess *sp)
return (sp->mysockaddr);
}
const char*
VRT_r_server_identity(struct sess *sp)
{
if (heritage.identity[0] != '\0')
return heritage.identity;
else
return heritage.name;
}
const char*
VRT_r_server_hostname(struct sess *sp)
{
......
......@@ -65,6 +65,7 @@ struct heritage {
struct hash_slinger *hash;
char name[1024];
char identity[1024];
};
struct params {
......
......@@ -190,6 +190,7 @@ usage(void)
fprintf(stderr, FMT, "", " -h simple_list");
fprintf(stderr, FMT, "", " -h classic [default]");
fprintf(stderr, FMT, "", " -h classic,<buckets>");
fprintf(stderr, FMT, "-i identity", "Identity of varnish instance");
fprintf(stderr, FMT, "-l bytesize", "Size of shared memory log");
fprintf(stderr, FMT, "-n dir", "varnishd working directory");
fprintf(stderr, FMT, "-P file", "PID file");
......@@ -399,6 +400,7 @@ main(int argc, char * const *argv)
unsigned F_flag = 0;
const char *b_arg = NULL;
const char *f_arg = NULL;
const char *i_arg = NULL;
const char *l_arg = "80m";
uintmax_t l_size;
const char *q;
......@@ -450,7 +452,7 @@ main(int argc, char * const *argv)
cli_check(cli);
while ((o = getopt(argc, argv,
"a:b:Cdf:Fg:h:l:n:P:p:S:s:T:t:u:Vw:")) != -1)
"a:b:Cdf:Fg:h:i:l:n:P:p:S:s:T:t:u:Vw:")) != -1)
switch (o) {
case 'a':
MCF_ParamSet(cli, "listen_address", optarg);
......@@ -477,6 +479,9 @@ main(int argc, char * const *argv)
case 'h':
h_arg = optarg;
break;
case 'i':
i_arg = optarg;
break;
case 'l':
l_arg = optarg;
break;
......@@ -571,6 +576,17 @@ main(int argc, char * const *argv)
exit(1);
}
if (i_arg != NULL) {
size_t len;
if (snprintf(heritage.identity, sizeof heritage.identity, "%s", i_arg) > sizeof heritage.identity) {
fprintf(stderr, "Invalid identity name: %s\n",
strerror(ENAMETOOLONG));
exit(1);
}
}
if (n_arg != NULL)
openlog(n_arg, LOG_PID, LOG_LOCAL0);
else
......
......@@ -39,6 +39,9 @@ varnish v1 -vcl+backend {
set resp.proto = "HTTP/1.2";
set resp.response = "Naah, lets fail it";
set resp.status = 904;
# XXX should be moved to it's own test
set resp.http.x-served-by-hostname = server.hostname;
set resp.http.x-served-by-identity = server.identity;
set resp.http.foobar =
resp.proto
resp.status;
......
......@@ -9,6 +9,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 *);
const char * VRT_r_server_identity(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 *, ...);
......
......@@ -322,13 +322,16 @@ vcl_output_lang_h(struct vsb *sb)
/* ../../include/vrt_obj.h */
vsb_cat(sb, "/*\n * $Id: vcc_gen_obj.tcl 3880 2009-03-04 13:00:18Z ");
vsb_cat(sb, "phk $\n *\n * NB: This file is machine generated, DO ");
vsb_cat(sb, "NOT EDIT!\n *\n * Edit vcc_gen_obj.tcl instead\n");
vsb_cat(sb, "/*\n * $Id$\n");
vsb_cat(sb, " *\n * NB: This file is machine generated, DO NOT EDI");
vsb_cat(sb, "T!\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 *);\nconst char * VRT_r_server_hostname(struct sess ");
vsb_cat(sb, "*);\nint VRT_r_server_port(struct sess *);\n");
vsb_cat(sb, "s *);\n<<<<<<< .mine\nconst char * VRT_r_server_hostna");
vsb_cat(sb, "me(struct sess *);\nconst char * VRT_r_server_identity");
vsb_cat(sb, "(struct sess *);\n=======\nconst char * VRT_r_server_h");
vsb_cat(sb, "ostname(struct sess *);\n>>>>>>> .r3947\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");
vsb_cat(sb, " *, ...);\nconst char * VRT_r_req_url(const struct ses");
......
......@@ -56,6 +56,11 @@ set spobj {
{recv pipe pass hash miss hit fetch deliver error }
"struct sess *"
}
{ server.identity
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 }
......
......@@ -32,6 +32,13 @@ struct var vcc_vars[] = {
| VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER
| VCL_MET_ERROR
},
{ "server.identity", STRING, 15,
"VRT_r_server_identity(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