Giter VIP home page Giter VIP logo

Comments (8)

zhuhaow avatar zhuhaow commented on July 28, 2024

from nekit.

simpzan avatar simpzan commented on July 28, 2024

Thank you for the information.
Without TUNInterface and tun2socks, as I understand it, the data sent to tun will lost. It will be an negative side effects on iOS.
If tun2socks is not stable, I wonder if something like TCPDirectStack possible, which sends data directly to real nic, instead of go through tun2socks? This way the request sent to tun will not lost at least.

from nekit.

zhuhaow avatar zhuhaow commented on July 28, 2024

from nekit.

simpzan avatar simpzan commented on July 28, 2024

How to achieve that while http/https/sock5 requests are routed to proxy server?
I understand that If I set http/https proxy of the tun device, http requests are routed to http proxy server, but raw sockets are routed to tun.

from nekit.

zhuhaow avatar zhuhaow commented on July 28, 2024

Well, you have some fundamental misunderstandings here. HTTP proxy has absolutely nothing todo with route table.

from nekit.

simpzan avatar simpzan commented on July 28, 2024

I tried the following code on iOS 9.3.3.

if v4Settings.includedRoutes = [NEIPv4Route.default()] is set, safari requests are routed to http proxy server, but raw sockets are routed to tun.
if it is not set, then both types of requests goes directly to real nic.

I don't know how to achieve that http requests goes to http proxy server while raw socket requests goes directly to real nic on iOS. Please help me figure this out, thank you!

    public let httpProxyAddress = "127.0.0.1"
    public let httpProxyPort: UInt16 = 9090
    public let socksProxyPort: UInt16 = 9091

    func getTunnelSettings() -> NEPacketTunnelNetworkSettings {
        let settings = NEPacketTunnelNetworkSettings(tunnelRemoteAddress: "192.0.2.2")
        settings.mtu = 1600
        settings.dnsSettings = NEDNSSettings(servers: ["114.114.114.114"])
        let v4Settings = NEIPv4Settings(addresses:["192.0.2.1"], subnetMasks:["255.255.255.0"])
        v4Settings.includedRoutes = [NEIPv4Route.default()]
        v4Settings.excludedRoutes = [NEIPv4Route(destinationAddress:"114.114.114.114", subnetMask:"255.255.255.255")]
        settings.iPv4Settings = v4Settings
        settings.proxySettings = getProxySettings()
        return settings
    }
    func getProxySettings() -> NEProxySettings {
        let proxy = NEProxySettings()
        proxy.httpEnabled = true
        proxy.httpServer = NEProxyServer(address: httpProxyAddress, port: Int(httpProxyPort))
        proxy.httpsEnabled = true
        proxy.httpsServer = proxy.httpServer
        return proxy
    }

    override func startTunnel(options: [String : NSObject]? = nil, completionHandler: @escaping (Error?) -> Void) {
        NSLog("startTunnel \(options)")

        DDLog.add(DDTTYLogger.sharedInstance()) // TTY = Xcode console
        DDLog.add(DDASLLogger.sharedInstance()) // ASL = Apple System Logs
        ObserverFactory.currentFactory = DebugObserverFactory()

        self.startProxyServer()
        setTunnelNetworkSettings(getTunnelSettings()) { (error) in
            if error != nil {
                NSLog("\(#function) error:\(error)")
                return
            }
            NSLog("connected")
            self.readTun()
            completionHandler(nil)
        }
    }

    func readTun() {
        packetFlow.readPackets { (packets, protocols) in
            NSLog("read packets \(protocols)")
            self.readTun()
        }
    }

from nekit.

simpzan avatar simpzan commented on July 28, 2024

@zhuhaow Could you please help me on this? Thanks!

from nekit.

zhuhaow avatar zhuhaow commented on July 28, 2024

See Specht about how to disable packet processing.

from nekit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.