Skip to content

Commit

Permalink
Проверка на блокировку имени хоста без указания порта
Browse files Browse the repository at this point in the history
  • Loading branch information
max197616 committed Oct 19, 2020
1 parent 21e061a commit d3fbde6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,13 @@ void extFilter::initParams()
if(http_entries)
prm->memory_configs.http_entries = http_entries;
else
prm->memory_configs.http_entries = _calc_scale(scale, 70000, 250000);
prm->memory_configs.http_entries = _calc_scale(scale, 100000, 400000);

int ssl_entries = config().getInt("dpi.ssl_entries", 0);
if(ssl_entries)
prm->memory_configs.ssl_entries = ssl_entries;
else
prm->memory_configs.ssl_entries = _calc_scale(scale, 150000, 470000);
prm->memory_configs.ssl_entries = _calc_scale(scale, 170000, 800000);

prm->answer_duplication = config().getInt("answer_duplication", 0);
if(prm->answer_duplication > 3)
Expand Down
17 changes: 14 additions & 3 deletions src/tries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,15 +259,26 @@ int TriesManager::checkURLBlocked(int thread_id, const char *hostname, uint32_t
rhost = &revhostname[sizeof(revhostname) - 1 - host_len];
}
// перевод hostname в маленькие буквы и копирование hostname в обратном порядке в revhostname
uint32_t revhost_len = 0;
char *rh = &revhostname[sizeof(revhostname)-2];
for(uint32_t i = 0; i < host_len; i++, rh--)
bool found_colon = false;
for(uint32_t i = 0; i < host_len; i++)
{
char v = hostname[i];
if( v >= 'A' && v <= 'Z')
v |= 0x20;
else if(v == ':')
found_colon = true;
url_buf[i] = v;
*rh = v;
if(!found_colon)
{
*rh = v;
revhost_len++;
rh--;
}
}
if(found_colon)
rhost = &revhostname[sizeof(revhostname) - 1 - revhost_len];
if(uri_len != 0)
{
for(uint32_t i = 0; i < uri_len; i++)
Expand All @@ -276,7 +287,7 @@ int TriesManager::checkURLBlocked(int thread_id, const char *hostname, uint32_t
url_buf[buf_len] = 0;
try
{
if(_bl_manager.getHttpBlacklist()->getActiveTrie()->search_prefix(&_agents[thread_id], rhost, host_len, url_buf, buf_len))
if(_bl_manager.getHttpBlacklist()->getActiveTrie()->search_prefix(&_agents[thread_id], rhost, revhost_len, url_buf, buf_len))
{
struct BlacklistsManager::bl_service_profile *sp = _bl_manager.getActiveSP();
if(redir_url && sp->redir_url[0] != 0) // make redir url
Expand Down

0 comments on commit d3fbde6

Please sign in to comment.