Mercurial > prosody-hg
comparison plugins/mod_c2s.lua @ 11608:b2610460d9ab
mod_c2s,mod_s2s: Collect stats on TLS versions and ciphers
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Wed, 16 Jun 2021 00:00:17 +0200 |
| parents | 3bbb1af92514 |
| children | 1ac8976f09a9 |
comparison
equal
deleted
inserted
replaced
| 11607:03eb4c0dca27 | 11608:b2610460d9ab |
|---|---|
| 37 | 37 |
| 38 local stream_callbacks = { default_ns = "jabber:client" }; | 38 local stream_callbacks = { default_ns = "jabber:client" }; |
| 39 local listener = {}; | 39 local listener = {}; |
| 40 local runner_callbacks = {}; | 40 local runner_callbacks = {}; |
| 41 | 41 |
| 42 local m_tls_params = module:metric( | |
| 43 "counter", "encrypted", "", | |
| 44 "Encrypted connections", | |
| 45 {"protocol"; "cipher"} | |
| 46 ); | |
| 47 | |
| 42 module:hook("stats-update", function () | 48 module:hook("stats-update", function () |
| 43 -- for push backends, avoid sending out updates for each increment of | 49 -- for push backends, avoid sending out updates for each increment of |
| 44 -- the metric below. | 50 -- the metric below. |
| 45 statsmanager.cork() | 51 statsmanager.cork() |
| 46 measure_connections:clear() | 52 measure_connections:clear() |
| 113 local sock = session.conn:socket(); | 119 local sock = session.conn:socket(); |
| 114 if sock.info then | 120 if sock.info then |
| 115 local info = sock:info(); | 121 local info = sock:info(); |
| 116 (session.log or log)("info", "Stream encrypted (%s with %s)", info.protocol, info.cipher); | 122 (session.log or log)("info", "Stream encrypted (%s with %s)", info.protocol, info.cipher); |
| 117 session.compressed = info.compression; | 123 session.compressed = info.compression; |
| 124 m_tls_params:with_labels(info.protocol, info.cipher):add(1) | |
| 118 else | 125 else |
| 119 (session.log or log)("info", "Stream encrypted"); | 126 (session.log or log)("info", "Stream encrypted"); |
| 120 end | 127 end |
| 121 end | 128 end |
| 122 | 129 |
