Skip to content

Commit bd05793

Browse files
feature: add ngx_stream_lua_ffi_get_upstream_ssl_pointer.
1 parent af519b2 commit bd05793

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/ngx_stream_lua_ssl.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
#if (NGX_STREAM_SSL)
2222

23+
#include "ngx_stream_lua_ssl.h"
24+
2325

2426
int ngx_stream_lua_ssl_ctx_index = -1;
2527
int ngx_stream_lua_ssl_key_log_index = -1;
@@ -58,4 +60,32 @@ ngx_stream_lua_ssl_init(ngx_log_t *log)
5860
}
5961

6062

63+
ngx_ssl_conn_t *
64+
ngx_stream_lua_ffi_get_upstream_ssl_pointer(ngx_stream_lua_request_t *r,
65+
const char **err)
66+
{
67+
ngx_connection_t *c;
68+
69+
if (r == NULL || r->connection == NULL || r->session == NULL) {
70+
*err = "bad request";
71+
return NULL;
72+
}
73+
74+
if (r->session->upstream == NULL
75+
|| r->session->upstream->peer.connection == NULL) {
76+
*err = "not upstream";
77+
return NULL;
78+
}
79+
80+
c = r->session->upstream->peer.connection;
81+
82+
if (c->ssl == NULL || c->ssl->connection == NULL) {
83+
*err = "not ssl connection";
84+
return NULL;
85+
}
86+
87+
return c->ssl->connection;
88+
}
89+
90+
6191
#endif /* NGX_STREAM_SSL */

0 commit comments

Comments
 (0)