]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/ssl/context_storage.cc
2 #include "mgr/Registration.h"
3 #include "ssl/context_storage.h"
5 #include "StoreEntryStream.h"
9 #include <openssl/ssl.h>
12 Ssl::CertificateStorageAction::CertificateStorageAction(const Mgr::Command::Pointer
&aCmd
)
16 Ssl::CertificateStorageAction::Pointer
17 Ssl::CertificateStorageAction::Create(const Mgr::Command::Pointer
&aCmd
)
19 return new CertificateStorageAction(aCmd
);
22 void Ssl::CertificateStorageAction::dump (StoreEntry
*sentry
)
24 StoreEntryStream
stream(sentry
);
25 const char delimiter
= '\t';
26 const char endString
= '\n';
28 stream
<< "Cached ssl certificates statistic.\n";
29 // Title of statistic table.
30 stream
<< "Port" << delimiter
<< "Max mem(KB)" << delimiter
<< "Cert number" << delimiter
<< "KB/cert" << delimiter
<< "Mem used(KB)" << delimiter
<< "Mem free(KB)" << endString
;
32 // Add info for each port.
33 for (std::map
<Ip::Address
, LocalContextStorage
*>::iterator i
= TheGlobalContextStorage
.storage
.begin(); i
!= TheGlobalContextStorage
.storage
.end(); ++i
) {
34 stream
<< i
->first
<< delimiter
;
35 LocalContextStorage
& ssl_store_policy(*(i
->second
));
36 stream
<< ssl_store_policy
.memLimit() / 1024 << delimiter
;
37 stream
<< ssl_store_policy
.entries() << delimiter
;
38 stream
<< SSL_CTX_SIZE
/ 1024 << delimiter
;
39 stream
<< ssl_store_policy
.size() / 1024 << delimiter
;
40 stream
<< ssl_store_policy
.freeMem() / 1024 << endString
;
46 ///////////////////////////////////////////////////////
48 Ssl::GlobalContextStorage::GlobalContextStorage()
51 RegisterAction("cached_ssl_cert", "Statistic of cached generated ssl certificates", &CertificateStorageAction::Create
, 0, 1);
54 Ssl::GlobalContextStorage::~GlobalContextStorage()
56 for (std::map
<Ip::Address
, LocalContextStorage
*>::iterator i
= storage
.begin(); i
!= storage
.end(); ++i
) {
61 void Ssl::GlobalContextStorage::addLocalStorage(Ip::Address
const & address
, size_t size_of_store
)
63 assert(reconfiguring
);
64 configureStorage
.insert(std::pair
<Ip::Address
, size_t>(address
, size_of_store
));
67 Ssl::LocalContextStorage
*Ssl::GlobalContextStorage::getLocalStorage(Ip::Address
const & address
)
70 std::map
<Ip::Address
, LocalContextStorage
*>::iterator i
= storage
.find(address
);
72 if (i
== storage
.end())
78 void Ssl::GlobalContextStorage::reconfigureStart()
80 configureStorage
.clear();
84 void Ssl::GlobalContextStorage::reconfigureFinish()
87 reconfiguring
= false;
89 // remove or change old local storages.
90 for (std::map
<Ip::Address
, LocalContextStorage
*>::iterator i
= storage
.begin(); i
!= storage
.end(); ++i
) {
91 std::map
<Ip::Address
, size_t>::iterator conf_i
= configureStorage
.find(i
->first
);
92 if (conf_i
== configureStorage
.end() || conf_i
->second
<= 0) {
95 i
->second
->setMemLimit(conf_i
->second
);
99 // add new local storages.
100 for (std::map
<Ip::Address
, size_t>::iterator conf_i
= configureStorage
.begin(); conf_i
!= configureStorage
.end(); ++conf_i
) {
101 if (storage
.find(conf_i
->first
) == storage
.end() && conf_i
->second
> 0) {
102 storage
.insert(std::pair
<Ip::Address
, LocalContextStorage
*>(conf_i
->first
, new LocalContextStorage(-1, conf_i
->second
)));
108 Ssl::GlobalContextStorage
Ssl::TheGlobalContextStorage
;