]> git.ipfire.org Git - thirdparty/squid.git/blob - src/ssl/context_storage.h
Merged from trunk 13172.
[thirdparty/squid.git] / src / ssl / context_storage.h
1 #ifndef SQUID_SSL_CONTEXT_STORAGE_H
2 #define SQUID_SSL_CONTEXT_STORAGE_H
3
4 #if USE_SSL
5
6 #include "base/LruMap.h"
7 #include "CacheManager.h"
8 #include "ip/Address.h"
9 #include "mgr/Action.h"
10 #include "mgr/Command.h"
11 #include "SquidTime.h"
12 #include "ssl/gadgets.h"
13 #if HAVE_MAP
14 #include <map>
15 #endif
16 #if HAVE_LIST
17 #include <list>
18 #endif
19 #include <openssl/ssl.h>
20
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
43 typedef LruMap<SSL_CTX_Pointer, SSL_CTX_SIZE> LocalContextStorage;
44
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