Skip to content

Commit

Permalink
HevSocks5Session: Add support for udp listen on IPv6 only.
Browse files Browse the repository at this point in the history
  • Loading branch information
heiher committed Apr 9, 2024
1 parent 2990f81 commit 822bb1d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/hev-socks5-session.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,23 @@ hev_socks5_session_udp_bind (HevSocks5Server *self, int sock)
const char *saddr;
const char *sport;
socklen_t alen;
int ipv6_only;
int res;

LOG_D ("%p socks5 session udp bind", self);

alen = sizeof (struct sockaddr_in6);
saddr = hev_config_get_udp_listen_address ();
sport = hev_config_get_udp_listen_port ();
ipv6_only = hev_config_get_listen_ipv6_only ();

if (ipv6_only) {
int one = 1;

res = setsockopt (sock, IPPROTO_IPV6, IPV6_V6ONLY, &one, sizeof (one));
if (res < 0)
return -1;
}

if (saddr) {
res = hev_netaddr_resolve (&addr, saddr, NULL);
Expand Down

0 comments on commit 822bb1d

Please sign in to comment.