-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathFoundation.NSURLSession.js
66 lines (39 loc) · 1.78 KB
/
Foundation.NSURLSession.js
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
'use strict';
var proxyHost = '192.168.1.219';
var proxyPort = 8080;
/*
Creating a Session
+ sessionWithConfiguration:
Creates a session with the specified session configuration.
+ sessionWithConfiguration:delegate:delegateQueue:
Creates a session with the specified session configuration, delegate, and operation queue.
*/
var NSMutableDictionary = ObjC.classes.NSMutableDictionary;
Interceptor.attach(ObjC.classes.NSURLSession['+ sessionWithConfiguration:'].implementation, {
onEnter: function (args) {
console.log("Setting proxy for [NSURLSession sessionWithConfiguration:]");
var configuration = ObjC.Object(args[2]);
var proxyDict = NSMutableDictionary.dictionary();
proxyDict.setValue_forKey_(1,"HTTPEnable");
proxyDict.setValue_forKey_(proxyHost,"HTTPProxy");
proxyDict.setValue_forKey_(proxyPort,"HTTPPort");
proxyDict.setValue_forKey_(1,"HTTPSEnable");
proxyDict.setValue_forKey_(proxyHost,"HTTPSProxy");
proxyDict.setValue_forKey_(proxyPort,"HTTPSPort");
configuration.setConnectionProxyDictionary_(proxyDict);
},
});
Interceptor.attach(ObjC.classes.NSURLSession['+ sessionWithConfiguration:delegate:delegateQueue:'].implementation, {
onEnter: function (args) {
console.log("Setting proxy for [NSURLSession sessionWithConfiguration:delegate:delegateQueue:]");
var configuration = ObjC.Object(args[2]);
var proxyDict = NSMutableDictionary.dictionary();
proxyDict.setValue_forKey_(1,"HTTPEnable");
proxyDict.setValue_forKey_(proxyHost,"HTTPProxy");
proxyDict.setValue_forKey_(proxyPort,"HTTPPort");
proxyDict.setValue_forKey_(1,"HTTPSEnable");
proxyDict.setValue_forKey_(proxyHost,"HTTPSProxy");
proxyDict.setValue_forKey_(proxyPort,"HTTPSPort");
configuration.setConnectionProxyDictionary_(proxyDict);
},
});