grrrr apple did not email me despite this thread being marked as watched.
Post
Replies
Boosts
Views
Activity
That is beautiful code.
I should clarify myself -- I have no problem with that! I often tend to use very, very precise working to make sure that what I'm saying is not confused for something else.
Hm, maybe that wasn't. I changed it to subclass NETransparentProxyProvider, and my handleNewFlow method isn't being called at all. And all networking (even a ping I started beforehand) dies. Hm hm hm hm.
Ah! THAT WAS IT! In one of my test programs, I was using NETransparentProxyProvider, but in this one I wasn't. That explains why I got confused between the behaviour I saw, the documentation that I read, and what I expected!
You rock, my person.
As I said, "I was just hopeful someone had already saved me a bit of work." It's mostly gruntwork; any cleverness is in how you handle IPv4 and IPv6, and how you handle adding TCP, UDP, ICMP, etc., on top of those.
Or NO, the start seems to succeed, but then I get nothing else. Still investigating, but at least I have made progress! Maybe I should commit this.
YES. Of all things I forgot to set a team. Yay me! Now it says not connected, which means I get to try to start it, YOU ARE SO AWESOME.
Hm. Now I am getting error 9, which is validationFailed. So that means something is wrong with my signing, or one of the plists. That's an improvement from error 1, anyway. ;)
I never get a chance to call manager.connection.startVPNTunnel because the managers argument is empty ([]). But! I haven't tried NETransparentProxyManager, so I will try that!
I've submitted FB9454265. And am reusing this comment to say something useful!
No, I am trying this for macOS. However, it was the only example I could find. :)
Ok. I've got this code, and proxy still ends up as nil.
I'm still playing with it so hopefully I'll figure out on my own what I'm doing wrong.
import Foundation
class ConnectionHandler: NSObject, NSXPCListenerDelegate {
override init() {
super.init()
print("ConnectionHandler.init()")
}
func listener(_ listener: NSXPCListener, shouldAcceptNewConnection newConnection: NSXPCConnection) -> Bool {
print("ConnectionHandler.listener()")
newConnection.resume()
return true
}
}
let handler = ConnectionHandler()
let listener = NSXPCListener.anonymous()
let endpoint = listener.endpoint
listener.delegate = handler
listener.resume()
@objc protocol Hello {
func hello()
}
class HelloClass: NSObject, Hello {
override init() {
super.init()
}
func hello() {
print("In HelloClass.hello()")
}
}
let hello = HelloClass()
let connection = NSXPCConnection(listenerEndpoint: endpoint)
connection.exportedInterface = NSXPCInterface(with: Hello.self)
print("Connection = \(connection)")
connection.resume()
let proxy = connection.remoteObjectProxyWithErrorHandler({ error in
print("Got error \(error)")
}) as? Hello
print("Proxy = \(proxy)")
dispatchMain()