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

[Bug] Maybe open_others.go need use 4 as default offset. #271

Closed myloft closed 1 year ago

myloft commented 1 year ago

Verify steps

Version

v2.5.1

What OS are you seeing the problem on?

No response

Description

I try to use tun2socks on ios via fd. Tun2socks will use open_others.go to open fd. It not works. The default offset is zero. But packet read from tun fd have TUN_PI header. I change offset to 4. It works.

I think ios is the vast majority of non-linux scenarios where iobased is used. Maybe we need set default to 4 or giving a args.

CLI or Config

No response

Logs

No response

How to Reproduce

No response

xjasonlyu commented 1 year ago

Is TUN_PI header configurable on iOS?

I'm not familiar with ios, but I agree that we may need to set offsets respectively for different OS.

myloft commented 1 year ago

https://stackoverflow.com/questions/69260852/ios-network-extension-packet-parsing/69487795#69487795 @xjasonlyu Yes, It has 4 bytes prefix and can not configurable.

xjasonlyu commented 1 year ago

Okay, maybe we should add a 4 bytes offset for fd open function. Would you like to open a PR?

myloft commented 1 year ago

OK, i will open a PR.