smartdev0126 / TrojanVPN-Tun2socks

5 stars 4 forks source link

vpn开启就立马断开了 #1

Closed maybeliu closed 1 year ago

maybeliu commented 1 year ago

这个trojan节点我使用shadowrocket是没有问题,这个不清楚是啥情况

maybeliu commented 1 year ago

//获取tunFd func getTunFd() ->Int32? { if #available(iOS 15, *) { var buf = [CChar](repeating: 0, count: Int(IFNAMSIZ)) let utunPrefix = "utun".utf8CString.dropLast() return (0...1024).first { (_ fd: Int32) -> Bool in var len = socklen_t(buf.count) return getsockopt(fd, 2, 2, &buf, &len) == 0 && buf.starts(with: utunPrefix) } } else { return self.packetFlow.value(forKeyPath: "socket.fileDescriptor") as? Int32 } }

替换

let tunFd = self?.packetFlow.value(forKeyPath: "socket.fileDescriptor") as! Int32

可以解决vpn开启失败的问题,只是还是无法建立连接,不知道这个demo作者有没有跑通过