Compare commits

..

No commits in common. "080cbe9c5370bc4bdb39a27b9c54f506936ff33b" and "7851f800d168adb0387e528022bb70712e70b1b9" have entirely different histories.

4 changed files with 8 additions and 37 deletions

View File

@ -82,10 +82,12 @@ static void onusr2(int sig)
printf("\nHOSTFAIL POOL DUMP\n"); printf("\nHOSTFAIL POOL DUMP\n");
struct desync_profile_list *dpl; struct desync_profile_list *dpl;
int n=0;
LIST_FOREACH(dpl, &params.desync_profiles, next) LIST_FOREACH(dpl, &params.desync_profiles, next)
{ {
printf("\nDESYNC PROFILE %d\n",dpl->dp.n); printf("\nDESYNC PROFILE %d\n",n);
HostFailPoolDump(dpl->dp.hostlist_auto_fail_counters); HostFailPoolDump(dpl->dp.hostlist_auto_fail_counters);
n++;
} }
printf("\n"); printf("\n");
@ -1771,6 +1773,7 @@ int main(int argc, char **argv)
DLOG_CONDUP("we have %d user defined desync profile(s) and default low priority profile 0\n",desync_profile_count); DLOG_CONDUP("we have %d user defined desync profile(s) and default low priority profile 0\n",desync_profile_count);
v=0;
LIST_FOREACH(dpl, &params.desync_profiles, next) LIST_FOREACH(dpl, &params.desync_profiles, next)
{ {
dp = &dpl->dp; dp = &dpl->dp;
@ -1783,6 +1786,7 @@ int main(int argc, char **argv)
DLOG("[profile %d] autottl ipv6 %u:%u-%u\n",v,dp->desync_autottl6.delta,dp->desync_autottl6.min,dp->desync_autottl6.max); DLOG("[profile %d] autottl ipv6 %u:%u-%u\n",v,dp->desync_autottl6.delta,dp->desync_autottl6.min,dp->desync_autottl6.max);
if (dp->desync_split_tls==tlspos_none && dp->desync_split_pos) dp->desync_split_tls=tlspos_pos; if (dp->desync_split_tls==tlspos_none && dp->desync_split_pos) dp->desync_split_tls=tlspos_pos;
if (dp->desync_split_http_req==httpreqpos_none && dp->desync_split_pos) dp->desync_split_http_req=httpreqpos_pos; if (dp->desync_split_http_req==httpreqpos_none && dp->desync_split_pos) dp->desync_split_http_req=httpreqpos_pos;
v++;
} }
if (!LoadIncludeHostLists()) if (!LoadIncludeHostLists())

View File

@ -24,45 +24,12 @@ bool IsHttp(const uint8_t *data, size_t len)
{ {
return !!HttpMethod(data,len); return !!HttpMethod(data,len);
} }
static bool IsHostAt(const uint8_t *p)
{
return \
p[0]=='\n' &&
(p[1]=='H' || p[1]=='h') &&
(p[2]=='o' || p[2]=='O') &&
(p[3]=='s' || p[3]=='S') &&
(p[4]=='t' || p[4]=='T') &&
p[5]==':';
}
static uint8_t *FindHostIn(uint8_t *buf, size_t bs)
{
size_t pos;
if (bs<6) return NULL;
bs-=6;
for(pos=0;pos<=bs;pos++)
if (IsHostAt(buf+pos))
return buf+pos;
return NULL;
}
static const uint8_t *FindHostInConst(const uint8_t *buf, size_t bs)
{
size_t pos;
if (bs<6) return NULL;
bs-=6;
for(pos=0;pos<=bs;pos++)
if (IsHostAt(buf+pos))
return buf+pos;
return NULL;
}
// pHost points to "Host: ..." // pHost points to "Host: ..."
bool HttpFindHost(uint8_t **pHost,uint8_t *buf,size_t bs) bool HttpFindHost(uint8_t **pHost,uint8_t *buf,size_t bs)
{ {
if (!*pHost) if (!*pHost)
{ {
*pHost = FindHostIn(buf, bs); *pHost = memmem(buf, bs, "\nHost:", 6);
if (*pHost) (*pHost)++; if (*pHost) (*pHost)++;
} }
return !!*pHost; return !!*pHost;
@ -71,7 +38,7 @@ bool HttpFindHostConst(const uint8_t **pHost,const uint8_t *buf,size_t bs)
{ {
if (!*pHost) if (!*pHost)
{ {
*pHost = FindHostInConst(buf, bs); *pHost = memmem(buf, bs, "\nHost:", 6);
if (*pHost) (*pHost)++; if (*pHost) (*pHost)++;
} }
return !!*pHost; return !!*pHost;
@ -165,7 +132,7 @@ bool HttpReplyLooksLikeDPIRedirect(const uint8_t *data, size_t len, const char *
} }
size_t HttpPos(enum httpreqpos tpos_type, size_t hpos_pos, const uint8_t *http, size_t sz) size_t HttpPos(enum httpreqpos tpos_type, size_t hpos_pos, const uint8_t *http, size_t sz)
{ {
const uint8_t *method, *host=NULL; const uint8_t *method, *host;
int i; int i;
switch(tpos_type) switch(tpos_type)