NEAppProxyUDPFlow contains below property:
open var localEndpoint: NWEndpoint? { get }
Why is localEndpoint not available for NEAppProxyTCPFlow?
Is there a way to determine the source port of a flow of type NEAppProxyTCPFlow
within the following method of NETransparentProxyProvider
?
override func handleNewFlow(_ flow: NEAppProxyFlow) -> Bool {
If someone starts a TCP connection using a connect-by-name API, the system does its Happy Eyeballs thing. This means that the local interface, and hence the local IP address, aren’t known until the connection goes through.
Note For more background to this, read Understanding Also-Ran Connections.
Conceptually an app proxy sits above the TCP layer. Given that, your handle-new-flow method is called before the system has local endpoint info available.
I presume you’re building a transparent proxy here. If so, one option is to accept the flow and then wait for the first data transfer. By the time that happens, all the endpoint info will be set up.
There are a couple of downsides to this:
- As a transparent proxy, you can’t ‘unaccept’ a flow. If the local endpoint info reveals that the flow needs no special handling, you’ll still have to proxy it.
- The act of making a connection can ‘leak’ information. Unfortunately that a hard concept problem to resolve. I’ve seen in come up before, although that was in the context of a content filter.
Anyway, if you can share some info about what you plan to do with the local endpoint info, we can discuss your next steps.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"