klzgrad / naiveproxy

Make a fortune quietly
BSD 3-Clause "New" or "Revised" License
6.31k stars 868 forks source link

Failed to get original destination address #614

Closed wsk2007 closed 4 months ago

wsk2007 commented 4 months ago

I am running Naiveproxy on an ARM device in redir mode. I suppose it should connect but I keep getting the following error: [0122/051629.384872:INFO:naive_proxy_bin.cc(484)] Proxying via [REDACTED] [0122/051629.475896:INFO:naive_proxy_bin.cc(686)] Listening on redir://127.0.0.1:10803 [0122/051632.658818:ERROR:naive_connection.cc(259)] Failed to get original destination address [0122/051632.658930:INFO:naive_proxy.cc(197)] Connection 1 closed: ERR_ADDRESS_INVALID [0122/051633.298616:ERROR:naive_connection.cc(259)] Failed to get original destination address [0122/051633.298675:INFO:naive_proxy.cc(197)] Connection 2 closed: ERR_ADDRESS_INVALID [0122/051633.755136:ERROR:naive_connection.cc(259)] Failed to get original destination address [0122/051633.755195:INFO:naive_proxy.cc(197)] Connection 3 closed: ERR_ADDRESS_INVALID [0122/051634.131287:ERROR:naive_connection.cc(259)] Failed to get original destination address [0122/051634.131346:INFO:naive_proxy.cc(197)] Connection 4 closed: ERR_ADDRESS_INVALID I read the source code and I think it should be caused by the call getsockopt() failed, but I don't know why and how to fix it. Waiting for your help, thank you.

Naiveproxy version: naive 120.0.6099.43, from the linux-arm64 one in the release Distro: Debian bookworm Device information: Orangepi Zero 3, ARM64, SoC: Allwinner H618

klzgrad commented 4 months ago

strace ./naive

What was the errno of the getsockopt syscall?

wsk2007 commented 4 months ago

errno is ENOPROTOOPT (Protocol not available) Full strace : https://fars.ee/QzRX

klzgrad commented 4 months ago
    /* We only do TCP and SCTP at the moment: is there a better way? */
    if (tuple.dst.protonum != IPPROTO_TCP &&
        tuple.dst.protonum != IPPROTO_SCTP)
        return -ENOPROTOOPT;

What is being redirected to 127.0.0.1:10803?

wsk2007 commented 4 months ago

It's socks5 packages. I believe they are TCP and should be supported. PS: I am using naiveproxy as a tunnel, so I send socks5 packages to naiveproxy and it will connect to a socks5 server at remote machine. This architecture works quite well on my other devices.

wsk2007 commented 4 months ago

Here is also a strace of a working instance of naiveproxy on my x86-64 nixos device for your reference: https://fars.ee/zfL5

klzgrad commented 4 months ago

iptables REDIRECT rules are not set up

wsk2007 commented 4 months ago

Yes, I see. Naiveproxy works well with iptables REDIRECT but not with my strange usage which is not what redir is designed for. I am sure that this is my problem. I apologize for my bother and my unclear explanation. Anyway, I have found a way to fix it. Thank you very much for your support and patience.