Skip to content

Commit

Permalink
format + remove some redundant code
Browse files Browse the repository at this point in the history
  • Loading branch information
radkesvat committed May 2, 2024
1 parent 026d1f3 commit 72f95db
Show file tree
Hide file tree
Showing 30 changed files with 120 additions and 87 deletions.
21 changes: 21 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ endif()
set(ENABLE_ASAN OFF CACHE BOOL "enable address sanitizer" FORCE)

option(INCLUDE_TCP_LISTENER "link TcpListener staticly to the core" TRUE)
option(INCLUDE_UDP_LISTENER "link UdpListener staticly to the core" TRUE)
option(INCLUDE_LISTENER "link istener staticly to the core" TRUE)
option(INCLUDE_LOGGER_TUNNEL "link LoggerTunnel staticly to the core" TRUE)
option(INCLUDE_CONNECTOR "link Connector staticly to the core" TRUE)
option(INCLUDE_TCPCONNECTOR "link TcpConnector staticly to the core" TRUE)
Expand Down Expand Up @@ -103,6 +105,25 @@ target_link_directories(Waterwall PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/tunnels/ada
target_link_libraries(Waterwall TcpListener)
endif()


#udp listener
if (INCLUDE_UDP_LISTENER)
target_compile_definitions(Waterwall PUBLIC INCLUDE_UDP_LISTENER=1)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tunnels/adapters/listener/udp)
target_link_directories(Waterwall PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/tunnels/adapters/listener/udp)
target_link_libraries(Waterwall UdpListener)
endif()


#listener
if (INCLUDE_LISTENER)
target_compile_definitions(Waterwall PUBLIC INCLUDE_LISTENER=1)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tunnels/adapters/listener)
target_link_directories(Waterwall PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/tunnels/adapters/listener)
target_link_libraries(Waterwall Listener)
endif()


#connector
if (INCLUDE_CONNECTOR)
target_compile_definitions(Waterwall PUBLIC INCLUDE_CONNECTOR=1)
Expand Down
13 changes: 9 additions & 4 deletions core/static_tunnels.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
#include "tunnels/adapters/listener/tcp/tcp_listener.h"
#endif

#ifdef INCLUDE_UDP_LISTENER
#include "tunnels/adapters/listener/udp/udp_listener.h"
#endif

#ifdef INCLUDE_OPENSSL_SERVER
#include "tunnels/server/openssl/openssl_server.h"
#endif
Expand Down Expand Up @@ -158,10 +162,6 @@ void loadStaticTunnelsIntoCore()
USING(WolfSSLClient);
#endif

#ifdef INCLUDE_WOLFSSL_CLIENT
USING(WolfSSLClient);
#endif

#ifdef INCLUDE_HTTP2_SERVER
USING(Http2Server);
#endif
Expand Down Expand Up @@ -205,4 +205,9 @@ void loadStaticTunnelsIntoCore()
#ifdef INCLUDE_SOCKS_5_SERVER
USING(Socks5Server);
#endif





}
2 changes: 1 addition & 1 deletion tunnels/adapters/bridge/bridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static void upStream(tunnel_t *self, context_t *c)
state->pair->dw->downStream(state->pair->dw, c);
}

static inline void downStream(tunnel_t *self, context_t *c)
static void downStream(tunnel_t *self, context_t *c)
{

bridge_state_t *state = STATE(self);
Expand Down
2 changes: 1 addition & 1 deletion tunnels/adapters/listener/listener.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ tunnel_t *newListener(node_instance_context_t *instance_info)
tcp_outbound_node->name = concat(instance_info->node->name, "_tcp_inbound");
tcp_outbound_node->type = "TcpListener";
tcp_outbound_node->version = instance_info->node->version;
udp_outbound_node->name = concat(instance_info->node->name, "_tcp_inbound");
udp_outbound_node->name = concat(instance_info->node->name, "_udp_inbound");
udp_outbound_node->type = "UdpListener";
udp_outbound_node->version = instance_info->node->version;
registerNode(tcp_outbound_node, settings);
Expand Down
4 changes: 2 additions & 2 deletions tunnels/adapters/listener/tcp/tcp_listener.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ static void onWriteComplete(hio_t *restrict io)
}
}

static inline void upStream(tunnel_t *self, context_t *c)
static void upStream(tunnel_t *self, context_t *c)
{
if (c->payload != NULL)
{
Expand Down Expand Up @@ -192,7 +192,7 @@ static inline void upStream(tunnel_t *self, context_t *c)
self->up->upStream(self->up, c);
}

static inline void downStream(tunnel_t *self, context_t *c)
static void downStream(tunnel_t *self, context_t *c)
{
tcp_listener_con_state_t *cstate = CSTATE(c);

Expand Down
4 changes: 2 additions & 2 deletions tunnels/adapters/listener/udp/udp_listener.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static void cleanup(udp_listener_con_state_t *cstate)
free(cstate);
}

static inline void upStream(tunnel_t *self, context_t *c)
static void upStream(tunnel_t *self, context_t *c)
{
if (c->payload != NULL)
{
Expand Down Expand Up @@ -79,7 +79,7 @@ static inline void upStream(tunnel_t *self, context_t *c)
self->up->upStream(self->up, c);
}

static inline void downStream(tunnel_t *self, context_t *c)
static void downStream(tunnel_t *self, context_t *c)
{
udp_listener_con_state_t *cstate = CSTATE(c);

Expand Down
2 changes: 1 addition & 1 deletion tunnels/client/header/header_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static void upStream(tunnel_t *self, context_t *c)
self->up->upStream(self->up, c);
}

static inline void downStream(tunnel_t *self, context_t *c)
static void downStream(tunnel_t *self, context_t *c)
{

self->dw->downStream(self->dw, c);
Expand Down
4 changes: 2 additions & 2 deletions tunnels/client/http2/http2_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ static int onFrameRecvCallback(nghttp2_session *session, const nghttp2_frame *fr
return 0;
}

static inline void upStream(tunnel_t *self, context_t *c)
static void upStream(tunnel_t *self, context_t *c)
{
http2_client_state_t *state = STATE(self);

Expand Down Expand Up @@ -405,7 +405,7 @@ static inline void upStream(tunnel_t *self, context_t *c)
}
}

static inline void downStream(tunnel_t *self, context_t *c)
static void downStream(tunnel_t *self, context_t *c)
{
http2_client_state_t *state = STATE(self);
http2_client_con_state_t *con = CSTATE(c);
Expand Down
4 changes: 2 additions & 2 deletions tunnels/client/openssl/openssl_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ static void flushWriteQueue(tunnel_t *self, context_t *c)
}
}

static inline void upStream(tunnel_t *self, context_t *c)
static void upStream(tunnel_t *self, context_t *c)
{
oss_client_state_t *state = STATE(self);

Expand Down Expand Up @@ -233,7 +233,7 @@ failed:;
self->dw->downStream(self->dw, fail_context);
}

static inline void downStream(tunnel_t *self, context_t *c)
static void downStream(tunnel_t *self, context_t *c)
{
oss_client_con_state_t *cstate = CSTATE(c);

Expand Down
4 changes: 2 additions & 2 deletions tunnels/client/preconnect/preconnect_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "types.h"
#include "utils/jsonutils.h"

static inline void upStream(tunnel_t *self, context_t *c)
static void upStream(tunnel_t *self, context_t *c)
{

preconnect_client_state_t *state = STATE(self);
Expand Down Expand Up @@ -92,7 +92,7 @@ static inline void upStream(tunnel_t *self, context_t *c)
}
}

static inline void downStream(tunnel_t *self, context_t *c)
static void downStream(tunnel_t *self, context_t *c)
{
preconnect_client_state_t *state = STATE(self);
if (c->payload != NULL)
Expand Down
2 changes: 1 addition & 1 deletion tunnels/client/protobuf/protobuf_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ static void upStream(tunnel_t *self, context_t *c)
self->up->upStream(self->up, c);
}

static inline void downStream(tunnel_t *self, context_t *c)
static void downStream(tunnel_t *self, context_t *c)
{
protobuf_client_con_state_t *cstate = CSTATE(c);

Expand Down
4 changes: 2 additions & 2 deletions tunnels/client/reverse/reverse_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "types.h"
#include "utils/jsonutils.h"

static inline void upStream(tunnel_t *self, context_t *c)
static void upStream(tunnel_t *self, context_t *c)
{

reverse_client_state_t *state = STATE(self);
Expand Down Expand Up @@ -46,7 +46,7 @@ static inline void upStream(tunnel_t *self, context_t *c)
}
}

static inline void downStream(tunnel_t *self, context_t *c)
static void downStream(tunnel_t *self, context_t *c)
{
reverse_client_state_t *state = STATE(self);
uint8_t tid = c->line->tid;
Expand Down
4 changes: 2 additions & 2 deletions tunnels/client/todo/mux_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ static void checkUpCon(tunnel_t *self, size_t up_id)
}
}

static inline void upStream(tunnel_t *self, context_t *c)
static void upStream(tunnel_t *self, context_t *c)
{
mux_state_t *state = STATE(self);
// find proper up id
Expand Down Expand Up @@ -218,7 +218,7 @@ static inline void upStream(tunnel_t *self, context_t *c)
self->up->upStream(self->up, redir_context);
}

static inline void downStream(tunnel_t *self, context_t *c)
static void downStream(tunnel_t *self, context_t *c)
{
mux_state_t *state = STATE(self);

Expand Down
4 changes: 2 additions & 2 deletions tunnels/client/todo/zero_rtt_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ static void restablish(tunnel_t *self, context_t *src_base_ctx)
{
}

static inline void upStream(tunnel_t *self, context_t *c)
static void upStream(tunnel_t *self, context_t *c)
{
zero_rtt_con_t *cstate = CSTATE(c);

Expand Down Expand Up @@ -113,7 +113,7 @@ static inline void upStream(tunnel_t *self, context_t *c)

self->up->upStream(self->up, c);
}
static inline void downStream(tunnel_t *self, context_t *c)
static void downStream(tunnel_t *self, context_t *c)
{
zero_rtt_con_t *cstate = CSTATE(c);
if (c->est)
Expand Down
4 changes: 2 additions & 2 deletions tunnels/client/wolfssl/wolfssl_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ static void flushWriteQueue(tunnel_t *self, context_t *c)
}
}

static inline void upStream(tunnel_t *self, context_t *c)
static void upStream(tunnel_t *self, context_t *c)
{
wssl_client_state_t *state = STATE(self);

Expand Down Expand Up @@ -236,7 +236,7 @@ failed:;
self->dw->downStream(self->dw, fail_context);
}

static inline void downStream(tunnel_t *self, context_t *c)
static void downStream(tunnel_t *self, context_t *c)
{
wssl_client_con_state_t *cstate = CSTATE(c);

Expand Down
4 changes: 2 additions & 2 deletions tunnels/logger/logger_tunnel.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ typedef struct logger_tunnel_con_state_s

} logger_tunnel_con_state_t;

static inline void upStream(tunnel_t *self, context_t *c)
static void upStream(tunnel_t *self, context_t *c)
{

if (c->payload != NULL)
Expand Down Expand Up @@ -77,7 +77,7 @@ static inline void upStream(tunnel_t *self, context_t *c)
}
}

static inline void downStream(tunnel_t *self, context_t *c)
static void downStream(tunnel_t *self, context_t *c)
{

if (c->payload != NULL)
Expand Down
4 changes: 2 additions & 2 deletions tunnels/server/boringssl/boringssl_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
// }
// }

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

Expand Down Expand Up @@ -333,7 +333,7 @@
// return;
// }

// static inline void downStream(tunnel_t *self, context_t *c)
// static void downStream(tunnel_t *self, context_t *c)
// {
// oss_server_con_state_t *cstate = CSTATE(c);
// if (c->payload != NULL)
Expand Down
2 changes: 1 addition & 1 deletion tunnels/server/header/header_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ static void upStream(tunnel_t *self, context_t *c)
}
}

static inline void downStream(tunnel_t *self, context_t *c)
static void downStream(tunnel_t *self, context_t *c)
{

if (c->fin)
Expand Down
4 changes: 2 additions & 2 deletions tunnels/server/http2/http2_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ static bool trySendResponse(tunnel_t *self, http2_server_con_state_t *con, size_
return false;
}

static inline void upStream(tunnel_t *self, context_t *c)
static void upStream(tunnel_t *self, context_t *c)
{
http2_server_state_t *state = STATE(self);
if (c->payload != NULL)
Expand Down Expand Up @@ -355,7 +355,7 @@ static inline void upStream(tunnel_t *self, context_t *c)
}
}

static inline void downStream(tunnel_t *self, context_t *c)
static void downStream(tunnel_t *self, context_t *c)
{
http2_server_child_con_state_t *stream = CSTATE(c);
http2_server_con_state_t * con = stream->parent->chains_state[self->chain_index];
Expand Down
4 changes: 2 additions & 2 deletions tunnels/server/openssl/openssl_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ static void onFallbackTimer(htimer_t *timer)
free(data);
}

static inline void upStream(tunnel_t *self, context_t *c)
static void upStream(tunnel_t *self, context_t *c)
{
oss_server_state_t *state = STATE(self);
oss_server_con_state_t *cstate = CSTATE(c);
Expand Down Expand Up @@ -473,7 +473,7 @@ disconnect:;
self->dw->downStream(self->dw, fail_context);
}

static inline void downStream(tunnel_t *self, context_t *c)
static void downStream(tunnel_t *self, context_t *c)
{
oss_server_state_t *state = STATE(self);
oss_server_con_state_t *cstate = CSTATE(c);
Expand Down
2 changes: 1 addition & 1 deletion tunnels/server/preconnect/preconnect_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static void upStream(tunnel_t *self, context_t *c)
}
}

static inline void downStream(tunnel_t *self, context_t *c)
static void downStream(tunnel_t *self, context_t *c)
{

if (c->fin)
Expand Down
4 changes: 2 additions & 2 deletions tunnels/server/protobuf/protobuf_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static void cleanup(protobuf_server_con_state_t *cstate)
free(cstate);
}

static inline void upStream(tunnel_t *self, context_t *c)
static void upStream(tunnel_t *self, context_t *c)
{
protobuf_server_con_state_t *cstate = CSTATE(c);

Expand Down Expand Up @@ -130,7 +130,7 @@ static inline void upStream(tunnel_t *self, context_t *c)
destroyContext(c);
}

static inline void downStream(tunnel_t *self, context_t *c)
static void downStream(tunnel_t *self, context_t *c)
{

if (c->payload != NULL)
Expand Down
4 changes: 2 additions & 2 deletions tunnels/server/reverse/reverse_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static void flushWriteQueue(tunnel_t *self, reverse_server_con_state_t *cstate)
}
}

static inline void upStream(tunnel_t *self, context_t *c)
static void upStream(tunnel_t *self, context_t *c)
{

reverse_server_state_t *state = STATE(self);
Expand Down Expand Up @@ -114,7 +114,7 @@ static inline void upStream(tunnel_t *self, context_t *c)
}
}

static inline void downStream(tunnel_t *self, context_t *c)
static void downStream(tunnel_t *self, context_t *c)
{
reverse_server_state_t *state = STATE(self);
if (c->payload != NULL)
Expand Down
Loading

0 comments on commit 72f95db

Please sign in to comment.