Advertisement
Guest User

Untitled

a guest
Nov 1st, 2018
342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 9.62 KB | None | 0 0
  1. --- src/samsredir.cpp.orig  2015-08-26 11:08:07.441827361 +0400
  2. +++ src/samsredir.cpp   2015-08-26 11:08:27.050329112 +0400
  3. @@ -217,7 +217,7 @@
  4.  //  Logger::addLog(Logger::LK_DAEMON, mess.str());
  5.  
  6.  
  7. -  char line[2048];
  8. +  char line[4096];
  9.    vector < string > fields;
  10.    vector < string > source;
  11.    string destination;
  12. @@ -231,17 +231,24 @@
  13.        // URL ip-address/fqdn ident method
  14.        Split (line, "\n\t ", fields);
  15.  
  16. +      // В версии сквида 3.4 поменялся протокол хелперов
  17. +      // OK url="URL" - success, URL был изменем
  18. +      // ERR          - success, URL не был изменен
  19. +      // Подробнее на:
  20. +      // http://wiki.squid-cache.org/Features/AddonHelpers
  21. +
  22.        if (fields.size () == 0)
  23.          break;
  24.  
  25.        INFO ("Input: " << line);
  26.  
  27.        // Мы незнаем что такое попалось, но на всякий случай ничего менять не будем
  28. +      // Изменено на "ERR" для совместимости со squid 3.4
  29.        if (fields.size () < 4)
  30.          {
  31.            INFO ("Reason: Invalid fields count: " << fields.size());
  32. -          INFO ("Output: " << line);
  33. -          cout << line << endl << flush;
  34. +          INFO ("Output: ERR");
  35. +          cout << "ERR" << endl << flush;
  36.            continue;
  37.          }
  38.  
  39. @@ -251,8 +258,8 @@
  40.        if (LocalNetworks::isLocalUrl(fields[0]))
  41.          {
  42.            INFO ("Reason: Url is local");
  43. -          INFO ("Output: " << line);
  44. -     cout << line << endl << flush;
  45. +          INFO ("Output: ERR");
  46. +     cout << "ERR" << endl << flush;
  47.            continue;
  48.          }
  49.  
  50. @@ -264,15 +271,13 @@
  51.            INFO ("Reason: User not found");
  52.            if (fields[2] != "-")
  53.              {
  54. -              INFO ("Output: " << Proxy::getDenyAddr () << "/blocked.php?action=usernotfound&id=" << fields[2] << " " << fields[1] << " " << fields[2] << " " << fields[3]);
  55. -              cout << Proxy::getDenyAddr () << "/blocked.php?action=usernotfound&id=" << fields[2];
  56. -              cout << " " << fields[1] << " " << fields[2] << " " << fields[3] << endl << flush;
  57. +              INFO ("Output: OK url=\"" << Proxy::getDenyAddr () << "/blocked.php?action=usernotfound&id=" << fields[2] << "\"");
  58. +              cout << "OK url=\"" << Proxy::getDenyAddr () << "/blocked.php?action=usernotfound&id=" << fields[2] << "\"" << endl << flush;
  59.              }
  60.            else
  61.              {
  62. -              INFO ("Output: " << Proxy::getDenyAddr () << "/blocked.php?action=usernotfound&id=" << source[0] << " " << fields[1] << " " << fields[2] << " " << fields[3]);
  63. -              cout << Proxy::getDenyAddr () << "/blocked.php?action=usernotfound&id=" << source[0];
  64. -              cout << " " << fields[1] << " " << fields[2] << " " << fields[3] << endl << flush;
  65. +              INFO ("Output: OK url=\"" << Proxy::getDenyAddr () << "/blocked.php?action=usernotfound&id=" << source[0] << "\"");
  66. +              cout << "OK url=\"" << Proxy::getDenyAddr () << "/blocked.php?action=usernotfound&id=" << source[0] << "\"" << endl << flush;
  67.              }
  68.            continue;
  69.          }
  70. @@ -282,9 +287,8 @@
  71.        if ( (usr->getEnabled () != SAMSUser::STAT_ACTIVE) && (usr->getEnabled () != SAMSUser::STAT_LIMITED) )
  72.          {
  73.            INFO ("Reason: User not active (disabled or blocked)");
  74. -          INFO ("Output: " << Proxy::getDenyAddr () << "/blocked.php?action=userdisabled&id=" << *usr << " " << fields[1] << " " << fields[2] << " " << fields[3]);
  75. -          cout << Proxy::getDenyAddr () << "/blocked.php?action=userdisabled&id=" << *usr;
  76. -          cout << " " << fields[1] << " " << fields[2] << " " << fields[3] << endl << flush;
  77. +          INFO ("Output: OK url=\"" << Proxy::getDenyAddr () << "/blocked.php?action=userdisabled&id=" << *usr << "\"");
  78. +          cout << "OK url=\"" << Proxy::getDenyAddr () << "/blocked.php?action=userdisabled&id=" << *usr << "\"" << endl << flush;
  79.            continue;
  80.          }
  81.  
  82. @@ -293,9 +297,8 @@
  83.        if (!tpl)
  84.          {
  85.            INFO ("Reason: User's template not found");
  86. -          INFO ("Output: " << Proxy::getDenyAddr () << "/blocked.php?action=templatenotfound&id=" << *usr << " " << fields[1] << " " << fields[2] << " " << fields[3]);
  87. -          cout << Proxy::getDenyAddr () << "/blocked.php?action=templatenotfound&id=" << *usr;
  88. -          cout << " " << fields[1] << " " << fields[2] << " " << fields[3] << endl << flush;
  89. +          INFO ("Output: OK url=\"" << Proxy::getDenyAddr () << "/blocked.php?action=templatenotfound&id=" << *usr << "\"");
  90. +          cout << "OK url=\"" << Proxy::getDenyAddr () << "/blocked.php?action=templatenotfound&id=" << *usr << "\"" << endl << flush;
  91.            continue;
  92.          }
  93.  
  94. @@ -303,8 +306,8 @@
  95.        if ( tpl->isUrlWhitelisted (fields[0]) )
  96.          {
  97.            INFO ("Reason: In white list");
  98. -          INFO ("Output: " << line);
  99. -     cout << line << endl << flush;
  100. +          INFO ("Output: ERR");
  101. +     cout << "ERR" << endl << flush;
  102.            continue;
  103.          }
  104.  
  105. @@ -312,9 +315,8 @@
  106.        if ( tpl->isUrlBlacklisted (fields[0]) )
  107.          {
  108.            INFO ("Reason: In black list");
  109. -          INFO ("Output: " << Proxy::getDenyAddr () << "/blocked.php?action=urldenied&id=" << *usr << " " << fields[1] << " " << fields[2] << " " << fields[3]);
  110. -          cout << Proxy::getDenyAddr () << "/blocked.php?action=urldenied&id=" << *usr;
  111. -          cout << " " << fields[1] << " " << fields[2] << " " << fields[3] << endl << flush;
  112. +          INFO ("Output: OK url=\"" << Proxy::getDenyAddr () << "/blocked.php?action=urldenied&id=" << *usr << "\"");
  113. +          cout << "OK url=\"" << Proxy::getDenyAddr () << "/blocked.php?action=urldenied&id=" << *usr << "\"" << endl << flush;
  114.            continue;
  115.          }
  116.  
  117. @@ -322,9 +324,8 @@
  118.        if ( tpl->isUrlMatchRegex (fields[0]) )
  119.          {
  120.            INFO ("Reason: In regular expression list");
  121. -          INFO ("Output: " << Proxy::getDenyAddr () << "/blocked.php?action=urldenied&id=" << *usr << " " << fields[1] << " " << fields[2] << " " << fields[3]);
  122. -          cout << Proxy::getDenyAddr () << "/blocked.php?action=urldenied&id=" << *usr;
  123. -          cout << " " << fields[1] << " " << fields[2] << " " << fields[3] << endl << flush;
  124. +          INFO ("Output: OK url=\"" << Proxy::getDenyAddr () << "/blocked.php?action=urldenied&id=" << *usr << "\"");
  125. +          cout << "OK url=\"" << Proxy::getDenyAddr () << "/blocked.php?action=urldenied&id=" << *usr << "\"" << endl << flush;
  126.            continue;
  127.          }
  128.  
  129. @@ -332,9 +333,8 @@
  130.        if ( tpl->isUrlHasFileExt (fields[0]) )
  131.          {
  132.            INFO ("Reason: Has disallowed file extension");
  133. -          INFO ("Output: " << Proxy::getDenyAddr () << "/blocked.php?action=urldenied&id=" << *usr << " " << fields[1] << " " << fields[2] << " " << fields[3]);
  134. -          cout << Proxy::getDenyAddr () << "/blocked.php?action=urldenied&id=" << *usr;
  135. -          cout << " " << fields[1] << " " << fields[2] << " " << fields[3] << endl << flush;
  136. +          INFO ("Output: OK url=\"" << Proxy::getDenyAddr () << "/blocked.php?action=urldenied&id=" << *usr << "\"");
  137. +          cout << "OK url=\"" << Proxy::getDenyAddr () << "/blocked.php?action=urldenied&id=" << *usr << "\"" << endl << flush;
  138.            continue;
  139.          }
  140.  
  141. @@ -342,18 +342,16 @@
  142.        if ( tpl->isTimeDenied (fields[0]) )
  143.          {
  144.            INFO ("Reason: Denied due to time restrictions");
  145. -          INFO ("Output: " << Proxy::getDenyAddr () << "/blocked.php?action=timedenied&id=" << *usr << " " << fields[1] << " " << fields[2] << " " << fields[3]);
  146. -          cout << Proxy::getDenyAddr () << "/blocked.php?action=timedenied&id=" << *usr;
  147. -          cout << " " << fields[1] << " " << fields[2] << " " << fields[3] << endl << flush;
  148. +          INFO ("Output: OK url=\"" << Proxy::getDenyAddr () << "/blocked.php?action=timedenied&id=" << *usr << "\"");
  149. +          cout << "OK url=\"" << Proxy::getDenyAddr () << "/blocked.php?action=timedenied&id=" << *usr << "\"" << endl << flush;
  150.            continue;
  151.          }
  152.  
  153.        if ( tpl->getAllDeny () )
  154.          {
  155.            INFO ("Reason: Denied to all and not whitelisted");
  156. -          INFO ("Output: " << Proxy::getDenyAddr () << "/blocked.php?action=urldenied&id=" << *usr << " " << fields[1] << " " << fields[2] << " " << fields[3]);
  157. -          cout << Proxy::getDenyAddr () << "/blocked.php?action=urldenied&id=" << *usr;
  158. -          cout << " " << fields[1] << " " << fields[2] << " " << fields[3] << endl << flush;
  159. +          INFO ("Output: OK url=\"" << Proxy::getDenyAddr () << "/blocked.php?action=urldenied&id=" << *usr << "\"");
  160. +          cout << "OK url=\"" << Proxy::getDenyAddr () << "/blocked.php?action=urldenied&id=" << *usr << "\"" << endl << flush;
  161.            continue;
  162.          }
  163.  
  164. @@ -361,16 +359,15 @@
  165.        if (!destination.empty ())
  166.          {
  167.            INFO ("Reason: Redirected to another location");
  168. -          INFO ("Output: " << destination << " " << fields[1] << " " << fields[2] << " " << fields[3]);
  169. -          cout << destination;
  170. -          cout << " " << fields[1] << " " << fields[2] << " " << fields[3] << endl << flush;
  171. +          INFO ("Output: OK url=\"" << destination << "\"");
  172. +          cout << "OK url=\"" << destination << "\"" << endl << flush;
  173.            continue;
  174.          }
  175.  
  176.        // Все проверки пройдены успешно, разрешаем доступ
  177.        INFO ("Reason: Access granted");
  178. -      INFO ("Output: " << line);
  179. -      cout << line << endl << flush;
  180. +      INFO ("Output: ERR");
  181. +      cout << "ERR" << endl << flush;
  182.      }
  183.  
  184.    delete conn;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement