Advertisement
Guest User

Untitled

a guest
Feb 7th, 2017
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. // Initialize Manager
  2. NETunnelProviderManager *manager = [[NETunnelProviderManager alloc] init];
  3.  
  4. [manager loadFromPreferencesWithCompletionHandler:^(NSError *error) {
  5. if (error) {
  6. NSLog(@"Load Error: %@", error.description);
  7. } else {
  8.  
  9. // Create the protocol object
  10. NETunnelProviderProtocol *protocol = [[NETunnelProviderProtocol alloc] init]; // Create the protocol object
  11.  
  12. // Configure the protocol object
  13. protocol.providerBundleIdentifier = @"com.nfisc.testvpn.ptp"; // Bundle ID of tunnel provider
  14. protocol.providerConfiguration = @{}; // Currently blank, but will be used later
  15. protocol.serverAddress = @"0.0.0.0"; // Ommited for security reasons
  16. protocol.username = @"username"; // The username for the configuration
  17. protocol.identityDataPassword = @"password"; // The password for the configuration
  18. protocol.disconnectOnSleep = NO;
  19.  
  20. // Configure the manager with the protocol
  21. manager.protocolConfiguration = protocol;
  22. manager.enabled = true;
  23.  
  24. [manager saveToPreferencesWithCompletionHandler:^(NSError *error) {
  25. if (error) {
  26. NSLog(@"Save Error: %@", error.description);
  27. } else {
  28. if ([[manager connection] status] != NEVPNStatusConnected) {
  29. NSLog(@"Starting VPN");
  30. [self start:manager];
  31. } else {
  32. NSLog(@"VPN Already Connected");
  33. [_statusLabel setText:@"Connected"];
  34. [_statusLabel setTextColor:[UIColor greenColor]];
  35. }
  36.  
  37. }
  38. }];
  39. }
  40. }];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement