Пример #1
0
static void addflag(const char *var, const char* flag, int reset)
{
  if(!session_getnum(var, 0)) return;

  if(reset) session_delnum(var);

  if(mflags.len) str_cats(&mflags, ",");
  str_cats(&mflags, flag);

}
Пример #2
0
static const response* apply_rule(const struct rule* rule)
{
  const response* resp;
  unsigned long maxdatabytes;
  resp = build_response(rule->code, &rule->response);
  apply_environment(&rule->environment);
  maxdatabytes = session_getnum("maxdatabytes", ~0UL);
  if (maxdatabytes == 0
      || (rule->databytes > 0
	  && maxdatabytes > rule->databytes))
    session_setnum("maxdatabytes", rule->databytes);
  return resp;
}
Пример #3
0
static int dblchk(str *domain, str *dbltxt)
{
	str dblstr;
	char *dbl = getenv("DBLLOOKUP");
	int l, i;
	unsigned char ansbuf[512];
	
	if(!dbl || domain->len == 0) return 0;
	if(session_getnum("sump",0)) return 0; /* no point */


	str_init(&dblstr);
	str_copy(&dblstr, domain);
	str_catc(&dblstr, '.');
	str_cats(&dblstr, dbl);
			
	l = res_query(dblstr.s, C_IN, T_TXT, ansbuf, sizeof(ansbuf));
	if(l > 0 && ((HEADER *)ansbuf)->ancount != 0) {  /* something in the answer */
		unsigned char *recbuf = ansbuf+NS_HFIXEDSZ;
		
		/* skip over questions, why am I still writing stuff
		 * like this? */
		for(i = ns_get16(ansbuf+4); i != 0; --i)
			recbuf += dn_skipname(recbuf, ansbuf+l)+4;

		for(i = ns_get16(ansbuf+6); i != 0; --i) {
			recbuf += dn_skipname(recbuf, ansbuf+l);

			if(ns_get16(recbuf) != T_TXT) { /* CNAME or something */
				recbuf += 10 + ns_get16(recbuf+8);
				continue;
			}
			/* it's a TXT record, wow */
			str_init(dbltxt);
			str_copyb(dbltxt, (char*)recbuf+11, recbuf[10]);
			str_free(&dblstr);
			return 1;
		}
	} /* didn't find anything */
	str_free(&dblstr);
	return 0;
	}