]>
Commit | Line | Data |
---|---|---|
95d2589c CT |
1 | #ifndef SQUID_SSL_CONTEXT_STORAGE_H |
2 | #define SQUID_SSL_CONTEXT_STORAGE_H | |
3 | ||
4 | #if USE_SSL | |
5 | ||
14798e73 | 6 | #include "base/LruMap.h" |
95d2589c CT |
7 | #include "SquidTime.h" |
8 | #include "CacheManager.h" | |
c6983ec7 | 9 | #include "ip/Address.h" |
95d2589c CT |
10 | #include "mgr/Action.h" |
11 | #include "mgr/Command.h" | |
14798e73 | 12 | #include "ssl/gadgets.h" |
95d2589c CT |
13 | #if HAVE_MAP |
14 | #include <map> | |
15 | #endif | |
16 | #if HAVE_LIST | |
17 | #include <list> | |
18 | #endif | |
a011edee FC |
19 | #include <openssl/ssl.h> |
20 | ||
95d2589c CT |
21 | /// TODO: Replace on real size. |
22 | #define SSL_CTX_SIZE 1024 | |
23 | ||
24 | namespace Ssl | |
25 | { | |
26 | ||
27 | /** Reports cached SSL certificate stats to Cache Manager. | |
28 | * TODO: Use "Report" functions instead friend class. | |
29 | */ | |
30 | class CertificateStorageAction : public Mgr::Action | |
31 | { | |
32 | public: | |
33 | CertificateStorageAction(const Mgr::Command::Pointer &cmd); | |
34 | static Pointer Create(const Mgr::Command::Pointer &cmd); | |
35 | virtual void dump (StoreEntry *sentry); | |
36 | /** | |
37 | * We do not support aggregation of information across workers | |
38 | * TODO: aggregate these stats | |
39 | */ | |
40 | virtual bool aggregatable() const { return false; } | |
41 | }; | |
42 | ||
14798e73 | 43 | typedef LruMap<SSL_CTX_Pointer, SSL_CTX_SIZE> LocalContextStorage; |
95d2589c | 44 | |
95d2589c CT |
45 | /// Class for storing/manipulating LocalContextStorage per local listening address/port. |
46 | class GlobalContextStorage | |
47 | { | |
48 | friend class CertificateStorageAction; | |
49 | public: | |
50 | GlobalContextStorage(); | |
51 | ~GlobalContextStorage(); | |
52 | /// Create new SSL context storage for the local listening address/port. | |
53 | void addLocalStorage(Ip::Address const & address, size_t size_of_store); | |
54 | /// Return the local storage for the given listening address/port. | |
55 | LocalContextStorage & getLocalStorage(Ip::Address const & address); | |
56 | /// When reconfigring should be called this method. | |
57 | void reconfigureStart(); | |
58 | private: | |
59 | /// Called by getLocalStorage method | |
60 | void reconfigureFinish(); | |
61 | bool reconfiguring; ///< True if system reconfiguring now. | |
62 | /// Storage used on configure or reconfigure. | |
63 | std::map<Ip::Address, size_t> configureStorage; | |
64 | /// Map for storing all local ip address and their local storages. | |
65 | std::map<Ip::Address, LocalContextStorage *> storage; | |
66 | }; | |
67 | ||
68 | /// Global cache for store all SSL server certificates. | |
69 | extern GlobalContextStorage TheGlobalContextStorage; | |
70 | } //namespace Ssl | |
71 | #endif // USE_SSL | |
72 | ||
73 | #endif // SQUID_SSL_CONTEXT_STORAGE_H |