]> err.no Git - varnish/commitdiff
Allow backend to be specified as "host:port" to -b
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Tue, 11 Jul 2006 16:25:49 +0000 (16:25 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Tue, 11 Jul 2006 16:25:49 +0000 (16:25 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@433 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/varnishd.c

index ed4d775d85e59df1ef274125798414894ac90600..800f0234a6056c69973ef33061f728322aaa7180 100644 (file)
@@ -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);