-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNetworkExtension.framework.h
More file actions
5971 lines (5060 loc) · 276 KB
/
NetworkExtension.framework.h
File metadata and controls
5971 lines (5060 loc) · 276 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ========== NetworkExtension.framework/Headers/NWEndpoint.h
//
// NWEndpoint
// Network
//
// Copyright (c) 2014-2016, 2018 Apple Inc. All rights reserved.
//
#ifndef __NE_TAPI__
#ifndef __NE_INDIRECT__
#error "Please import the NetworkExtension module instead of this file directly."
#endif // __NE_INDIRECT__
#ifndef __NWEndpoint_h_
#define __NWEndpoint_h_
NS_ASSUME_NONNULL_BEGIN
/*!
* @interface NWEndpoint
* @discussion NWEndpoint is a generic class to represent network endpoints, such as a port on a remote server.
*/
API_AVAILABLE(macos(10.11), ios(9.0)) API_UNAVAILABLE(watchos, tvos)
@interface NWEndpoint : NSObject <NSSecureCoding, NSCopying>
@end
NS_ASSUME_NONNULL_END
#endif // __NWEndpoint_h_
#endif // __NE_TAPI__
// ========== NetworkExtension.framework/Headers/NEVPNProtocolIPSec.h
/*
* Copyright (c) 2013-2015, 2018 Apple Inc.
* All rights reserved.
*/
#ifndef __NE_INDIRECT__
#error "Please import the NetworkExtension module instead of this file directly."
#endif
#import <NetworkExtension/NEVPNProtocol.h>
NS_ASSUME_NONNULL_BEGIN
/*!
* @typedef NEVPNIKEAuthenticationMethod
* @abstract Internet Key Exchange (IKE) authentication methods used to authenticate with the IPSec server.
*/
typedef NS_ENUM(NSInteger, NEVPNIKEAuthenticationMethod) {
/*! @const NEVPNIKEAuthenticationMethodNone Do not authenticate with the IPSec server */
NEVPNIKEAuthenticationMethodNone = 0,
/*! @const NEVPNIKEAuthenticationMethodCertificate Use a certificate and private key as the authentication credential */
NEVPNIKEAuthenticationMethodCertificate = 1,
/*! @const NEVPNIKEAuthenticationMethodSharedSecret Use a shared secret as the authentication credential */
NEVPNIKEAuthenticationMethodSharedSecret = 2,
} API_AVAILABLE(macos(10.11), ios(8.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @interface NEVPNProtocolIPSec
* @discussion The NEVPNProtocolIPSec class declares the programmatic interface of an object that manages the IPSec-specific portion of a VPN configuration.
*
* Instances of this class use IKE version 1 for key negotiation.
*/
API_AVAILABLE(macos(10.11), ios(8.0)) API_UNAVAILABLE(watchos, tvos)
@interface NEVPNProtocolIPSec : NEVPNProtocol
/*!
* @property authenticationMethod
* @discussion The method used to authenticate with the IPSec server. Note that if this property is set to NEVPNIKEAuthenticationMethodNone, extended authentication will still be negotiated if useExtendedAuthentication is set to YES.
*/
@property NEVPNIKEAuthenticationMethod authenticationMethod API_AVAILABLE(macos(10.11), ios(8.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @property useExtendedAuthentication
* @discussion A flag indicating if extended authentication will be negotiated. This authentication is in addition to the IKE authentication used to authenticate the endpoints of the IKE session.
* For IKE version 1, when this flag is set X-Auth authentication will be negotiated as part of the IKE session, using the username and password properties as the credential.
* For IKE version 2, when this flag is set EAP authentication will be negotiated as part of the IKE session, using the username, password, and/or identity properties as the credential depending on which EAP method the server requires.
*/
@property BOOL useExtendedAuthentication API_AVAILABLE(macos(10.11), ios(8.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @property sharedSecretReference
* @discussion A persistent reference to a keychain item of class kSecClassGenericPassword containing the IKE shared secret.
*/
@property (copy, nullable) NSData *sharedSecretReference API_AVAILABLE(macos(10.11), ios(8.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @property localIdentifier
* @discussion A string identifying the local IPSec endpoint for authentication purposes.
*/
@property (copy, nullable) NSString *localIdentifier API_AVAILABLE(macos(10.11), ios(8.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @property remoteIdentifier
* @discussion A string identifying the remote IPSec endpoint for authentication purposes.
*/
@property (copy, nullable) NSString *remoteIdentifier API_AVAILABLE(macos(10.11), ios(8.0)) API_UNAVAILABLE(watchos, tvos);
@end
NS_ASSUME_NONNULL_END
// ========== NetworkExtension.framework/Headers/NEFilterSettings.h
/*
* Copyright (c) 2019 Apple Inc.
* All rights reserved.
*/
#ifndef __NE_INDIRECT__
#error "Please import the NetworkExtension module instead of this file directly."
#endif
#import <NetworkExtension/NEFilterDataProvider.h>
NS_ASSUME_NONNULL_BEGIN
@class NEFilterRule;
/*!
* @interface NEFilterSettings
* @discussion The NEFilterSettings class declares the programmatic interface for an object that contains filter settings.
*
* NEFilterSettings is used by NEFilterDataProviders to communicate the desired settings for the filter to the framework. The framework takes care of applying the contained settings to the system.
*/
API_AVAILABLE(macos(10.15)) API_UNAVAILABLE(ios, watchos, tvos)
@interface NEFilterSettings : NSObject <NSSecureCoding,NSCopying>
/*!
* @method initWithRules:defaultAction:
* @discussion Initialize a newly-allocated NEFilterSettings object with a set of filtering rules and a default filter action to takke if none
* of the rules match.
* @param rules An NSArray containing an ordered list of NEFilterRule objects. The maximum number of rules that this array can contain is 1000.
* @param defaultAction The NEFilterAction to take for flows of network data that do not match any of the specified rules. The default defaultAction is
* NEFilterActionFilterData. If defaultAction is NEFilterActionAllow or NEFilterActionDrop, then the rules array must contain at least one NEFilterRule.
* @return the newly-initialized NEFilterSettings object.
*/
- (instancetype)initWithRules:(NSArray<NEFilterRule *> *)rules defaultAction:(NEFilterAction)defaultAction API_AVAILABLE(macos(10.15)) API_UNAVAILABLE(ios, watchos, tvos);
/*!
* @property rules
* @discussion An NSArray containing an ordered list of NEFilterRuleObjects. After the NEFilterSettings are applied to the system,
* each network flow is matched against these rules in order, and the NEFilterAction of the first rule that matches is taken:
* NEFilterActionAllow: Allow the flow of data to proceed on its journey through the networking stack without consulting this provider.
* NEFilterActionDrop: Drop the flow without consulting this provider.
* NEFilterActionFilterData: Call this provider's handleNewFlow: method with the flow.
*/
@property (readonly, copy) NSArray<NEFilterRule *> *rules API_AVAILABLE(macos(10.15)) API_UNAVAILABLE(ios, watchos, tvos);
/*!
* @property defaultAction
* @discussion An NEFilterAction containing the default action to take for flows of network data that do not match any of the specified rules.
*/
@property (readonly) NEFilterAction defaultAction API_AVAILABLE(macos(10.15)) API_UNAVAILABLE(ios, watchos, tvos);
@end
NS_ASSUME_NONNULL_END
// ========== NetworkExtension.framework/Headers/NEDNSProxyProvider.h
/*
* Copyright (c) 2017-2018 Apple Inc.
* All rights reserved.
*/
#ifndef __NE_INDIRECT__
#error "Please import the NetworkExtension module instead of this file directly."
#endif
#import <NetworkExtension/NEProvider.h>
NS_ASSUME_NONNULL_BEGIN
@class NEAppProxyFlow;
@class NEDNSSettings;
/*!
* @file NEDNSProxyProvider.h
* @discussion This file declares the NEDNSProxyProvider API. The NEDNSProxyProvider is used to implement custom DNS proxy solutions.
*/
/*!
* @interface NEDNSProxyProvider
* @discussion The NEDNSProxyProvider class declares the programmatic interface for an object that implements the client side of a custom DNS proxy solution.
*
* NEDNSProxyProvider is part of NetworkExtension.framework
*/
API_AVAILABLE(macos(10.15), ios(11.0)) API_UNAVAILABLE(watchos, tvos)
@interface NEDNSProxyProvider : NEProvider
/*!
* @method startProxyWithOptions:completionHandler:
* @discussion This function is called by the framework when a new proxy instance is being created. Subclasses must override this method to perform whatever steps are necessary to ready the proxy for handling flows of network data.
* @param options A dictionary containing keys and values passed by the provider's containing app. If the containing app did not start the proxy then this parameter will be nil.
* @param completionHandler A block that must be called when the process of starting the proxy is complete. If the proxy cannot be started then the subclass' implementation of this method must pass a non-nil NSError object to this block. A value of nil passed to the completion handler indicates that the proxy was successfully started.
*/
- (void)startProxyWithOptions:(nullable NSDictionary<NSString *,id> *)options completionHandler:(void (^)(NSError * __nullable error))completionHandler API_AVAILABLE(macos(10.15), ios(11.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @method stopProxyWithReason:completionHandler:
* @discussion This function is called by the framework when the proxy is being stopped. Subclasses must override this method to perform whatever steps are necessary to stop the proxy.
* @param reason An NEProviderStopReason indicating why the proxy is being stopped.
* @param completionHandler A block that must be called when the proxy is completely stopped.
*/
- (void)stopProxyWithReason:(NEProviderStopReason)reason completionHandler:(void (^)(void))completionHandler API_AVAILABLE(macos(10.15), ios(11.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @method cancelProxyWithError:
* @discussion This function is called by proxy provider implementations to stop the proxy when a network error is encountered that renders the proxy no longer viable. Subclasses should not override this method.
* @param error An NSError object containing details about the error that the proxy provider implementation encountered.
*/
- (void)cancelProxyWithError:(nullable NSError *)error API_AVAILABLE(macos(10.15), ios(11.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @method handleNewFlow:
* @discussion This function is called by the framework to deliver a new network data flow to the proxy provider implementation. Subclasses must override this method to perform whatever steps are necessary to ready the proxy to receive data from the flow. The proxy provider implementation indicates that the proxy is ready to handle flow data by calling -[NEAppProxyFlow openWithLocalEndpoint:completionHandler:] on the flow. If the proxy implementation decides to not handle the flow and instead terminate it, the subclass implementation of this method should return NO. If the proxy implementation decides to handle the flow, the subclass implementation of this method should return YES. In this case the proxy implementation is responsible for retaining the NEAppProxyFlow object.
* @param flow The new flow
* @return YES if the proxy implementation has retained the flow and intends to handle the flow data. NO if the proxy implementation has not retained the flow and will not handle the flow data. In this case the flow is terminated.
*/
- (BOOL)handleNewFlow:(NEAppProxyFlow *)flow API_AVAILABLE(macos(10.15), ios(11.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @method handleNewUDPFlow:initialRemoteEndpoint:
* @discussion This function is called by the framework to deliver a new UDP data flow to the proxy provider implementation. Subclasses can override this method to perform whatever steps are necessary to ready the proxy to receive
* data from the flow. The proxy provider implementation indicates that the proxy is ready to handle flow data by calling -[NEAppProxyFlow openWithLocalEndpoint:completionHandler:] on the flow. If the proxy implementation decides
* to not handle the flow and instead terminate it, the subclass implementation of this method should return NO. If the proxy implementation decides to handle the flow, the subclass implementation of this method should return YES.
* In this case the proxy implementation is responsible for retaining the NEAppProxyUDPFlow object.
* The default implementation of this method calls -[NEAppProxyProvider handleNewFlow:] and returns its result.
* @param flow The new UDP flow
* @param remoteEndpoint The initial remote endpoint provided by the proxied app when the flow was opened.
* @return YES if the proxy implementation has retained the flow and intends to handle the flow data. NO if the proxy implementation has not retained the flow and will not handle the flow data. In this case the flow is terminated.
*/
- (BOOL)handleNewUDPFlow:(NEAppProxyUDPFlow *)flow initialRemoteEndpoint:(NWEndpoint *)remoteEndpoint API_AVAILABLE(macos(10.15), ios(13.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @property systemDNSSettings
* @discussion The current system DNS settings. Use KVO to watch for changes.
*/
@property (readonly, nullable) NSArray<NEDNSSettings *> *systemDNSSettings API_AVAILABLE(macos(10.15), ios(11.0)) API_UNAVAILABLE(watchos, tvos);
@end
NS_ASSUME_NONNULL_END
// ========== NetworkExtension.framework/Headers/NETunnelProviderSession.h
/*
* Copyright (c) 2015, 2018 Apple Inc.
* All rights reserved.
*/
#ifndef __NE_INDIRECT__
#error "Please import the NetworkExtension module instead of this file directly."
#endif
#import <NetworkExtension/NEVPNConnection.h>
NS_ASSUME_NONNULL_BEGIN
/*!
* @file NETunnelProviderSession.h
* @discussion This file declares the NETunnelProviderSession API. The NETunnelProviderSession API is used to control network tunnel services provided by NETunnelProvider implementations.
*
* This API is part of NetworkExtension.framework.
*/
API_AVAILABLE(macos(10.11), ios(9.0)) API_UNAVAILABLE(watchos, tvos)
@interface NETunnelProviderSession : NEVPNConnection
/*!
* @method startTunnelWithOptions:andReturnError:
* @discussion This function is used to start the tunnel using the configuration associated with this connection object. The tunnel connection process is started and this function returns immediately.
* @param options A dictionary that will be passed as-is to the tunnel provider during the process of starting the tunnel.
* @param error If the tunnel was started successfully, this parameter is set to nil. Otherwise this parameter is set to the error that occurred. Possible errors include:
* 1. NEVPNErrorConfigurationInvalid
* 2. NEVPNErrorConfigurationDisabled
* @return YES if the tunnel was started successfully, NO if an error occurred.
*/
- (BOOL)startTunnelWithOptions:(nullable NSDictionary<NSString *,id> *)options andReturnError:(NSError **)error API_AVAILABLE(macos(10.11), ios(9.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @method stopTunnel
* @discussion This function is used to stop the tunnel. The tunnel disconnect process is started and this function returns immediately.
*/
- (void)stopTunnel API_AVAILABLE(macos(10.11), ios(9.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @method sendProviderMessage:responseHandler:
* @discussion This function sends a message to the NETunnelProvider and provides a way to receive a response.
* @param messageData An NSData object containing the message to be sent.
* @param error If the message was sent successfully, this parameter is set to nil. Otherwise this parameter is set to the error that occurred. Possible errors include:
* 1. NEVPNErrorConfigurationInvalid
* 2. NEVPNErrorConfigurationDisabled
* @param responseHandler A block that handles the response. Can be set to nil if no response is expected.
* @return YES if the message was sent successfully, NO if an error occurred.
*/
- (BOOL)sendProviderMessage:(NSData *)messageData returnError:(NSError **)error responseHandler:(nullable void (^)( NSData * __nullable responseData))responseHandler API_AVAILABLE(macos(10.11), ios(9.0)) API_UNAVAILABLE(watchos, tvos);
@end
NS_ASSUME_NONNULL_END
// ========== NetworkExtension.framework/Headers/NEVPNManager.h
/*
* Copyright (c) 2013-2015, 2018 Apple Inc.
* All rights reserved.
*/
#ifndef __NE_INDIRECT__
#error "Please import the NetworkExtension module instead of this file directly."
#endif
/*!
* @file NEVPNManager.h
* @discussion This file declares the NEVPNManager API. The NEVPNManager API is used to configure and control Virtual Private Network (VPN) tunnels.
*
* This API is part of NetworkExtension.framework.
*
* This API is used to create VPN configurations. The VPN tunnel can be started manually, or On Demand rules can be created that will start the VPN tunnel automatically when specific network events occur.
*/
#if TARGET_OS_OSX
#import <Security/Security.h>
#endif
NS_ASSUME_NONNULL_BEGIN
#if defined(__cplusplus)
#define NEVPN_EXPORT extern "C"
#else
#define NEVPN_EXPORT extern
#endif
@class NEVPNConnection;
@class NEVPNProtocol;
@class NEOnDemandRule;
/*!
* @typedef NEVPNError
* @abstract VPN error codes
*/
typedef NS_ENUM(NSInteger, NEVPNError) {
/*! @const NEVPNErrorConfigurationInvalid The VPN configuration is invalid */
NEVPNErrorConfigurationInvalid = 1,
/*! @const NEVPNErrorConfigurationDisabled The VPN configuration is not enabled. */
NEVPNErrorConfigurationDisabled = 2,
/*! @const NEVPNErrorConnectionFailed The connection to the VPN server failed. */
NEVPNErrorConnectionFailed = 3,
/*! @const NEVPNErrorConfigurationStale The VPN configuration is stale and needs to be loaded. */
NEVPNErrorConfigurationStale = 4,
/*! @const NEVPNErrorConfigurationReadWriteFailed The VPN configuration cannot be read from or written to disk. */
NEVPNErrorConfigurationReadWriteFailed = 5,
/*! @const NEVPNErrorConfigurationUnknown An unknown configuration error occurred. */
NEVPNErrorConfigurationUnknown = 6,
} API_AVAILABLE(macos(10.11), ios(8.0)) API_UNAVAILABLE(watchos, tvos);
/*! @const NEVPNErrorDomain The VPN error domain */
NEVPN_EXPORT NSString * const NEVPNErrorDomain API_AVAILABLE(macos(10.11), ios(8.0)) API_UNAVAILABLE(watchos, tvos);
/*! @const NEVPNConfigurationChangeNotification Name of the NSNotification that is posted when the VPN configuration changes. */
NEVPN_EXPORT NSString * const NEVPNConfigurationChangeNotification API_AVAILABLE(macos(10.11), ios(8.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @interface NEVPNManager
* @discussion The NEVPNManager class declares the programmatic interface for an object that manages Virtual Private Network (VPN) configurations.
*
* NEVPNManager declares methods and properties for configuring and controlling a VPN.
*
* Instances of this class are thread safe.
*/
API_AVAILABLE(macos(10.11), ios(8.0)) API_UNAVAILABLE(watchos, tvos)
@interface NEVPNManager : NSObject
/*!
* @method sharedManager
* @return The singleton NEVPNManager object for the calling process.
*/
+ (NEVPNManager *)sharedManager API_AVAILABLE(macos(10.11), ios(8.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @method loadFromPreferencesWithCompletionHandler:
* @discussion This function loads the current VPN configuration from the caller's VPN preferences.
* @param completionHandler A block that will be called on the main thread when the load operation is completed. The NSError passed to this block will be nil if the load operation succeeded, non-nil otherwise.
*/
- (void)loadFromPreferencesWithCompletionHandler:(void (^)(NSError * __nullable error))completionHandler API_AVAILABLE(macos(10.11), ios(8.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @method removeFromPreferencesWithCompletionHandler:
* @discussion This function removes the VPN configuration from the caller's VPN preferences. If the VPN is enabled, has VPN On Demand enabled, and has VPN On Demand rules, the VPN is disabled and the VPN On Demand rules are de-activated.
* @param completionHandler A block that will be called on the main thread when the remove operation is completed. The NSError passed to this block will be nil if the remove operation succeeded, non-nil otherwise.
*/
- (void)removeFromPreferencesWithCompletionHandler:(nullable void (^)(NSError * __nullable error))completionHandler API_AVAILABLE(macos(10.11), ios(8.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @method saveToPreferencesWithCompletionHandler:
* @discussion This function saves the VPN configuration in the caller's VPN preferences. If the VPN is enabled, has VPN On Demand enabled, and has VPN On Demand rules, the VPN On Demand rules are activated.
*
* @param completionHandler A block that will be called on the main thread when the save operation is completed. The NSError passed to this block will be nil if the save operation succeeded, non-nil otherwise.
*/
- (void)saveToPreferencesWithCompletionHandler:(nullable void (^)(NSError * __nullable error))completionHandler API_AVAILABLE(macos(10.11), ios(8.0)) API_UNAVAILABLE(watchos, tvos);
#if TARGET_OS_OSX
/*!
* @method setAuthorization:
* @discussion This function sets an authorization object that can be used to obtain the authorization rights necessary to modify the system VPN configuration.
* @param authorization The AuthorizationRef to use to obtain rights.
*/
- (void)setAuthorization:(AuthorizationRef)authorization API_AVAILABLE(macos(10.11)) API_UNAVAILABLE(ios, watchos, tvos);
#endif
/*!
* @property onDemandRules
* @discussion An array of NEOnDemandRule objects.
*/
@property (copy, nullable) NSArray<NEOnDemandRule *> *onDemandRules API_AVAILABLE(macos(10.11), ios(8.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @property onDemandEnabled
* @discussion Toggles VPN On Demand.
*/
@property (getter=isOnDemandEnabled) BOOL onDemandEnabled API_AVAILABLE(macos(10.11), ios(8.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @property localizedDescription
* @discussion A string containing a description of the VPN.
*/
@property (copy, nullable) NSString *localizedDescription API_AVAILABLE(macos(10.11), ios(8.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @property protocol
* @discussion An NEVPNProtocol object containing the protocol-specific portion of the VPN configuration.
*/
@property (strong, nullable) NEVPNProtocol *protocol API_DEPRECATED_WITH_REPLACEMENT("Use protocolConfiguration instead", macos(10.11, 10.11), ios(8.0, 9.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @property protocolConfiguration
* @discussion An NEVPNProtocol object containing the protocol-specific portion of the VPN configuration.
*/
@property (strong, nullable) NEVPNProtocol *protocolConfiguration API_AVAILABLE(macos(10.11), ios(9.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @property connection
* @discussion The NEVPNConnection object used for controlling the VPN tunnel.
*/
@property (readonly) NEVPNConnection *connection API_AVAILABLE(macos(10.11), ios(8.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @property enabled
* @discussion Toggles the enabled status of the VPN. Setting this property will disable VPN configurations of other apps. This property will be set to NO when other VPN configurations are enabled.
*/
@property (getter=isEnabled) BOOL enabled API_AVAILABLE(macos(10.11), ios(8.0)) API_UNAVAILABLE(watchos, tvos);
@end
NS_ASSUME_NONNULL_END
// ========== NetworkExtension.framework/Headers/NEFilterDataProvider.h
/*
* Copyright (c) 2015-2019 Apple Inc.
* All rights reserved.
*/
#ifndef __NE_INDIRECT__
#error "Please import the NetworkExtension module instead of this file directly."
#endif
#import <NetworkExtension/NEFilterProvider.h>
@class NEFilterVerdict;
@class NEFilterNewFlowVerdict;
@class NEFilterDataVerdict;
@class NEFilterRemediationVerdict;
@class NEFilterFlow;
@class NEFilterBrowserFlow;
@class NEFilterSocketFlow;
@class NEFilterSettings;
NS_ASSUME_NONNULL_BEGIN
#define NEFILTER_DATA_PROVIDER_EXTERN extern
/*!
* @file NEFilterDataProvider.h
* @discussion This file declares the NEFilterDataProvider. The NEFilterDataProvider API is used to implement the portion of a content filtering solution that is responsible for making filtering decisions about network data flows.
*/
/*!
* @interface NEFilterDataProvider
* @discussion The NEFilterDataProvider class declares the programmatic interface for an object that evaluates network data flows based on a set of locally-available rules and makes decisions about whether to block or allow the flows.
*/
API_AVAILABLE(macos(10.15), ios(9.0)) API_UNAVAILABLE(watchos, tvos)
@interface NEFilterDataProvider : NEFilterProvider
/*!
* @method handleNewFlow:
* @discussion This function is called by the framework when a filtering decision needs to be made about a new network data flow. Subclasses must override this method to implement the steps necessary to match the flow against some locally stored rules and return an appropriate verdict.
* @param flow An NEFilterFlow object containing details about the new flow.
* @return An NEFilterNewFlowVerdict object containing the veridct for the new flow.
*/
- (NEFilterNewFlowVerdict *)handleNewFlow:(NEFilterFlow *)flow API_AVAILABLE(macos(10.15), ios(9.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @method handleInboundDataFromFlow:readBytesStartOffset:readBytes:
* @discussion This function is called by the framework when a filtering decision needs to be made about some inbound data that the filter previously requested access to via the NEFilterFlowDataVerdict or the NEFilterNewFlowVerdict. Subclasses must override this method.
* @param flow The NEFilterFlow from which the data was read.
* @param offset The offset in bytes from the start of the flow's inbound data at which readBytes begins.
* @param readBytes The data that was read.
* @return An NEFilterFlowDataVerdict containing the verdict for the flow.
*/
- (NEFilterDataVerdict *)handleInboundDataFromFlow:(NEFilterFlow *)flow readBytesStartOffset:(NSUInteger)offset readBytes:(NSData *)readBytes API_AVAILABLE(macos(10.15), ios(9.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @method handleOutboundDataFromFlow:readBytesStartOffset:readBytes:
* @discussion This function is called by the framework when a filtering decision needs to be made about some outbound data that the filter previously requested access to via the NEFilterFlowDataVerdict or the NEFilterNewFlowVerdict. Subclasses must override this method.
* @param flow The NEFilterFlow from which the data was read.
* @param offset The offset in bytes from the start of the flow's outbound data at which readBytes begins.
* @param readBytes The data that was read.
* @return An NEFilterFlowDataVerdict containing the verdict for the flow.
*/
- (NEFilterDataVerdict *)handleOutboundDataFromFlow:(NEFilterFlow *)flow readBytesStartOffset:(NSUInteger)offset readBytes:(NSData *)readBytes API_AVAILABLE(macos(10.15), ios(9.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @method handleInboundDataCompleteForFlow:
* @discussion This function is called by the framework after all of the inbound data for a flow has been seen by the filter. Subclasses must override this method to return an appropriate pass/block result.
* @param flow The flow
* @return The final NEFilterFlowDataVerdict verdict for the flow.
*/
- (NEFilterDataVerdict *)handleInboundDataCompleteForFlow:(NEFilterFlow *)flow API_AVAILABLE(macos(10.15), ios(9.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @method handleOutboundDataCompleteForFlow:
* @discussion This function is called by the framework after all of the outbound data for a flow has been seen by the filter. Subclasses must override this method to return an appropriate pass/block result.
* @param flow The flow
* @return The final NEFilterFlowDataVerdict verdict for the flow.
*/
- (NEFilterDataVerdict *)handleOutboundDataCompleteForFlow:(NEFilterFlow *)flow API_AVAILABLE(macos(10.15), ios(9.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @method handleRemediationForFlow:
* @discussion This function is called by the framework after the user requests remediation for a blocked flow. Subclasses must override this method to return an appropriate pass/block result.
* @param flow The flow
* @return The final NEFilterRemediationVerdict verdict for the flow.
*/
- (NEFilterRemediationVerdict *)handleRemediationForFlow:(NEFilterFlow *)flow API_AVAILABLE(ios(9.0)) API_UNAVAILABLE(macos, watchos, tvos);
/*!
* @method handleRulesChanged
* @discussion This function is called by the framework when -[NEFilterControlProvider notifyRulesChanged] is called. Subclasses should override this method to reload new rules from disk.
*/
- (void)handleRulesChanged API_AVAILABLE(ios(9.0)) API_UNAVAILABLE(macos, watchos, tvos);
/*!
* @method applyFilterRules:defaultAction:withCompletionHandler:
* @discussion The provider calls this function to apply the current set of filtering rules associated with the provider and also change the default filtering action.
* @param settings A NEFilterSettings object containing the filter settings to apply to the system. Pass nil to revert to the default settings, which are an
* empty list of rules and a default action of NEFilterActionFilterData.
* @param completionHandler A block that will be executed when the settings have been applied to the system. If an error occurs then the error parameter will be non-nil.
*/
- (void)applySettings:(nullable NEFilterSettings *)settings completionHandler:(void (^)(NSError * _Nullable error))completionHandler API_AVAILABLE(macos(10.15)) API_UNAVAILABLE(ios, watchos, tvos);
/*!
* @method resumeFlow:withVerdict:
* @discussion This function is called by the provider to resume a flow that was previously paused by the provider returning a pause verdict.
* @param flow The flow to resume
* @param verdict The next NEFilterDataVerdict for the flow. This verdict is used as the verdict corresponding to the
* flow handler callback (handleNewFlow:, handleInboundDataFromFlow:, etc.) that returned the pause verdict that
* paused the flow. This must be either a NEFilterDataVerdict or a NEFilterNewFlowVerdict. It is invalid to resume
* a flow that is not paused.
*/
- (void)resumeFlow:(NEFilterFlow *)flow withVerdict:(NEFilterVerdict *)verdict API_AVAILABLE(macos(10.15)) API_UNAVAILABLE(ios, watchos, tvos);
@end
/*!
* @interface NEFilterDataVerdict
* @discussion The NEFilterDataVerdict class declares the programmatic interface of an object that is the verdict for a flow of network data after some of the data has been seen by the filter.
*
* NEFilterDataVerdict is part of NetworkExtension.framework
*/
API_AVAILABLE(macos(10.15), ios(9.0)) API_UNAVAILABLE(watchos, tvos)
@interface NEFilterDataVerdict : NEFilterVerdict <NSSecureCoding,NSCopying>
/*!
* @method allowVerdict
* @discussion This class method returns a verdict indicating that the flow should be allowed.
* @return The NEFilterDataVerdict object.
*/
+ (NEFilterDataVerdict *)allowVerdict API_AVAILABLE(macos(10.15), ios(9.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @method dropVerdict
* @discussion This class method returns a verdict indicating that the flow should be dropped.
* @return The NEFilterDataVerdict object.
*/
+ (NEFilterDataVerdict *)dropVerdict API_AVAILABLE(macos(10.11), ios(9.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @method remediateVerdictWithRemediationURLMapKey:remediationButtonTextMapKey:
* @discussion This class method returns a verdict indicating that a "content blocked" page should be displayed to the user. The block page should contain a link to the given URL.
* @param remediationURLMapKey Remediation map key used by data plugin to get remediation url. Passing nil will result into data provider being notified with the callback handleRemediationForFlow:
* @param remediationButtonTextMapKey Remediation button map key used by the data plugin to get the remediation button text. Passing nil will set the button text to "Request Access"
* @return The NEFilterDataVerdict object.
*/
+ (NEFilterDataVerdict *)remediateVerdictWithRemediationURLMapKey:(nullable NSString *)remediationURLMapKey remediationButtonTextMapKey:(nullable NSString *)remediationButtonTextMapKey API_AVAILABLE(ios(9.0)) API_UNAVAILABLE(macos, watchos, tvos);
/*!
* @method dataVerdictWithPassBytes:peekBytes:
* @discussion This class method returns a data verdict indicating that the filter is passing a given number of bytes through the filter and needs to see a given number of bytes after the bytes that are passed.
* @param passBytes The number of bytes to pass through the filter.
* @param peekBytes The number of bytes after the end of the bytes passed that the filter wants to see in the next call to -[NEFilterDataProvider handleOutboundDataFromFlow:readBytesStartOffset:readBytes:] or -[NEFilterDataProvider handleInboundDataFromFlow:readBytesStartOffset:readBytes:].
* @return The data flow verdict.
*/
+ (NEFilterDataVerdict *)dataVerdictWithPassBytes:(NSUInteger)passBytes peekBytes:(NSUInteger)peekBytes API_AVAILABLE(macos(10.15), ios(9.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @method needRulesVerdict
* @discussion This class method returns a verdict indicating that control provider needs to be asked how to handle the data flow. The control provider can either drop or allow the flow, or update the rules and ask the data provider to decide on the data flow again.
* @return The NEFilterDataVerdict object.
*/
+ (NEFilterDataVerdict *)needRulesVerdict API_AVAILABLE(ios(9.0)) API_UNAVAILABLE(macos, watchos, tvos);
/*!
* @method pauseVerdict
* @discussion This class method returns a verdict indicating that none of the data provider's handler callbacks shall be called for the flow until after the flow is resumed
* by a call to -[NEFilterDataProvider resumeFlow:withVerdict:]. TCP flows may be paused indefinitely. UDP flows will be dropped if not resumed within 10 seconds of
* being paused. It is invalid to pause a flow that is already paused.
* @return The NEFilterDataVerdict object.
*/
+ (NEFilterDataVerdict *)pauseVerdict API_AVAILABLE(macos(10.15)) API_UNAVAILABLE(ios, watchos, tvos);
@end
/*!
* @interface NEFilterRemediationVerdict
* @discussion The NEFilterRemediationVerdict class declares the programmatic interface of an object that is the verdict for a flow which has been blocked by the filter, but the user has made a request for remediation.
*
* NEFilterRemediationVerdict is part of NetworkExtension.framework
*/
API_AVAILABLE(ios(9.0)) API_UNAVAILABLE(macos, watchos, tvos)
@interface NEFilterRemediationVerdict : NEFilterVerdict <NSSecureCoding,NSCopying>
/*!
* @method allowVerdict
* @discussion This class method returns a verdict indicating that the flow should be allowed.
* @return The NEFilterRemediationVerdict object.
*/
+ (NEFilterRemediationVerdict *) allowVerdict API_AVAILABLE(ios(9.0)) API_UNAVAILABLE(macos, watchos, tvos);
/*!
* @method dropVerdict
* @discussion This class method returns a verdict indicating that the flow should be dropped.
* @return The NEFilterRemediationVerdict object.
*/
+ (NEFilterRemediationVerdict *) dropVerdict API_AVAILABLE(ios(9.0)) API_UNAVAILABLE(macos, watchos, tvos);
/*!
* @method needRulesVerdict
* @discussion This class method returns a verdict indicating that control provider needs to be asked how to handle the remediation. The control provider can either drop or allow the flow, or update the rules and ask the data provider to decide on the data flow again.
* @return The NEFilterRemediationVerdict object.
*/
+ (NEFilterRemediationVerdict *) needRulesVerdict API_AVAILABLE(ios(9.0)) API_UNAVAILABLE(macos, watchos, tvos);
@end
NS_ASSUME_NONNULL_END
// ========== NetworkExtension.framework/Headers/NEDNSSettings.h
/*
* Copyright (c) 2013-2015, 2018 Apple Inc.
* All rights reserved.
*/
#ifndef __NE_INDIRECT__
#error "Please import the NetworkExtension module instead of this file directly."
#endif
NS_ASSUME_NONNULL_BEGIN
/*!
* @file NEDNSSettings.h
* @discussion This file declares the NEDNSSettings API. The NEDNSSettings API is used to specify DNS settings for Network Extensions.
*
* This API is part of NetworkExtension.framework
*/
/*!
* @interface NEDNSSettings
* @discussion The NEDNSSettings class declares the programmatic interface for an object that contains DNS settings.
*/
API_AVAILABLE(macos(10.11), ios(9.0)) API_UNAVAILABLE(watchos, tvos)
@interface NEDNSSettings : NSObject <NSSecureCoding,NSCopying>
/*!
* @method initWithServers:
* @discussion Initialize a newly-allocated NEDNSSettings object.
* @param servers An array of DNS server IP address strings.
*/
- (instancetype)initWithServers:(NSArray<NSString *> *)servers API_AVAILABLE(macos(10.11), ios(9.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @property servers
* @discussion An array of DNS server address strings.
*/
@property (readonly) NSArray<NSString *> *servers API_AVAILABLE(macos(10.11), ios(9.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @property searchDomains
* @discussion An array of DNS server search domain strings.
*/
@property (copy, nullable) NSArray<NSString *> *searchDomains API_AVAILABLE(macos(10.11), ios(9.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @property domainName
* @discussion A string containing the DNS domain.
*/
@property (copy, nullable) NSString *domainName API_AVAILABLE(macos(10.11), ios(9.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @property matchDomains
* @discussion An array of strings containing domain strings. If this property is non-nil, the DNS settings will only be used to resolve host names within the specified domains.
*/
@property (copy, nullable) NSArray<NSString *> *matchDomains API_AVAILABLE(macos(10.11), ios(9.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @property matchDomainsNoSearch
* @discussion A boolean indicating if the match domains should be appended to the search domain list. Default is NO (match domains will be appended to the search domain list).
*/
@property BOOL matchDomainsNoSearch API_AVAILABLE(macos(10.11), ios(9.0)) API_UNAVAILABLE(watchos, tvos);
@end
NS_ASSUME_NONNULL_END
// ========== NetworkExtension.framework/Headers/NWTCPConnection.h
//
// NWTCPConnection.h
// Network
//
// Copyright (c) 2014-2016, 2018 Apple Inc. All rights reserved.
//
#ifndef __NE_TAPI__
#ifndef __NE_INDIRECT__
#error "Please import the NetworkExtension module instead of this file directly."
#endif // __NE_INDIRECT__
#ifndef __NWTCPConnection_h_
#define __NWTCPConnection_h_
#import <Security/Security.h>
NS_ASSUME_NONNULL_BEGIN
/*!
* @typedef NWTCPConnectionState
* @abstract Defined connection states. New types may be defined in the future.
*/
typedef NS_ENUM(NSInteger, NWTCPConnectionState) {
/*! @constant NWTCPConnectionStateInvalid The connection is in an invalid or uninitialized state */
NWTCPConnectionStateInvalid = 0,
/*! @constant NWTCPConnectionStateConnecting The connection is attempting */
NWTCPConnectionStateConnecting = 1,
/*! @constant NWTCPConnectionStateWaiting The connection has attempted but failed. It is now
* waiting for better condition(s) before trying again.
*/
NWTCPConnectionStateWaiting = 2,
/*! @constant NWTCPConnectionStateConnected The connection is established. It is now possible
* to transfer data. If TLS is in use, the TLS handshake would have finished when the connection
* is in this state.
*/
NWTCPConnectionStateConnected = 3,
/*! @constant NWTCPConnectionStateDisconnected The connection is disconnected. It is no longer
* possible to transfer data. The application should call cancellation method to clean up resources
* when the connection is in this state.
*/
NWTCPConnectionStateDisconnected = 4,
/*! @constant NWTCPConnectionStateCancelled The connection is cancelled. This is triggered by
* the cancellation method.
*/
NWTCPConnectionStateCancelled = 5,
} API_AVAILABLE(macos(10.11), ios(9.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @interface NWTCPConnection
* @discussion Establish TCP connections to an endpoint, and send and receive data on the TCP connection.
*/
API_AVAILABLE(macos(10.11), ios(9.0)) API_UNAVAILABLE(watchos, tvos)
@interface NWTCPConnection : NSObject
/*!
* @method initWithUpgradeForConnection:
* @discussion This convenience initializer can be used to create a new connection that would only
* be connected if there exists a better path (as determined by the system) to the destination
* endpoint of the original connection. It will be initialized using the same destination endpoint
* and set of parameters from the original connection.
*
* If the original connection becomes disconnected or cancelled, the new "upgrade" connection
* would automatically be considered better.
*
* The caller should create an NWTCPConnection and watch for the hasBetterPath property.
* When this property is YES, the caller should attempt to create a new upgrade
* connection, with the goal to start transferring data on the new better path as soon as
* possible to reduce power and potentially monetary cost. When the new upgrade connection
* becomes connected and when the caller wraps up the previous caller session on
* the original connection, the caller can start using the new upgrade connection and
* tear down the original one.
*
* @param connection The original connection from which the caller will upgrade
* @return An initialized NWTCPConnection
*/
- (instancetype)initWithUpgradeForConnection:(NWTCPConnection *)connection API_AVAILABLE(macos(10.11), ios(9.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @property state
* @discussion The status of the connection. Use KVO to watch this property to get updates.
*/
@property (readonly) NWTCPConnectionState state API_AVAILABLE(macos(10.11), ios(9.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @property viable
* @discussion YES if the connection can read and write data, NO otherwise. Use KVO to watch this property.
*/
@property (readonly, getter=isViable) BOOL viable API_AVAILABLE(macos(10.11), ios(9.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @property hasBetterPath
* @discussion YES if the system determines there is a better path the destination can be reached if
* the caller creates a new connection using the same endpoint and parameters. This can
* be done using the convenience upgrade initializer method.
* Use KVO to watch this property to get updates.
*/
@property (readonly) BOOL hasBetterPath API_AVAILABLE(macos(10.11), ios(9.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @property endpoint
* @discussion The destination endpoint with which this connection was created.
*/
@property (readonly) NWEndpoint *endpoint API_AVAILABLE(macos(10.11), ios(9.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @property connectedPath
* @discussion The network path over which the connection was established. The caller can query
* additional properties from the NWPath object for more information.
*
* Note that this contains a snapshot of information at the time of connection establishment
* for this connection only. As a result, some underlying properties might change in time and
* might not reflect the path for other connections that might be established at different times.
*/
@property (readonly, nullable) NWPath *connectedPath API_AVAILABLE(macos(10.11), ios(9.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @property localAddress
* @discussion The IP address endpoint from which the connection was connected.
*/
@property (readonly, nullable) NWEndpoint *localAddress API_AVAILABLE(macos(10.11), ios(9.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @property remoteAddress
* @discussion The IP address endpoint to which the connection was connected.
*/
@property (readonly, nullable) NWEndpoint *remoteAddress API_AVAILABLE(macos(10.11), ios(9.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @property txtRecord
* @discussion When the connection is connected to a Bonjour service endpoint, the TXT record associated
* with the Bonjour service is available via this property. Beware that the value comes from
* the network. Care must be taken when parsing this potentially malicious value.
*/
@property (readonly, nullable) NSData *txtRecord API_AVAILABLE(macos(10.11), ios(9.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @property error
* @discussion The connection-wide error property indicates any fatal error that occurred while
* processing the connection or performing data reading or writing.
*/
@property (readonly, nullable) NSError *error API_AVAILABLE(macos(10.11), ios(9.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @method cancel:
* @discussion Cancel the connection. This will clean up the resources associated with this object
* and transition this object to NWTCPConnectionStateCancelled state.
*/
- (void)cancel API_AVAILABLE(macos(10.11), ios(9.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @method readLength:completionHandler:
* @discussion Read "length" number of bytes. See readMinimumLength:maximumLength:completionHandler:
* for a complete discussion of the callback behavior.
* @param length The exact number of bytes the application wants to read
* @param completion The completion handler to be invoked when there is data to read or an error occurred
*/
- (void)readLength:(NSUInteger)length completionHandler:(void (^)(NSData * __nullable data, NSError * __nullable error))completion API_AVAILABLE(macos(10.11), ios(9.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @method readMinimumLength:maximumLength:completionHandler:
*
* @discussion Read the requested range of bytes. The completion handler will be invoked when:
* - Exactly "length" number of bytes have been read. 'data' will be non-nil.
*
* - Fewer than "length" number of bytes, including 0 bytes, have been read, and the connection's
* read side has been closed. 'data' might be nil, depending on whether there was any data to be
* read when the connection's read side was closed.
*
* - Some fatal error has occurred, and 'data' will be nil.
*
* To know when to schedule a read again, check for the condition whether an error has occurred.
*
* For better performance, the caller should pick the effective minimum and maximum lengths.
* For example, if the caller absolutely needs a specific number of bytes before it can
* make any progress, use that value as the minimum. The maximum bytes can be the upperbound
* that the caller wants to read. Typically, the minimum length can be the caller
* protocol fixed-size header and the maximum length can be the maximum size of the payload or
* the size of the current read buffer.
*
* @param minimum The minimum number of bytes the caller wants to read
* @param maximum The maximum number of bytes the caller wants to read
* @param completion The completion handler to be invoked when there is data to read or an error occurred
*/
- (void)readMinimumLength:(NSUInteger)minimum maximumLength:(NSUInteger)maximum completionHandler:(void (^)(NSData * __nullable data, NSError * __nullable error))completion API_AVAILABLE(macos(10.11), ios(9.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @method write:completionHandler:
* @discussion Write the given data object content. Callers should wait until the completionHandler is executed
* before issuing another write.
* @param data The data object whose content will be written
* @param completion The completion handler to be invoked when the data content has been written or an error has occurred.
* If the error is nil, the write succeeded and the caller can write more data.
*/
- (void)write:(NSData *)data completionHandler:(void (^)(NSError * __nullable error))completion API_AVAILABLE(macos(10.11), ios(9.0)) API_UNAVAILABLE(watchos, tvos);
/*!
* @method writeClose:
* @discussion Close this connection's write side such that further write requests won't succeed.
* Note that this has the effect of closing the read side of the peer connection.
* When the connection's read side and write side are closed, the connection is considered
* disconnected and will transition to the appropriate state.
*/
- (void)writeClose API_AVAILABLE(macos(10.11), ios(9.0)) API_UNAVAILABLE(watchos, tvos);
@end
/*!
* @protocol NWTCPConnectionAuthenticationDelegate
* @discussion Allows the caller to take custom actions on some connection events.
*/
@protocol NWTCPConnectionAuthenticationDelegate <NSObject>
@optional
/*!
* @method shouldProvideIdentityForConnection:
* @discussion The caller can implement this optional protocol method to decide whether it
* wants to provide the identity for this connection for authentication. If this delegate
* method is not implemented, the return value will default to YES if
* provideIdentityForConnection:completionHandler: is implemented.
* @param connection The connection sending this message
* @return YES to provide the identity for this connection, in which case, the delegate method
* provideIdentityForConnection:completionHandler: will be called.
*/
- (BOOL)shouldProvideIdentityForConnection:(NWTCPConnection *)connection;
/*!
* @method provideIdentityForConnection:completionHandler:
* @discussion The caller can implement this optional protocol method to provide the identity
* and an optional certificate chain to be used for authentication.
* @param connection The connection sending this message
* @param completion The completion handler for passing identity and certificate chain to the connection.
* The "identity" argument is required and must not be nil. The "certificateChain" argument is optional,
* and is an array of one or more SecCertificateRef objects. The certificate chain must contain objects
* of type SecCertificateRef only. If the certificate chain is set, it will be used. Otherwise, the leaf
* certificate will be extracted from the SecIdentityRef object and will be used for authentication.
*
* The caller is responsible for keeping the argument object(s) alive for the duration of the
* completion handler invocation.
*/
- (void)provideIdentityForConnection:(NWTCPConnection *)connection
completionHandler:(void (^)(SecIdentityRef identity, NSArray<id> *certificateChain))completion;
/*!
* @method shouldEvaluateTrustForConnection:
* @discussion The caller can implement this optional protocol method to decide whether it
* wants to take over the default trust evaluation for this connection. If this delegate method
* is not implemented, the return value will default to YES if
* provideIdentityForConnection:completionHandler: is implemented.
* @param connection The connection sending this message
* @return YES to take over the default trust evaluation, in which case, the delegate method
* evaluateTrustForConnection:peerCertificateChain:completionHandler: will be called.
*/
- (BOOL)shouldEvaluateTrustForConnection:(NWTCPConnection *)connection;
/*!
* @method evaluateTrustForConnection:peerCertificateChain:completionHandler:
* @discussion The caller can implement this optional protocol method to set up custom policies
* for peer certificate trust evaluation. If the delegate method is implemented, the caller
* is responsible for creating and setting up the SecTrustRef object and passing it to the
* completion handler. Otherwise, the default trust evaluation policy is used for the connection.