int client_ip_max_connections;
+ char *redirector_extras;
+
+ char *storeId_extras;
+
struct {
int v4_first; ///< Place IPv4 first in the order of DNS results.
ssize_t packet_max; ///< maximum size EDNS advertised for DNS replies.
#define dump_eol dump_string
#define free_eol free_string
+static void
+parse_TokenOrQuotedString(char **var)
+{
+ char *token = ConfigParser::NextQuotedToken();
+ safe_free(*var);
+
+ if (token == NULL)
+ self_destruct();
+
+ *var = xstrdup(token);
+}
+
+#define dump_TokenOrQuotedString dump_string
+#define free_TokenOrQuotedString free_string
+
static void
dump_time_t(StoreEntry * entry, const char *name, time_t var)
{
pipelinePrefetch
PortCfg
QosConfig
+TokenOrQuotedString
refreshpattern
removalpolicy
size_t
For each requested URL, the rewriter will receive on line with the format
- [channel-ID <SP>] URL <SP> client_ip "/" fqdn <SP> user <SP> method [<SP> kv-pairs]<NL>
+ [channel-ID <SP>] URL [<SP> extras]<NL>
After processing the request the helper must reply using the following format:
be allowed to request.
DOC_END
+NAME: url_rewrite_extras format
+TYPE: TokenOrQuotedString
+LOC: Config.redirector_extras
+DEFAULT: "%>a/%>A %un %>rm myip=%la myport=%lp"
+DOC_START
+ Specifies a string to be append to request line format for the
+ rewriter helper. "Quoted" format values may contain spaces and
+ logformat %macros. In theory, any logformat %macro can be used.
+ In practice, a %macro expands as a dash (-) if the helper request is
+ sent before the required macro information is available to Squid.
+DOC_END
+
COMMENT_START
OPTIONS FOR STORE ID
-----------------------------------------------------------------------------
For each requested URL, the helper will receive one line with the format
- [channel-ID <SP>] URL <SP> client_ip "/" fqdn <SP> user <SP> method [<SP> kv-pairs]<NL>
+ [channel-ID <SP>] URL [<SP> extras]<NL>
After processing the request the helper must reply using the following format:
a result being identified.
- Helper programs should be prepared to receive and possibly ignore additional
- kv-pairs with keys they do not support.
+ Helper programs should be prepared to receive and possibly ignore
+ additional whitespace-separated tokens on each input line.
When using the concurrency= option the protocol is changed by
introducing a query channel tag in front of the request/response.
By default, a StoreID helper is not used.
DOC_END
+NAME: store_id_extras format
+TYPE: TokenOrQuotedString
+LOC: Config.storeId_extras
+DEFAULT: "%>a/%>A %un %>rm myip=%la myport=%lp"
+DOC_START
+ Specifies a string to be append to request line format for the
+ StoreId helper. "Quoted" format values may contain spaces and
+ logformat %macros. In theory, any logformat %macro can be used.
+ In practice, a %macro expands as a dash (-) if the helper request is
+ sent before the required macro information is available to Squid.
+DOC_END
+
NAME: store_id_children storeurl_rewrite_children
TYPE: HelperChildConfig
DEFAULT: 20 startup=0 idle=1 concurrency=0
static void gen_default_postscriptum(const EntryList &, std::ostream&);
static bool isDefined(const std::string &name);
static const char *available_if(const std::string &name);
+static const char *gen_quote_escape(const std::string &var);
static void
checkDepend(const std::string &directive, const char *name, const TypeList &types, const EntryList &entries)
fout << "#if " << entry->ifdef << std::endl;
for (LineList::const_iterator l = entry->defaults.preset.begin(); l != entry->defaults.preset.end(); ++l) {
- fout << " default_line(\"" << entry->name << " " << *l << "\");" << std::endl;
+ fout << " default_line(\"" << entry->name << " " << gen_quote_escape(*l) << "\");" << std::endl;
}
if (entry->ifdef.size())
fout << " if (check_null_" << entry->type << "(" << entry->loc << ")) {" << std::endl;
for (LineList::const_iterator l = entry->defaults.if_none.begin(); l != entry->defaults.if_none.end(); ++l)
- fout << " default_line(\"" << entry->name << " " << *l <<"\");" << std::endl;
+ fout << " default_line(\"" << entry->name << " " << gen_quote_escape(*l) <<"\");" << std::endl;
fout << " }" << std::endl;
if (entry->ifdef.size())
if (entry->defaults.preset.size() && entry->defaults.preset.front().compare("none") != 0) {
// Display DEFAULT: line(s)
for (LineList::const_iterator l = entry->defaults.preset.begin(); l != entry->defaults.preset.end(); ++l) {
- snprintf(buf, sizeof(buf), "%s %s", entry->name.c_str(), l->c_str());
+ snprintf(buf, sizeof(buf), "%s %s", entry->name.c_str(), gen_quote_escape(*l));
def.push_back(buf);
}
} else if (entry->defaults.if_none.size()) {
// Display DEFAULT_IF_NONE: line(s)
for (LineList::const_iterator l = entry->defaults.if_none.begin(); l != entry->defaults.if_none.end(); ++l) {
- snprintf(buf, sizeof(buf), "%s %s", entry->name.c_str(), l->c_str());
+ snprintf(buf, sizeof(buf), "%s %s", entry->name.c_str(), gen_quote_escape(*l));
def.push_back(buf);
}
}
}
}
}
+
+static const char *
+gen_quote_escape(const std::string &var)
+{
+ static std::string esc;
+ esc.clear();
+
+ for (int i = 0; i < var.length(); ++i) {
+ switch (var[i]) {
+ case '"':
+ case '\\':
+ esc += '\\';
+ default:
+ esc += var[i];
+ }
+ }
+
+ return esc.c_str();
+}
ClientRequestContext::clientRedirectStart()
{
debugs(33, 5, HERE << "'" << http->uri << "'");
-
+ (void)SyncNotes(*http->al, *http->request);
if (Config.accessList.redirector) {
acl_checklist = clientAclChecklistCreate(Config.accessList.redirector, http);
acl_checklist->nonBlockingCheck(clientRedirectAccessCheckDone, this);
#include "comm/Connection.h"
#include "fde.h"
#include "fqdncache.h"
+#include "format/Format.h"
#include "globals.h"
#include "HttpRequest.h"
#include "mgr/Registration.h"
static OBJH storeIdStats;
static int redirectorBypassed = 0;
static int storeIdBypassed = 0;
+static Format::Format *redirectorExtrasFmt = NULL;
+static Format::Format *storeIdExtrasFmt = NULL;
CBDATA_CLASS_INIT(RedirectStateData);
}
static void
-constructHelperQuery(const char *name, helper *hlp, HLPCB *replyHandler, ClientHttpRequest * http, HLPCB *handler, void *data)
+constructHelperQuery(const char *name, helper *hlp, HLPCB *replyHandler, ClientHttpRequest * http, HLPCB *handler, void *data, Format::Format *requestExtrasFmt)
{
ConnStateData * conn = http->getConn();
const char *fqdn;
char buf[MAX_REDIRECTOR_REQUEST_STRLEN];
int sz;
Http::StatusCode status;
- char claddr[MAX_IPSTRLEN];
- char myaddr[MAX_IPSTRLEN];
/** TODO: create a standalone method to initialize
* the RedirectStateData for all the helpers.
if ((fqdn = fqdncache_gethostbyaddr(r->client_addr, 0)) == NULL)
fqdn = dash_str;
- sz = snprintf(buf, MAX_REDIRECTOR_REQUEST_STRLEN, "%s %s/%s %s %s myip=%s myport=%d\n",
+ static MemBuf requestExtras;
+ requestExtras.reset();
+ if (requestExtrasFmt)
+ requestExtrasFmt->assemble(requestExtras, http->al, 0);
+
+ sz = snprintf(buf, MAX_REDIRECTOR_REQUEST_STRLEN, "%s%s%s\n",
r->orig_url.c_str(),
- r->client_addr.toStr(claddr,MAX_IPSTRLEN),
- fqdn,
- r->client_ident[0] ? rfc1738_escape(r->client_ident) : dash_str,
- r->method_s,
- http->request->my_addr.toStr(myaddr,MAX_IPSTRLEN),
- http->request->my_addr.port());
+ requestExtras.hasContent() ? " " : "",
+ requestExtras.hasContent() ? requestExtras.content() : "");
if ((sz<=0) || (sz>=MAX_REDIRECTOR_REQUEST_STRLEN)) {
if (sz<=0) {
return;
}
- constructHelperQuery("redirector", redirectors, redirectHandleReply, http, handler, data);
+ constructHelperQuery("redirector", redirectors, redirectHandleReply, http, handler, data, redirectorExtrasFmt);
}
/**
return;
}
- constructHelperQuery("storeId helper", storeIds, storeIdHandleReply, http, handler, data);
+ constructHelperQuery("storeId helper", storeIds, storeIdHandleReply, http, handler, data, storeIdExtrasFmt);
}
void
helperOpenServers(storeIds);
}
+ if (Config.redirector_extras) {
+ redirectorExtrasFmt = new ::Format::Format("redirecor_extras");
+ (void)redirectorExtrasFmt->parse(Config.redirector_extras);
+ }
+
+ if (Config.storeId_extras) {
+ storeIdExtrasFmt = new ::Format::Format("storeId_extras");
+ (void)storeIdExtrasFmt->parse(Config.storeId_extras);
+ }
+
init = true;
}
delete storeIds;
storeIds = NULL;
+ delete redirectorExtrasFmt;
+ redirectorExtrasFmt = NULL;
+
+ delete storeIdExtrasFmt;
+ storeIdExtrasFmt = NULL;
}