Skip to content

Commit

Permalink
HevSocks5Tunnel: Rename UDP to DNS.
Browse files Browse the repository at this point in the history
  • Loading branch information
heiher committed May 10, 2021
1 parent d4dc0b8 commit 1af73f4
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/hev-socks5-tunnel.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ static int event_fds[2];

static struct netif netif;
static struct tcp_pcb *tcp;
static struct udp_pcb *udp;
static struct udp_pcb *dns;

static HevTaskMutex mutex;
static HevTask *task_event;
Expand All @@ -58,7 +58,7 @@ static void lwip_io_task_entry (void *data);
static void lwip_timer_task_entry (void *data);
static void session_manager_task_entry (void *data);
static err_t tcp_accept_handler (void *arg, struct tcp_pcb *pcb, err_t err);
static void udp_recv_handler (void *arg, struct udp_pcb *pcb, struct pbuf *p,
static void dns_recv_handler (void *arg, struct udp_pcb *pcb, struct pbuf *p,
const ip_addr_t *addr, u16_t port);

int
Expand Down Expand Up @@ -143,7 +143,7 @@ hev_socks5_tunnel_init (int tunfd)
exit_free_task_event:
hev_task_unref (task_event);
exit_free_gateway:
udp_remove (udp);
udp_remove (dns);
tcp_close (tcp);
netif_remove (&netif);
exit_close_event:
Expand All @@ -165,7 +165,7 @@ hev_socks5_tunnel_fini (void)
hev_task_unref (task_lwip_io);
hev_task_unref (task_event);

udp_remove (udp);
udp_remove (dns);
tcp_close (tcp);
netif_remove (&netif);

Expand Down Expand Up @@ -385,24 +385,24 @@ gateway_init (void)

tcp_accept (tcp, tcp_accept_handler);

udp = udp_new ();
if (!udp) {
dns = udp_new ();
if (!dns) {
LOG_E ("Create UDP failed!");
goto exit_free_tcp;
}

udp_bind_netif (udp, &netif);
if (udp_bind (udp, IP_ANY_TYPE, port) != ERR_OK) {
udp_bind_netif (dns, &netif);
if (udp_bind (dns, IP_ANY_TYPE, port) != ERR_OK) {
LOG_E ("UDP bind failed!");
goto exit_free_udp;
goto exit_free_dns;
}

udp_recv (udp, udp_recv_handler, NULL);
udp_recv (dns, dns_recv_handler, NULL);

return 0;

exit_free_udp:
udp_remove (udp);
exit_free_dns:
udp_remove (dns);
exit_free_tcp:
tcp_close (tcp);
exit_free_netif:
Expand Down Expand Up @@ -582,7 +582,7 @@ tcp_accept_handler (void *arg, struct tcp_pcb *pcb, err_t err)
}

static void
udp_recv_handler (void *arg, struct udp_pcb *pcb, struct pbuf *p,
dns_recv_handler (void *arg, struct udp_pcb *pcb, struct pbuf *p,
const ip_addr_t *addr, u16_t port)
{
HevSocks5Session *session;
Expand Down

0 comments on commit 1af73f4

Please sign in to comment.