From fa6a6b57958e1f1f4eff0ae5d5134a5c98370b99 Mon Sep 17 00:00:00 2001 From: Radkesvat <134321679+radkesvat@users.noreply.github.com> Date: Sun, 12 May 2024 16:33:10 +0000 Subject: [PATCH] address parsing bug fix --- .../adapters/connector/tcp/tcp_connector.c | 19 ++++++++++++++----- .../adapters/connector/udp/udp_connector.c | 12 +++++++++--- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/tunnels/adapters/connector/tcp/tcp_connector.c b/tunnels/adapters/connector/tcp/tcp_connector.c index 26970172..c87ed97a 100644 --- a/tunnels/adapters/connector/tcp/tcp_connector.c +++ b/tunnels/adapters/connector/tcp/tcp_connector.c @@ -1,9 +1,11 @@ #include "tcp_connector.h" +#include "basic_types.h" +#include "hsocket.h" #include "loggers/network_logger.h" #include "sync_dns.h" #include "types.h" -#include "utils/sockutils.h" #include "utils/jsonutils.h" +#include "utils/sockutils.h" static void cleanup(tcp_connector_con_state_t *cstate, bool write_queue) { @@ -84,7 +86,7 @@ static bool resumeWriteQueue(tcp_connector_con_state_t *cstate) } return true; } -static void onWriteComplete(hio_t * io) +static void onWriteComplete(hio_t *io) { // resume the read on other end of the connection tcp_connector_con_state_t *cstate = (tcp_connector_con_state_t *) (hevent_userdata(io)); @@ -124,7 +126,7 @@ static void onWriteComplete(hio_t * io) } } -static void onRecv(hio_t * io, shift_buffer_t *buf) +static void onRecv(hio_t *io, shift_buffer_t *buf) { tcp_connector_con_state_t *cstate = (tcp_connector_con_state_t *) (hevent_userdata(io)); if (cstate == NULL) @@ -414,8 +416,15 @@ tunnel_t *newTcpConnector(node_instance_context_t *instance_info) if (state->dest_addr_selected.status == kDvsConstant) { state->constant_dest_addr.address_type = getHostAddrType(state->dest_addr_selected.value_ptr); - socketContextDomainSetConstMem(&(state->constant_dest_addr), state->dest_addr_selected.value_ptr, - strlen(state->dest_addr_selected.value_ptr)); + if (state->constant_dest_addr.address_type == kSatDomainName) + { + socketContextDomainSetConstMem(&(state->constant_dest_addr), state->dest_addr_selected.value_ptr, + strlen(state->dest_addr_selected.value_ptr)); + } + else + { + sockaddr_set_ip(&(state->constant_dest_addr.address), state->dest_addr_selected.value_ptr); + } } state->dest_port_selected = diff --git a/tunnels/adapters/connector/udp/udp_connector.c b/tunnels/adapters/connector/udp/udp_connector.c index e662c46f..81abd2bc 100644 --- a/tunnels/adapters/connector/udp/udp_connector.c +++ b/tunnels/adapters/connector/udp/udp_connector.c @@ -217,9 +217,15 @@ tunnel_t *newUdpConnector(node_instance_context_t *instance_info) } if (state->dest_addr_selected.status == kDvsConstant) { - state->constant_dest_addr.address_type = getHostAddrType(state->dest_addr_selected.value_ptr); - socketContextDomainSetConstMem(&(state->constant_dest_addr), state->dest_addr_selected.value_ptr, - strlen(state->dest_addr_selected.value_ptr)); + if (state->constant_dest_addr.address_type == kSatDomainName) + { + socketContextDomainSetConstMem(&(state->constant_dest_addr), state->dest_addr_selected.value_ptr, + strlen(state->dest_addr_selected.value_ptr)); + } + else + { + sockaddr_set_ip(&(state->constant_dest_addr.address), state->dest_addr_selected.value_ptr); + } } state->dest_port_selected =