xjasonlyu / tun2socks

tun2socks - powered by gVisor TCP/IP stack
https://github.com/xjasonlyu/tun2socks/wiki
GNU General Public License v3.0
2.85k stars 404 forks source link

feature: device add support unixsocket use fd #286

Closed lflish closed 8 months ago

lflish commented 10 months ago

This is a great project. For ease of use, I gave it a little detail. Using FD is compatible with all Linux communication, and I optimized it to use Unix sockets directly,It has no effect on the original method

device: unix:///tmp/unix_socket

xjasonlyu commented 10 months ago

Hi! Thanks for your PR.

Unix socket can be a great source input for tun2socks project. Can we implement it in the core/device pkg directly?

lflish commented 10 months ago

你好 新改的代码放到了core/device目录了,但是对设备解析的函数parseDevice中, url.Parse(s)函数对unix:///tmp/unix.sock这种格式解析有问题,所以把这里也重新写了下。

    devInfo := strings.Split(s, "://")
    if len(devInfo) < 2 {
        return nil, fmt.Errorf("unsupported device: %s", s)
    }
    driver, name := devInfo[0], devInfo[1]
xjasonlyu commented 10 months ago

There is actually no issue with this parsing process, you don’t need u.Host, just use u.Path directly.

lflish commented 10 months ago

多谢指点,这块代码回滚重新提交了