]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * Copyright (C) 1996-2025 The Squid Software Foundation and contributors | |
3 | * | |
4 | * Squid software is distributed under GPLv2+ license and includes | |
5 | * contributions from numerous individuals and organizations. | |
6 | * Please see the COPYING and CONTRIBUTORS files for details. | |
7 | */ | |
8 | ||
9 | #ifndef SQUID_SRC_CACHEMANAGER_H | |
10 | #define SQUID_SRC_CACHEMANAGER_H | |
11 | ||
12 | #include "anyp/forward.h" | |
13 | #include "comm/forward.h" | |
14 | #include "log/forward.h" | |
15 | #include "mgr/Action.h" | |
16 | #include "mgr/ActionProfile.h" | |
17 | #include "mgr/Command.h" | |
18 | #include "mgr/forward.h" | |
19 | ||
20 | #include <vector> | |
21 | ||
22 | class HttpRequest; | |
23 | class HttpReply; | |
24 | ||
25 | /** | |
26 | * a CacheManager - the menu system for interacting with squid. | |
27 | * This is currently just an adapter to the global cachemgr* routines to | |
28 | * provide looser coupling between modules, but once fully transitioned, | |
29 | * an instance of this class will represent a single independent manager. | |
30 | * TODO: update documentation to reflect the new singleton model. | |
31 | */ | |
32 | class CacheManager | |
33 | { | |
34 | public: | |
35 | typedef std::vector<Mgr::ActionProfilePointer> Menu; | |
36 | ||
37 | /// initial URL path characters that identify cache manager requests | |
38 | static const SBuf &WellKnownUrlPathPrefix(); | |
39 | ||
40 | /// remembers the given profile while ignoring attempts to register a same-name duplicate | |
41 | void registerProfile(const Mgr::ActionProfilePointer &); | |
42 | ||
43 | Mgr::ActionProfilePointer findAction(char const * action) const; | |
44 | Mgr::Action::Pointer createNamedAction(const char *actionName); | |
45 | Mgr::Action::Pointer createRequestedAction(const Mgr::ActionParams &); | |
46 | const Menu& menu() const { return menu_; } | |
47 | ||
48 | void start(const Comm::ConnectionPointer &client, HttpRequest *request, StoreEntry *entry, const AccessLogEntryPointer &ale); | |
49 | ||
50 | static CacheManager* GetInstance(); | |
51 | const char *ActionProtection(const Mgr::ActionProfilePointer &profile); | |
52 | ||
53 | /// Add HTTP response headers specific/common to all cache manager replies, | |
54 | /// including cache manager errors and Action reports. | |
55 | /// \param httpOrigin the value of Origin header in the trigger HTTP request (or nil) | |
56 | static void PutCommonResponseHeaders(HttpReply &, const char *httpOrigin); | |
57 | ||
58 | protected: | |
59 | CacheManager() {} ///< use Instance() instead | |
60 | ||
61 | Mgr::CommandPointer ParseUrl(const AnyP::Uri &); | |
62 | void ParseHeaders(const HttpRequest * request, Mgr::ActionParams ¶ms); | |
63 | int CheckPassword(const Mgr::Command &cmd); | |
64 | char *PasswdGet(Mgr::ActionPasswordList *, const char *); | |
65 | ||
66 | Menu menu_; | |
67 | }; | |
68 | ||
69 | #endif /* SQUID_SRC_CACHEMANAGER_H */ | |
70 |