Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
radkesvat committed Apr 3, 2024
1 parent 6c9e2aa commit 8dee1bb
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 33 deletions.
6 changes: 6 additions & 0 deletions core/static_tunnels.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@
#include "tunnels/client/preconnect/preconnect_client.h"
#endif

#ifdef INCLUDE_PRECONNECT_SERVER
#include "tunnels/server/preconnect/preconnect_server.h"
#endif


void loadStaticTunnelsIntoCore()
Expand Down Expand Up @@ -167,5 +170,8 @@ void loadStaticTunnelsIntoCore()
USING(PreConnectClient);
#endif

#ifdef INCLUDE_PRECONNECT_SERVER
USING(PreConnectServer);
#endif

}
2 changes: 1 addition & 1 deletion tunnels/adapters/connector/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "utils/sockutils.h"
#include "loggers/network_logger.h"

static void cleanup(tcp_listener_con_state_t *cstate)
static void cleanup(connector_con_state_t *cstate)
{
hio_t *last_resumed_io = NULL;

Expand Down
2 changes: 1 addition & 1 deletion tunnels/adapters/tcp_connector/tcp_connector.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "utils/sockutils.h"
#include "loggers/network_logger.h"

static void cleanup(tcp_listener_con_state_t *cstate)
static void cleanup(tcp_connector_con_state_t *cstate)
{
hio_t *last_resumed_io = NULL;

Expand Down
65 changes: 34 additions & 31 deletions tunnels/server/header/header_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,40 +33,43 @@ static void upStream(tunnel_t *self, context_t *c)
{
header_server_state_t *state = STATE(self);

if (c->payload != NULL && c->first)
if (c->payload != NULL)
{

shift_buffer_t *buf = c->payload;
if (bufLen(buf) < 2)
{
DISCARD_CONTEXT(c);
self->up->upStream(self->up, newFinContext(c->line));
self->dw->downStream(self->dw, newFinContext(c->line));
destroyContext(c);
return;
}

uint16_t port = 0;
switch ((enum header_dynamic_value_status)state->data.status)
if (c->first)
{
case hdvs_dest_port:

readUI16(buf, &port);
sockaddr_set_port(&(c->line->dest_ctx.addr), port);
shiftr(c->payload, sizeof(uint16_t));
break;

default:
(void)(0);
break;
}
CSTATE(c)->init_sent = true;
self->up->upStream(self->up, newInitContext(c->line));
if (!ISALIVE(c))
{
DISCARD_CONTEXT(c);
destroyContext(c);
return;
shift_buffer_t *buf = c->payload;
if (bufLen(buf) < 2)
{
DISCARD_CONTEXT(c);
self->up->upStream(self->up, newFinContext(c->line));
self->dw->downStream(self->dw, newFinContext(c->line));
destroyContext(c);
return;
}

uint16_t port = 0;
switch ((enum header_dynamic_value_status)state->data.status)
{
case hdvs_dest_port:

readUI16(buf, &port);
sockaddr_set_port(&(c->line->dest_ctx.addr), port);
shiftr(c->payload, sizeof(uint16_t));
break;

default:
(void)(0);
break;
}
CSTATE(c)->init_sent = true;
self->up->upStream(self->up, newInitContext(c->line));
if (!ISALIVE(c))
{
DISCARD_CONTEXT(c);
destroyContext(c);
return;
}
}
}
else if (c->init)
Expand Down

0 comments on commit 8dee1bb

Please sign in to comment.