Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

你好,xcode 15,Socks5Tunnel.run 返回-1, 貌似tunnelFileDescriptor 无法获取到值,大神知道什么原因吗? #2

Open
RonadoLong opened this issue Dec 29, 2023 · 7 comments

Comments

@RonadoLong
Copy link

No description provided.

@EbrahimTahernejad
Copy link
Owner

EbrahimTahernejad commented Dec 30, 2023

are you sure you're calling it after setTunnelNetworkSettings is done?

@800sea
Copy link

800sea commented Jan 16, 2024

我这边也是xcode15。但是我报 -5

@Formerly
Copy link

同样报 5 static func getSettings() -> NEPacketTunnelNetworkSettings {
let settings = NEPacketTunnelNetworkSettings(tunnelRemoteAddress: "127.0.0.1")
settings.mtu = 8500
let ipv4Settings = NEIPv4Settings(addresses: ["198.18.0.20"], subnetMasks: ["255.255.255.0"])
ipv4Settings.includedRoutes = [NEIPv4Route.default()]
settings.ipv4Settings = ipv4Settings
let ipv6Settings = NEIPv6Settings(addresses: ["fd6e:a81b:704f:1211::1"], networkPrefixLengths: [64])
ipv6Settings.includedRoutes = [NEIPv6Route.default()]
settings.ipv6Settings = ipv6Settings
let dns = NEDNSSettings(servers: ["8.8.8.8"])
settings.dnsSettings = dns
settings.proxySettings = nil
return settings
}
WX20240123-114009@2x

@EbrahimTahernejad
Copy link
Owner

同样报 5 static func getSettings() -> NEPacketTunnelNetworkSettings {

    let settings = NEPacketTunnelNetworkSettings(tunnelRemoteAddress: "127.0.0.1")

    settings.mtu = 8500

    let ipv4Settings = NEIPv4Settings(addresses: ["198.18.0.20"], subnetMasks: ["255.255.255.0"])

    ipv4Settings.includedRoutes = [NEIPv4Route.default()]

    settings.ipv4Settings = ipv4Settings

    let ipv6Settings = NEIPv6Settings(addresses: ["fd6e:a81b:704f:1211::1"], networkPrefixLengths: [64])

    ipv6Settings.includedRoutes = [NEIPv6Route.default()]

    settings.ipv6Settings = ipv6Settings

    let dns = NEDNSSettings(servers: ["8.8.8.8"])

    settings.dnsSettings = dns

    settings.proxySettings = nil

    return settings

}

WX20240123-114009@2x

What's your tun2socks config.

@linchuIOS
Copy link

同样报 5 static func getSettings() -> NEPacketTunnelNetworkSettings {

    let settings = NEPacketTunnelNetworkSettings(tunnelRemoteAddress: "127.0.0.1")

    settings.mtu = 8500

    let ipv4Settings = NEIPv4Settings(addresses: ["198.18.0.20"], subnetMasks: ["255.255.255.0"])

    ipv4Settings.includedRoutes = [NEIPv4Route.default()]

    settings.ipv4Settings = ipv4Settings

    let ipv6Settings = NEIPv6Settings(addresses: ["fd6e:a81b:704f:1211::1"], networkPrefixLengths: [64])

    ipv6Settings.includedRoutes = [NEIPv6Route.default()]

    settings.ipv6Settings = ipv6Settings

    let dns = NEDNSSettings(servers: ["8.8.8.8"])

    settings.dnsSettings = dns

    settings.proxySettings = nil

    return settings

}

WX20240123-114009@2x

What's your tun2socks config.

""" tunnel: mtu: 9000 socks5: port: \(port) address: ::1 udp: 'udp' misc: task-stack-size: 20480 connect-timeout: 5000 read-write-timeout: 60000 log-file: stderr log-level: error limit-nofile: 65535 """
return 5 too.

@LondonX
Copy link

LondonX commented Mar 27, 2024

应该是新版本里Socks5Tunnel.run(withConfig: .string(content: tunConfigContent))的锅。
我这边改成了Socks5Tunnel.run(withConfig: .file(path: tunConfigFile))就行了。

tunConfigFiletunConfigContent来自以下方法

private func createTunnelConfig(socksPort: Int) -> String {
    return """
    tunnel:
      mtu: 9000

    socks5:
      port: \(socksPort)
      address: ::1
      udp: 'udp'

    misc:
      task-stack-size: 2048
      connect-timeout: 5000
      read-write-timeout: 60000
      log-file: stderr
      log-level: info
      limit-nofile: 65535
    """
}

private func createTunnelConfigFile(socksPort: Int) -> URL {
    let configContent = createTunnelConfig(socksPort: socksPort)
    if let documentsDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first {
        let fileURL = documentsDirectory.appendingPathComponent("tunnel_config.yaml")
        do {
            try configContent.write(to: fileURL, atomically: true, encoding: .utf8)
            return fileURL
        } catch {
            fatalError("Error writing to file: \(error)")
        }
    } else {
        fatalError("Error finding the documents directory.")
    }
}

@vitbulio
Copy link

I have the same problem. -5 code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants