Use parent protoctx for autossl ctx

This fixes a crash.
And improve logging.
This commit is contained in:
Soner Tari 2022-04-11 12:27:30 +03:00
parent 63a48308cd
commit 3a215f4f3f

View File

@ -245,13 +245,13 @@ protoautossl_peek_and_upgrade(pxy_conn_ctx_t *ctx)
if (!ctx->children) { if (!ctx->children) {
// This means that there was no autossl handshake prior to ClientHello, e.g. no STARTTLS message // This means that there was no autossl handshake prior to ClientHello, e.g. no STARTTLS message
// This is perhaps the SSL handshake of a direct SSL connection // This is perhaps the SSL handshake of a direct SSL connection
log_err_level(LOG_CRIT, "No children setup yet, upgrading srvdst"); log_fine("Upgrading srvdst, no child conn set up yet");
protoautossl_upgrade_srvdst(ctx); protoautossl_upgrade_srvdst(ctx);
bufferevent_enable(ctx->srvdst.bev, EV_READ|EV_WRITE); bufferevent_enable(ctx->srvdst.bev, EV_READ|EV_WRITE);
} }
else { else {
// @attention Autossl protocol should never have multiple children. // @attention Autossl protocol should never have multiple children.
log_err_level(LOG_CRIT, "Upgrading child dst"); log_fine("Upgrading child dst");
protoautossl_upgrade_dst_child(ctx->children); protoautossl_upgrade_dst_child(ctx->children);
} }
@ -263,6 +263,9 @@ protoautossl_peek_and_upgrade(pxy_conn_ctx_t *ctx)
if (pxy_set_sslproxy_header(ctx, 1) == -1) { if (pxy_set_sslproxy_header(ctx, 1) == -1) {
return -1; return -1;
} }
} else {
log_err_level(LOG_CRIT, "No sslproxy_header set up in divert mode in autossl");
return -1;
} }
} else { } else {
// srvdst == dst in split mode // srvdst == dst in split mode
@ -566,7 +569,7 @@ protoautossl_enable_conn_src_child(pxy_conn_child_ctx_t *ctx)
// Now open the gates for a second time after autossl upgrade // Now open the gates for a second time after autossl upgrade
bufferevent_enable(ctx->conn->src.bev, EV_READ|EV_WRITE); bufferevent_enable(ctx->conn->src.bev, EV_READ|EV_WRITE);
protoautossl_ctx_t *autossl_ctx = ctx->protoctx->arg; protoautossl_ctx_t *autossl_ctx = ctx->conn->protoctx->arg;
autossl_ctx->clienthello_found = 0; autossl_ctx->clienthello_found = 0;
return 0; return 0;
} }