Thank you for the help.
I implemented transparent proxy but I'm experiencing some issues.
I'm getting new flows in handleNewFlow(_ flow: NEAppProxyFlow) callback, but I completely loose network connection every time I enable the proxy. Here is my NEAppProxyProvider implementation:
override func startProxy(options: [String : Any]? = nil, completionHandler: @escaping (Error?) -> Void) {
var includedRules = [NENetworkRule]()
os_log("I have proxy start")
let remoteNetwork = NWHostEndpoint(hostname: "8.8.8.8", port: "0")
let networkRule = NENetworkRule(remoteNetwork: remoteNetwork,
remotePrefix: 0,
localNetwork: nil,
localPrefix: 0,
protocol: .any,
direction: .outbound)
includedRules.append(networkRule)
let settings = NETransparentProxyNetworkSettings(tunnelRemoteAddress: "127.0.0.1")
settings.includedNetworkRules = includedRules
setTunnelNetworkSettings(settings) { error in
if error != nil {
os_log("I have proxy start error")
} else {
os_log("I have proxy start success")
}
completionHandler(error)
}
}
override func handleNewFlow(_ flow: NEAppProxyFlow) -> Bool {
os_log("I have proxy flow")
flow.open(withLocalEndpoint: nil) { error in
if error != nil {
os_log("I have proxy open error")
} else {
//flow.networkInterface = nw_interface_create_with_name("en0")
os_log("I have proxy open success")
}
flow.closeReadWithError(error)
flow.closeWriteWithError(error)
}
return true
}
Do you maybe have some transparent proxy code samples so I could see what I'm doing wrong?