Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- src/samsredir.cpp.orig 2015-08-26 11:08:07.441827361 +0400
- +++ src/samsredir.cpp 2015-08-26 11:08:27.050329112 +0400
- @@ -217,7 +217,7 @@
- // Logger::addLog(Logger::LK_DAEMON, mess.str());
- - char line[2048];
- + char line[4096];
- vector < string > fields;
- vector < string > source;
- string destination;
- @@ -231,17 +231,24 @@
- // URL ip-address/fqdn ident method
- Split (line, "\n\t ", fields);
- + // В версии сквида 3.4 поменялся протокол хелперов
- + // OK url="URL" - success, URL был изменем
- + // ERR - success, URL не был изменен
- + // Подробнее на:
- + // http://wiki.squid-cache.org/Features/AddonHelpers
- +
- if (fields.size () == 0)
- break;
- INFO ("Input: " << line);
- // Мы незнаем что такое попалось, но на всякий случай ничего менять не будем
- + // Изменено на "ERR" для совместимости со squid 3.4
- if (fields.size () < 4)
- {
- INFO ("Reason: Invalid fields count: " << fields.size());
- - INFO ("Output: " << line);
- - cout << line << endl << flush;
- + INFO ("Output: ERR");
- + cout << "ERR" << endl << flush;
- continue;
- }
- @@ -251,8 +258,8 @@
- if (LocalNetworks::isLocalUrl(fields[0]))
- {
- INFO ("Reason: Url is local");
- - INFO ("Output: " << line);
- - cout << line << endl << flush;
- + INFO ("Output: ERR");
- + cout << "ERR" << endl << flush;
- continue;
- }
- @@ -264,15 +271,13 @@
- INFO ("Reason: User not found");
- if (fields[2] != "-")
- {
- - INFO ("Output: " << Proxy::getDenyAddr () << "/blocked.php?action=usernotfound&id=" << fields[2] << " " << fields[1] << " " << fields[2] << " " << fields[3]);
- - cout << Proxy::getDenyAddr () << "/blocked.php?action=usernotfound&id=" << fields[2];
- - cout << " " << fields[1] << " " << fields[2] << " " << fields[3] << endl << flush;
- + INFO ("Output: OK url=\"" << Proxy::getDenyAddr () << "/blocked.php?action=usernotfound&id=" << fields[2] << "\"");
- + cout << "OK url=\"" << Proxy::getDenyAddr () << "/blocked.php?action=usernotfound&id=" << fields[2] << "\"" << endl << flush;
- }
- else
- {
- - INFO ("Output: " << Proxy::getDenyAddr () << "/blocked.php?action=usernotfound&id=" << source[0] << " " << fields[1] << " " << fields[2] << " " << fields[3]);
- - cout << Proxy::getDenyAddr () << "/blocked.php?action=usernotfound&id=" << source[0];
- - cout << " " << fields[1] << " " << fields[2] << " " << fields[3] << endl << flush;
- + INFO ("Output: OK url=\"" << Proxy::getDenyAddr () << "/blocked.php?action=usernotfound&id=" << source[0] << "\"");
- + cout << "OK url=\"" << Proxy::getDenyAddr () << "/blocked.php?action=usernotfound&id=" << source[0] << "\"" << endl << flush;
- }
- continue;
- }
- @@ -282,9 +287,8 @@
- if ( (usr->getEnabled () != SAMSUser::STAT_ACTIVE) && (usr->getEnabled () != SAMSUser::STAT_LIMITED) )
- {
- INFO ("Reason: User not active (disabled or blocked)");
- - INFO ("Output: " << Proxy::getDenyAddr () << "/blocked.php?action=userdisabled&id=" << *usr << " " << fields[1] << " " << fields[2] << " " << fields[3]);
- - cout << Proxy::getDenyAddr () << "/blocked.php?action=userdisabled&id=" << *usr;
- - cout << " " << fields[1] << " " << fields[2] << " " << fields[3] << endl << flush;
- + INFO ("Output: OK url=\"" << Proxy::getDenyAddr () << "/blocked.php?action=userdisabled&id=" << *usr << "\"");
- + cout << "OK url=\"" << Proxy::getDenyAddr () << "/blocked.php?action=userdisabled&id=" << *usr << "\"" << endl << flush;
- continue;
- }
- @@ -293,9 +297,8 @@
- if (!tpl)
- {
- INFO ("Reason: User's template not found");
- - INFO ("Output: " << Proxy::getDenyAddr () << "/blocked.php?action=templatenotfound&id=" << *usr << " " << fields[1] << " " << fields[2] << " " << fields[3]);
- - cout << Proxy::getDenyAddr () << "/blocked.php?action=templatenotfound&id=" << *usr;
- - cout << " " << fields[1] << " " << fields[2] << " " << fields[3] << endl << flush;
- + INFO ("Output: OK url=\"" << Proxy::getDenyAddr () << "/blocked.php?action=templatenotfound&id=" << *usr << "\"");
- + cout << "OK url=\"" << Proxy::getDenyAddr () << "/blocked.php?action=templatenotfound&id=" << *usr << "\"" << endl << flush;
- continue;
- }
- @@ -303,8 +306,8 @@
- if ( tpl->isUrlWhitelisted (fields[0]) )
- {
- INFO ("Reason: In white list");
- - INFO ("Output: " << line);
- - cout << line << endl << flush;
- + INFO ("Output: ERR");
- + cout << "ERR" << endl << flush;
- continue;
- }
- @@ -312,9 +315,8 @@
- if ( tpl->isUrlBlacklisted (fields[0]) )
- {
- INFO ("Reason: In black list");
- - INFO ("Output: " << Proxy::getDenyAddr () << "/blocked.php?action=urldenied&id=" << *usr << " " << fields[1] << " " << fields[2] << " " << fields[3]);
- - cout << Proxy::getDenyAddr () << "/blocked.php?action=urldenied&id=" << *usr;
- - cout << " " << fields[1] << " " << fields[2] << " " << fields[3] << endl << flush;
- + INFO ("Output: OK url=\"" << Proxy::getDenyAddr () << "/blocked.php?action=urldenied&id=" << *usr << "\"");
- + cout << "OK url=\"" << Proxy::getDenyAddr () << "/blocked.php?action=urldenied&id=" << *usr << "\"" << endl << flush;
- continue;
- }
- @@ -322,9 +324,8 @@
- if ( tpl->isUrlMatchRegex (fields[0]) )
- {
- INFO ("Reason: In regular expression list");
- - INFO ("Output: " << Proxy::getDenyAddr () << "/blocked.php?action=urldenied&id=" << *usr << " " << fields[1] << " " << fields[2] << " " << fields[3]);
- - cout << Proxy::getDenyAddr () << "/blocked.php?action=urldenied&id=" << *usr;
- - cout << " " << fields[1] << " " << fields[2] << " " << fields[3] << endl << flush;
- + INFO ("Output: OK url=\"" << Proxy::getDenyAddr () << "/blocked.php?action=urldenied&id=" << *usr << "\"");
- + cout << "OK url=\"" << Proxy::getDenyAddr () << "/blocked.php?action=urldenied&id=" << *usr << "\"" << endl << flush;
- continue;
- }
- @@ -332,9 +333,8 @@
- if ( tpl->isUrlHasFileExt (fields[0]) )
- {
- INFO ("Reason: Has disallowed file extension");
- - INFO ("Output: " << Proxy::getDenyAddr () << "/blocked.php?action=urldenied&id=" << *usr << " " << fields[1] << " " << fields[2] << " " << fields[3]);
- - cout << Proxy::getDenyAddr () << "/blocked.php?action=urldenied&id=" << *usr;
- - cout << " " << fields[1] << " " << fields[2] << " " << fields[3] << endl << flush;
- + INFO ("Output: OK url=\"" << Proxy::getDenyAddr () << "/blocked.php?action=urldenied&id=" << *usr << "\"");
- + cout << "OK url=\"" << Proxy::getDenyAddr () << "/blocked.php?action=urldenied&id=" << *usr << "\"" << endl << flush;
- continue;
- }
- @@ -342,18 +342,16 @@
- if ( tpl->isTimeDenied (fields[0]) )
- {
- INFO ("Reason: Denied due to time restrictions");
- - INFO ("Output: " << Proxy::getDenyAddr () << "/blocked.php?action=timedenied&id=" << *usr << " " << fields[1] << " " << fields[2] << " " << fields[3]);
- - cout << Proxy::getDenyAddr () << "/blocked.php?action=timedenied&id=" << *usr;
- - cout << " " << fields[1] << " " << fields[2] << " " << fields[3] << endl << flush;
- + INFO ("Output: OK url=\"" << Proxy::getDenyAddr () << "/blocked.php?action=timedenied&id=" << *usr << "\"");
- + cout << "OK url=\"" << Proxy::getDenyAddr () << "/blocked.php?action=timedenied&id=" << *usr << "\"" << endl << flush;
- continue;
- }
- if ( tpl->getAllDeny () )
- {
- INFO ("Reason: Denied to all and not whitelisted");
- - INFO ("Output: " << Proxy::getDenyAddr () << "/blocked.php?action=urldenied&id=" << *usr << " " << fields[1] << " " << fields[2] << " " << fields[3]);
- - cout << Proxy::getDenyAddr () << "/blocked.php?action=urldenied&id=" << *usr;
- - cout << " " << fields[1] << " " << fields[2] << " " << fields[3] << endl << flush;
- + INFO ("Output: OK url=\"" << Proxy::getDenyAddr () << "/blocked.php?action=urldenied&id=" << *usr << "\"");
- + cout << "OK url=\"" << Proxy::getDenyAddr () << "/blocked.php?action=urldenied&id=" << *usr << "\"" << endl << flush;
- continue;
- }
- @@ -361,16 +359,15 @@
- if (!destination.empty ())
- {
- INFO ("Reason: Redirected to another location");
- - INFO ("Output: " << destination << " " << fields[1] << " " << fields[2] << " " << fields[3]);
- - cout << destination;
- - cout << " " << fields[1] << " " << fields[2] << " " << fields[3] << endl << flush;
- + INFO ("Output: OK url=\"" << destination << "\"");
- + cout << "OK url=\"" << destination << "\"" << endl << flush;
- continue;
- }
- // Все проверки пройдены успешно, разрешаем доступ
- INFO ("Reason: Access granted");
- - INFO ("Output: " << line);
- - cout << line << endl << flush;
- + INFO ("Output: ERR");
- + cout << "ERR" << endl << flush;
- }
- delete conn;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement