heiher / hev-socks5-server

A high-performance socks5 server for Unix (Linux/Android/BSD/macOS)
MIT License
185 stars 33 forks source link

Server only listens on IPV6 #49

Closed joshbaptiste closed 1 month ago

joshbaptiste commented 1 month ago

I want the server to listen on 127.0.0.1 port 1081 IPv4 but it only listens on IPv6

josh@wg:~/etc$ lsb_release -a
Description:    Debian GNU/Linux 12 (bookworm)

josh@wg:~/etc$ cat hev.yml
main:
  # Worker threads
  workers: 4
  # Listen port
  port: 1081
  # Listen address (ipv4|ipv6)
  listen-address: '127.0.0.1'
  # UDP listen port
  udp-port: 1080
  # UDP listen address (ipv4|ipv6)
# udp-listen-address: '::1'
  # Listen ipv6 only
  listen-ipv6-only: false
  # Bind source address (ipv4|ipv6)
  bind-address: '127.0.0.1'
  # Domain address type (ipv4|ipv6|unspec)
  domain-address-type: 'ipv4'

josh@wg:~/etc$ hev-socks5-server-linux-x86_64 hev.yml &
[3] 2413

josh@wg:~/etc$ lsof -p 2413 -a -i -P -n
COMMAND    PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
hev-socks 2413 junya   10u  IPv6  24550      0t0  TCP 127.0.0.1:1081 (LISTEN)
hev-socks 2413 junya   15u  IPv6  24553      0t0  TCP 127.0.0.1:1081 (LISTEN)
hev-socks 2413 junya   20u  IPv6  24556      0t0  TCP 127.0.0.1:1081 (LISTEN)
hev-socks 2413 junya   25u  IPv6  24559      0t0  TCP 127.0.0.1:1081 (LISTEN)

Why does it only listen on IPv6?

heiher commented 1 month ago

Yeah. The server only creates AF_INET6 sockets and the IPv4 mapping addresses are available.

joshbaptiste commented 1 month ago

ah understood.. but fails to connect with curl .. something i'm missing in the config?

josh@wg:~/etc$ curl --socks5-hostname 127.0.0.1:1081  http://ipinfo.io
[2024-05-15 11:57:30] [E] 0x7fcf64d39c30 socks5 server connect
curl: (97) Can't complete SOCKS5 connection to ipinfo.io. (4)
heiher commented 1 month ago

Don't set the bind address if you don't know what it does.

joshbaptiste commented 1 month ago

ah great.. set back to default.. works now