#include <CacheManager.h>


Public Types | |
typedef std::vector< Mgr::ActionProfilePointer > | Menu |
Public Member Functions | |
void | registerProfile (char const *action, char const *desc, OBJH *handler, int pw_req_flag, int atomic) |
void | registerProfile (char const *action, char const *desc, Mgr::ClassActionCreationHandler *handler, int pw_req_flag, int atomic) |
Mgr::ActionProfilePointer | findAction (char const *action) const |
Mgr::Action::Pointer | createNamedAction (const char *actionName) |
Mgr::Action::Pointer | createRequestedAction (const Mgr::ActionParams &) |
const Menu & | menu () const |
void | start (const Comm::ConnectionPointer &client, HttpRequest *request, StoreEntry *entry, const AccessLogEntryPointer &ale) |
const char * | ActionProtection (const Mgr::ActionProfilePointer &profile) |
Static Public Member Functions | |
static CacheManager * | GetInstance () |
Protected Member Functions | |
CacheManager () | |
use Instance() instead More... | |
Mgr::CommandPointer | ParseUrl (const AnyP::Uri &) |
void | ParseHeaders (const HttpRequest *request, Mgr::ActionParams ¶ms) |
int | CheckPassword (const Mgr::Command &cmd) |
char * | PasswdGet (Mgr::ActionPasswordList *, const char *) |
void | registerProfile (const Mgr::ActionProfilePointer &profile) |
Registers new profiles, ignoring attempts to register a duplicate. More... | |
Protected Attributes | |
Menu | menu_ |
Detailed Description
a CacheManager - the menu system for interacting with squid. This is currently just an adapter to the global cachemgr* routines to provide looser coupling between modules, but once fully transitioned, an instance of this class will represent a single independent manager. TODO: update documentation to reflect the new singleton model.
Definition at line 31 of file CacheManager.h.
Member Typedef Documentation
◆ Menu
Definition at line 34 of file CacheManager.h.
Constructor & Destructor Documentation
◆ CacheManager()
|
inlineprotected |
Definition at line 53 of file CacheManager.h.
Referenced by GetInstance().
Member Function Documentation
◆ ActionProtection()
const char * CacheManager::ActionProtection | ( | const Mgr::ActionProfilePointer & | profile | ) |
Definition at line 437 of file cache_manager.cc.
References assert, Config, SquidConfig::passwd_list, and PasswdGet().
Referenced by Mgr::MenuAction::dump(), and ParseUrl().
◆ CheckPassword()
|
protected |
- Return values
-
0 if mgr->password is good or "none" 1 if mgr->password is "disable" !0 if mgr->password does not match configured password
Definition at line 284 of file cache_manager.cc.
References action(), assert, Config, debugs, Mgr::Command::params, SquidConfig::passwd_list, PasswdGet(), Mgr::ActionParams::password, Mgr::Command::profile, and String::size().
Referenced by start().
◆ createNamedAction()
Mgr::Action::Pointer CacheManager::createNamedAction | ( | const char * | actionName | ) |
Definition at line 131 of file cache_manager.cc.
References findAction(), and Must.
Referenced by Mgr::Response::Response(), and TestCacheManager::testRegister().
◆ createRequestedAction()
Mgr::Action::Pointer CacheManager::createRequestedAction | ( | const Mgr::ActionParams & | params | ) |
Definition at line 144 of file cache_manager.cc.
References Mgr::ActionParams::actionName, findAction(), Must, and String::termedBuf().
Referenced by Ipc::Coordinator::handleCacheMgrRequest(), and Ipc::Strand::handleCacheMgrRequest().
◆ findAction()
Mgr::ActionProfile::Pointer CacheManager::findAction | ( | char const * | action | ) | const |
Locates an action in the actions registry ActionsList.
- Return values
-
NULL if Action not found CacheManagerAction* if the action was found
Definition at line 113 of file cache_manager.cc.
References action(), debugs, menu_, and Must.
Referenced by createNamedAction(), createRequestedAction(), ParseUrl(), and registerProfile().
◆ GetInstance()
|
static |
Definition at line 479 of file cache_manager.cc.
References CacheManager(), debugs, instance, and Mgr::RegisterBasics().
Referenced by Mgr::Response::Response(), Mgr::MenuAction::dump(), Ipc::Coordinator::handleCacheMgrRequest(), Ipc::Strand::handleCacheMgrRequest(), internalStart(), Mgr::RegisterAction(), FwdState::Start(), TestCacheManager::testCreate(), TestCacheManager::testParseUrl(), and TestCacheManager::testRegister().
◆ menu()
|
inline |
Definition at line 45 of file CacheManager.h.
References menu_.
Referenced by Mgr::MenuAction::dump().
◆ ParseHeaders()
|
protected |
Definition at line 244 of file cache_manager.cc.
References assert, Http::AUTHORIZATION, DBG_IMPORTANT, debugs, HttpRequest::flags, HttpHeader::getAuthToken(), Http::Message::header, Mgr::ActionParams::httpFlags, Mgr::ActionParams::httpMethod, HttpRequestMethod::id(), HttpRequest::method, SBuf::npos, Mgr::ActionParams::password, SBufToString(), and Mgr::ActionParams::userName.
Referenced by start().
◆ ParseUrl()
|
protected |
define whether the URL is a cache-manager URL and parse the action requested by the user. Checks via CacheManager::ActionProtection() that the item is accessible by the user.
Syntax:
scheme "://" authority [ '/squid-internal-mgr' ] path-absolute [ '@' unreserved ] '?' query-string
see RFC 3986 for definitions of scheme, authority, path-absolute, query-string
- Returns
- Mgr::Command object with action to perform and parameters it might use
Definition at line 180 of file cache_manager.cc.
References AnyP::Uri::absolute(), action(), ActionProtection(), debugs, findAction(), AnyP::Uri::getScheme(), Here, AnyP::Uri::host(), MgrFieldChars(), Mgr::QueryParams::Parse(), AnyP::Uri::path(), AnyP::PROTO_CACHE_OBJECT, SBufToString(), and ToSBuf().
Referenced by CacheManagerInternals::ParseUrl(), and start().
◆ PasswdGet()
|
protected |
Definition at line 460 of file cache_manager.cc.
References action(), Mgr::ActionPasswordList::actions, Mgr::ActionPasswordList::next, and Mgr::ActionPasswordList::passwd.
Referenced by ActionProtection(), and CheckPassword().
◆ registerProfile() [1/3]
void CacheManager::registerProfile | ( | char const * | action, |
char const * | desc, | ||
Mgr::ClassActionCreationHandler * | handler, | ||
int | pw_req_flag, | ||
int | atomic | ||
) |
◆ registerProfile() [2/3]
void CacheManager::registerProfile | ( | char const * | action, |
char const * | desc, | ||
OBJH * | handler, | ||
int | pw_req_flag, | ||
int | atomic | ||
) |
Registers a C-style action, which is implemented as a pointer to a function taking as argument a pointer to a StoreEntry and returning void. Implemented via CacheManagerActionLegacy.
Definition at line 82 of file cache_manager.cc.
References action(), debugs, handler(), and registerProfile().
Referenced by Mgr::RegisterAction(), registerProfile(), and TestCacheManager::testRegister().
◆ registerProfile() [3/3]
|
protected |
Definition at line 64 of file cache_manager.cc.
References debugs, findAction(), menu_, and Must.
◆ start()
void CacheManager::start | ( | const Comm::ConnectionPointer & | client, |
HttpRequest * | request, | ||
StoreEntry * | entry, | ||
const AccessLogEntryPointer & | ale | ||
) |
Main entry point in the Cache Manager's activity. Gets called as part of the forward chain if the right URL is detected there. Initiates all needed internal work and renders the response.
Definition at line 314 of file cache_manager.cc.
References action(), HttpReply::body, ErrorState::BuildHttpReply(), CheckPassword(), StoreEntry::complete(), HttpBody::content(), CurrentException(), DBG_IMPORTANT, debugs, ERR_CACHE_MGR_ACCESS_DENIED, ERR_INVALID_URL, errorAppendEntry(), StoreEntry::expires, HttpHeader::getStr(), HttpHeader::has(), Http::Message::header, Here, IamWorkerProcess(), MGR_INDEX, Must, Http::ORIGIN, ParseHeaders(), ParseUrl(), Http::ProtocolVersion(), HttpHeader::putAuth(), HttpHeader::putExt(), StoreEntry::replaceHttpReply(), Http::scNotFound, Http::scOkay, Http::scUnauthorized, Http::StatusLine::set(), HttpReply::sline, squid_curtime, AsyncJob::Start(), ErrorState::url, HttpRequest::url, StoreEntry::url(), UsingSmp(), and xstrdup.
Referenced by internalStart(), and FwdState::Start().
Member Data Documentation
◆ menu_
|
protected |
Definition at line 62 of file CacheManager.h.
Referenced by findAction(), menu(), and registerProfile().
The documentation for this class was generated from the following files:
- src/CacheManager.h
- src/cache_manager.cc
- src/tests/stub_cache_manager.cc