Open liudanking opened 8 years ago
I think the package itself works on macOS, as the code does not rely on OS-specific structs/interfaces. Thought I did't test.
The executable in bin directory only works on Linux. But it should be not hard to make it works on macOS. The only thing missing is a procedure that opens a tun device and returns a os.File object.
I will have a try, and give my feedback ASAP.
@liudanking gotun2socks works on macOS now. You can have a try. The problem only sets up the utun interface, you need to take care of routing yourself.
Could you give me a route command example for OSX? I am not familiar with OSX route
command. I have try some commands below.
As you see.
Generaly the process includes changing default route to the tun/tap device, and exclude IP addresses of remote servers to go through the original network device so that traffic forwarded from local SOCKS5 proxy to remote servers would not loop back.
Follow command work for me. But I do not know it is corrent or not?
# start shadowsocks server on vps with udp relay
# start shadowsocks client on your computer with udp relay
sudo ./gotun2socks --local-socks-addr 127.0.0.1:1080
sudo route add -net 0.0.0.0 10.0.0.1 -netmask 128.0.0.0
sudo route add -net 128.0.0.0 10.0.0.1 -netmask 128.0.0.0
orig_gw=$(netstat -nr | grep --color=never '^default' | grep -v 'utun' | sed 's/default *\([0-9\.]*\) .*/\1/' | head -1)
sudo route add my_ss_server $origin_gw
@FlowerWrong I think the commands you posted should be sufficient. The 2th and 3th commands change default route to the new utun device. The 4th command extracts previous default gateway. The 5th command specifies your ss_server to go through the previous gateway.
@yinghuocho @FlowerWrong
I'm sorry if this is a dumb question - but is sudo ip tuntap add dev tun0 mode tun user foobar
posted here only necessary on linux? Because there's no ip
command available on osx in the first place.
Or, will sudo gotun2socks --local-socks-addr 127.0.0.1:1080
create tun device automatically on both linux and osx?
see this comment
@FlowerWrong Is -netmask 128.0.0.0
a must? What difference will it make when I set it to 255.255.255.0
?
There is a
tun_linux.go
file inbin
directory, but missingtun_darwin.go
.