From a75a6eed263b3094abbab6342d3f823574ee3f52 Mon Sep 17 00:00:00 2001 From: phk Date: Tue, 11 Jul 2006 16:25:49 +0000 Subject: [PATCH] Allow backend to be specified as "host:port" to -b git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@433 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/varnishd.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/varnish-cache/bin/varnishd/varnishd.c b/varnish-cache/bin/varnishd/varnishd.c index ed4d775d..800f0234 100644 --- a/varnish-cache/bin/varnishd/varnishd.c +++ b/varnish-cache/bin/varnishd/varnishd.c @@ -66,6 +66,7 @@ static char * vcl_default(const char *bflag) { char *buf, *vf; + const char *p, *q; struct sbuf *sb; /* @@ -76,10 +77,19 @@ vcl_default(const char *bflag) * XXX: a bug for a backend to not reply at that time, so then * XXX: again: we should check it here in the "trivial" case. */ + p = strchr(bflag, ':'); + if (p != NULL) { + q = p + 1; + } else { + p = strchr(bflag, '\0'); + q = "http"; + } + buf = NULL; asprintf(&buf, "backend default {\n" - " set backend.host = \"%s\";\n" + " set backend.host = \"%*.*s\";\n" + " set backend.port = \"%s\";\n" "}\n" "sub vcl_recv {\n" " if (req.request != \"GET\" && req.request != \"HEAD\") {\n" @@ -117,7 +127,7 @@ vcl_default(const char *bflag) "sub vcl_timeout {\n" " discard;\n" "}\n" - "", bflag); + "", p - bflag, p - bflag, bflag, q); assert(buf != NULL); sb = sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND); assert(sb != NULL); -- 2.39.5