Skip to content

Commit

Permalink
refactor openssl
Browse files Browse the repository at this point in the history
  • Loading branch information
radkesvat committed Apr 19, 2024
1 parent 8c82132 commit 1ae769e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
28 changes: 16 additions & 12 deletions tunnels/server/openssl/openssl_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@

typedef struct
{
char * name;
int name_length;
tunnel_t *next;
char * name;
unsigned int name_length;
tunnel_t * next;
} alpn_item_t;

typedef struct oss_server_state_s
{
ssl_ctx_t ssl_context;
alpn_item_t *alpns;
int alpns_length;
unsigned int alpns_length;

// settings
tunnel_t *fallback;
Expand Down Expand Up @@ -183,11 +183,11 @@ static void onFallbackTimer(htimer_t *timer)

static inline void upStream(tunnel_t *self, context_t *c)
{
oss_server_state_t *state = STATE(self);
oss_server_state_t * state = STATE(self);
oss_server_con_state_t *cstate = CSTATE(c);

if (c->payload != NULL)
{
oss_server_con_state_t *cstate = CSTATE(c);

if (! cstate->handshake_completed)
{
Expand Down Expand Up @@ -414,18 +414,20 @@ static inline void upStream(tunnel_t *self, context_t *c)
SSL_set_bio(cstate->ssl, cstate->rbio, cstate->wbio);
if (state->anti_tit)
{
if (1 != SSL_set_record_padding_callback(cstate->ssl, padding_decision_cb))
if (1 != SSL_set_record_padding_callback(cstate->ssl, paddingDecisionCb))
{
LOGW("OpensslServer: Could not set ssl padding");
}
SSL_set_record_padding_callback_arg(cstate->ssl, cstate);
}
destroyContext(c);
}
else if (c->fin)
{

if (CSTATE(c)->fallback)
if (cstate->fallback)
{
if (CSTATE(c)->fallback_init_sent)
if (cstate->fallback_init_sent)
{
cleanup(self, c);
state->fallback->upStream(state->fallback, c);
Expand All @@ -436,7 +438,7 @@ static inline void upStream(tunnel_t *self, context_t *c)
destroyContext(c);
}
}
else if (CSTATE(c)->init_sent)
else if (cstate->init_sent)
{
cleanup(self, c);
self->up->upStream(self->up, c);
Expand Down Expand Up @@ -545,7 +547,9 @@ static inline void downStream(tunnel_t *self, context_t *c)
}

if (n == 0)
{
break;
}
}
assert(bufLen(c->payload) == 0);
reuseContextBuffer(c);
Expand All @@ -559,7 +563,7 @@ static inline void downStream(tunnel_t *self, context_t *c)
self->dw->downStream(self->dw, c);
return;
}
else if (c->fin)
if (c->fin)
{
cleanup(self, c);
self->dw->downStream(self->dw, c);
Expand Down Expand Up @@ -726,7 +730,7 @@ tunnel_t *newOpenSSLServer(node_instance_context_t *instance_info)
return t;
}

api_result_t apiOpenSSLServer(tunnel_t *self, char *msg)
api_result_t apiOpenSSLServer(tunnel_t *self,const char *msg)
{
(void) (self);
(void) (msg);
Expand Down
9 changes: 4 additions & 5 deletions tunnels/server/openssl/openssl_server.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#pragma once
#include "api.h"

//
//
// con <------> OpenSSL-server <------> TLS(con)
//
//

tunnel_t *newOpenSSLServer(node_instance_context_t *instance_info);
api_result_t apiOpenSSLServer(tunnel_t *self, char *msg);
tunnel_t *destroyOpenSSLServer(tunnel_t *self);
tunnel_t * newOpenSSLServer(node_instance_context_t *instance_info);
api_result_t apiOpenSSLServer(tunnel_t *self, char *msg);
tunnel_t * destroyOpenSSLServer(tunnel_t *self);
tunnel_metadata_t getMetadataOpenSSLServer();

0 comments on commit 1ae769e

Please sign in to comment.