EbrahimTahernejad / Tun2SocksKit

Tun2Socks Solution for Apple Devices
77 stars 47 forks source link

Problem with iOS #14

Open Alireza1044 opened 4 months ago

Alireza1044 commented 4 months ago

Hi,

Thanks for the wrapper.

I'm trying to use this to forward iPhone's traffic to xray-core using NetworkExtension, however it seems the connection between tun2socks and xray is broken. Could you help me please?

Network settings:

let settings = NEPacketTunnelNetworkSettings(tunnelRemoteAddress: "254.1.1.1")
settings.mtu = 8500
let ipv4Settings = NEIPv4Settings(addresses: ["198.18.0.1"], subnetMasks: ["255.255.0.0"])
ipv4Settings.includedRoutes = [NEIPv4Route.default()]
settings.ipv4Settings = ipv4Settings
let dns = NEDNSSettings(servers: ["1.1.1.1", "8.8.8.8"])
settings.dnsSettings = dns
settings.proxySettings = nil

tun2socks config:

tunnel:
  mtu: 8500

socks5:
  port: 1081
  address: ::1
  udp: 'udp'

misc:
  task-stack-size: 20480
  connect-timeout: 5000
  read-write-timeout: 60000
  log-file: \(logFile.path(percentEncoded: false))
  log-level: debug
  limit-nofile: 65535

xray intbounds config:

"inbounds" : [
    {
      "port" : 1081,
      "protocol" : "socks",
      "settings" : {
        "auth" : "noauth",
        "udp" : true
      },
      "sniffing" : {
        "destOverride" : [
          "http",
          "tls",
          "quic",
          "fakedns"
        ],
        "enabled" : true,
        "routeOnly" : true
      },
      "tag" : "socks"
    }
  ],

Do you have any idea of where the problem is?

EbrahimTahernejad commented 4 months ago

I'm gonna need some logs brother

houmie commented 4 months ago

That was a problem with previous release 3.6.8, which was pointing to 3.6.9. (mismatch) The latest release 3.7.1 works correctly. Get the latest.

Alireza1044 commented 4 months ago

Thank you both for answering. Release 3.7.1 still has the same issue. Here is Tun2sockKit's logs: log.txt

I haven't configured xray-core's logger. I'll try to provide logs for that in a few days as well.

Alireza1044 commented 4 months ago

Hi,

I have some logs from xray-core. Looks like tun2sockskit tries to connect to xray-core's socks proxy, but is being rejected. Any ideas?

2024/07/16 06:00:32 [Debug] app/log: Logger started
2024/07/16 06:01:12 [Debug] app/proxyman/inbound: creating stream worker on 0.0.0.0:1081
2024/07/16 06:01:16 [Info] transport/internet/tcp: listening TCP on 0.0.0.0:1081
2024/07/16 06:01:22 [Info] transport/internet/udp: listening UDP on 0.0.0.0:1081
2024/07/16 06:01:22 [Warning] core: Xray 1.8.16 started
2024/07/16 06:02:09 [Info] [3249438730] app/proxyman/inbound: connection ends > proxy/socks: failed to read request > proxy/socks: insufficient header > EOF
2024/07/16 06:02:09 tcp:[::1]:54201 rejected  proxy/socks: insufficient header > EOF
2024/07/16 06:02:18 tcp:[::1]:54197 rejected  proxy/socks: insufficient header > EOF
2024/07/16 06:02:21 tcp:[::1]:54200 rejected  proxy/socks: insufficient header > EOF
2024/07/16 06:02:21 tcp:[::1]:54196 rejected  proxy/socks: insufficient header > EOF
2024/07/16 06:02:22 tcp:[::1]:54203 rejected  proxy/socks: insufficient header > EOF
2024/07/16 06:02:27 tcp:[::1]:54204 rejected  proxy/socks: insufficient header > EOF
jobsteven commented 2 months ago

This lib seems broken for iOS 13.+, probably related to Packet encapsulation, just can not directly read and write packets as other platforms. Still not working.

EbrahimTahernejad commented 2 months ago

This lib is intended for iOS15+ and I’m pretty sure it’s working, unless the latest version is broken, please test one version below this one as i’ve not yet been able to test the latest version.

On Mon, Sep 23, 2024 at 08:20 jobsteven @.***> wrote:

This lib seems broken for iOS 13.+, probably related to Packet encapsulation, just can not directly read and write packets as other platforms. Still not working.

— Reply to this email directly, view it on GitHub https://github.com/EbrahimTahernejad/Tun2SocksKit/issues/14#issuecomment-2367233088, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACDQKHBU6HWOLJCLIFQ7EU3ZX6MYHAVCNFSM6AAAAABKQABPK6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNRXGIZTGMBYHA . You are receiving this because you commented.Message ID: @.***>

jobsteven commented 2 months ago

This lib seems broken for iOS 13.+, probably related to Packet encapsulation, just can not directly read and write packets as other platforms. Still not working.

Thank your work and reply. In case of misleading for others, I add more info:

Xcode: 15.3 target: 13.4 lib version: 4.7.5

I have not tested it on 15.x, I will give a try. If it's possible to comment this mini-os requirement at README somewhere. I did find any dependency requirements.

houmie commented 2 months ago

Just to chime in here:

The minimum OS requirement isn't dictated by this project. It's a well-known fact that Xray-core requires iOS 15 as a minimum. However, I agree it's a bit difficult to find the dependency requirements in the Xray-core project documentation. The whole project is generally underdocumented.

I tested the latest Tun2SocksKit release yesterday on iOS, and it worked fine.

By the way, this is one of the best Tun2SocksKit libraries out there. A big thanks to Ebrahim for maintaining this project!