crossroads

Git mirror of https://crossroads.e-tunity.com/
git clone git://git.finwo.net/app/crossroads
Log | Files | Refs | LICENSE

setbackend.cc (882B)


      1 #include "config"
      2 
      3 void Config::setbackend (string const &str, string const &host,
      4 			 string const &url,
      5 			 BackendCheck const &backend_check) {
      6     vector<string> parts = str2parts (str, ':');
      7     if (parts.size() < 2 || parts.size() > 4)
      8 	throw Error("Bad back end specifier in '-b" + str +
      9 		    "', expected: SERVER:PORT or SERVER:PORT:MAXCONNECTIONS"
     10 		    " or SERVER:PORT:MAXCONNECTIONS:WEIGHT");
     11 
     12     BackendDef *bdp = 0;
     13     if (parts.size() == 2)
     14 	bdp = new BackendDef(parts[0], parts[1]);
     15     else if (parts.size() == 3)
     16 	bdp = new BackendDef(parts[0], parts[1], parts[2]);
     17     else if (parts.size() == 4)
     18 	bdp = new BackendDef(parts[0], parts[1], parts[2], parts[3]);
     19     if (!bdp)
     20 	throw Error("Memory fault in Config::setbackend");
     21     bdp->hostmatch(host);
     22     bdp->urlmatch(url);
     23     bdp->backendcheck(backend_check);
     24     blist.push_back (*bdp);
     25     delete bdp;
     26 }