[sr-dev] git:master:377a23b8: tls_wolfssl: add timestamp and sni info for a session

S-P Chan shihping.chan at gmail.com
Fri Aug 19 16:21:49 CEST 2022


Module: kamailio
Branch: master
Commit: 377a23b8f0152d9c61ddf17e4b95d7fa08dd11d9
URL: https://github.com/kamailio/kamailio/commit/377a23b8f0152d9c61ddf17e4b95d7fa08dd11d9

Author: S-P Chan <shihping.chan at gmail.com>
Committer: S-P Chan <shihping.chan at gmail.com>
Date: 2022-08-19T22:20:52+08:00

tls_wolfssl: add timestamp and sni info for a session

- ref: commit c0c1dcc100 for tls

---

Modified: src/modules/tls_wolfssl/tls_rpc.c

---

Diff:  https://github.com/kamailio/kamailio/commit/377a23b8f0152d9c61ddf17e4b95d7fa08dd11d9.diff
Patch: https://github.com/kamailio/kamailio/commit/377a23b8f0152d9c61ddf17e4b95d7fa08dd11d9.patch

---

diff --git a/src/modules/tls_wolfssl/tls_rpc.c b/src/modules/tls_wolfssl/tls_rpc.c
index 6ee5a14e023..887ac451aa4 100644
--- a/src/modules/tls_wolfssl/tls_rpc.c
+++ b/src/modules/tls_wolfssl/tls_rpc.c
@@ -115,6 +115,9 @@ static void tls_list(rpc_t* rpc, void* c)
 	struct tls_extra_data* tls_d;
 	struct tcp_connection* con;
 	int i, len, timeout;
+	struct tm timestamp;
+	char timestamp_s[128];
+	const char* sni;
 
 	TCPCONN_LOCK;
 	for(i = 0; i < TCP_ID_HASH_SIZE; i++) {
@@ -132,8 +135,29 @@ static void tls_list(rpc_t* rpc, void* c)
 				BUG("failed to convert destination ip");
 			dst_ip[len] = 0;
 			timeout = TICKS_TO_S(con->timeout - get_ticks_raw());
-			rpc->struct_add(handle, "ddsdsd",
+			timestamp = *localtime(&con->timestamp);
+			if (snprintf(timestamp_s, 128, "%d-%02d-%02d %02d:%02d:%02d", timestamp.tm_year + 1900,
+					timestamp.tm_mon + 1, timestamp.tm_mday, timestamp.tm_hour,
+					timestamp.tm_min, timestamp.tm_sec) < 0) {
+				timestamp_s[0] = 'N';
+				timestamp_s[1] = '/';
+				timestamp_s[2] = 'A';
+				timestamp_s[3] = '\0';
+			}
+
+			if (tls_d) {
+				sni = wolfSSL_get_servername(tls_d->ssl, TLSEXT_NAMETYPE_host_name);
+				if (sni == NULL) {
+					sni = "N/A";
+				}
+			} else {
+				sni = "N/A";
+			}
+
+			rpc->struct_add(handle, "dssdsdsd",
 					"id", con->id,
+					"sni", sni,
+					"timestamp", timestamp_s,
 					"timeout", timeout,
 					"src_ip", src_ip,
 					"src_port", con->rcv.src_port,




More information about the sr-dev mailing list