How to programmatically configure vpn connection in MAC?

after searching for a while, I found that the only best source available for setting up a vpn connection programmatically on mac is in

http://lists.apple.com/archives/Macnetworkprog/2011/May/msg00032.html

but I was hit by the 5th point when the coding that says kSCNetworkProtocolTypePPP and there is no such thing ...

Has anyone done this as shown in the link above or is there any other source available ...?

+6
source share
1 answer

but I was hit by the 5th point when the coding that says kSCNetworkProtocolTypePPP and there is no such thing ...

There is no need to extract the PPP protocol, you can apply the settings directly to the created interface. If you created such an interface:

interface = SCNetworkInterfaceCreateWithInterface(bottomInterface, kSCNetworkInterfaceTypePPP); 

you can directly apply PPP options using:

 SCNetworkInterfaceSetConfiguration(interface, myOptions) 

You need to apply a shared secret using

 SCNetworkInterfaceSetExtendedConfiguration(interface, CFSTR("IPSec"), myOptions) 

And if you want to enable β€œSend all traffic via VPN”, you need to apply these settings by first extracting the IPv4 protocol:

 SCNetworkProtocolRef protocol = SCNetworkServiceCopyProtocol(service, kSCNetworkProtocolTypeIPv4); SCNetworkProtocolSetConfiguration(protocol, myOptions) 

The source code mentioned in this answer was extracted from https://github.com/halo/macosvpn/blob/master/macosvpn/Classes/VPNController.m , where you can find it in its entirety.

+2
source

Source: https://habr.com/ru/post/894796/


All Articles