This response assumes you’re using TCP to connect to your VPN server. If not — if, say, you’re using UDP — things get more complex.
Can I know if the user is connected by WIFI or by ethernet (wired/unwired)?
With TCP you can get the source address from the TCP connection, map that to an interface, and then look at the characteristics of the interface.
Is it possible that he is connected by both of them?
Certainly a Mac can have both Ethernet and Wi-Fi interfaces up at the same time. When your provider connects to a server, the connection will use the appropriate interface based on that destination address (if the server is on the global Internet, it will use the default interface).
(A bonus question would be how can I tell if the connection type changes while using the VPN)
The best approach here depends on the API you’re using for the connection. If you’re using NWTCPConnection you typically watch for changes to the
hasBetterPath
property.
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"