Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
v2rayx_sysconf now will not change other proxy settings, like bypass …
Browse files Browse the repository at this point in the history
…settings.
  • Loading branch information
Cenmrev committed Aug 23, 2018
1 parent f145393 commit 8204670
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
16 changes: 9 additions & 7 deletions v2rayx_sysconf/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,12 @@ int main(int argc, const char * argv[])

NSDictionary *sets = (__bridge NSDictionary *)SCPreferencesGetValue(prefRef, kSCPrefNetworkServices);

NSMutableDictionary *proxies = [[NSMutableDictionary alloc] init];
[proxies setObject:[NSNumber numberWithInt:0] forKey:(NSString *)kCFNetworkProxiesHTTPEnable];
[proxies setObject:[NSNumber numberWithInt:0] forKey:(NSString *)kCFNetworkProxiesHTTPSEnable];
[proxies setObject:[NSNumber numberWithInt:0] forKey:(NSString *)kCFNetworkProxiesProxyAutoConfigEnable];
[proxies setObject:[NSNumber numberWithInt:0] forKey:(NSString *)kCFNetworkProxiesSOCKSEnable];


NSDictionary* originalSets;
if ([mode isEqualToString:@"save"]) {
[sets writeToURL:[NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/Library/Application Support/V2RayX/system_proxy_backup.plist",NSHomeDirectory()]] atomically:NO];
return 0;
}

// 遍历系统中的网络设备列表,设置 AirPort 和 Ethernet 的代理
if([mode isEqualToString:@"restore"]) {
originalSets = [NSDictionary dictionaryWithContentsOfURL:[NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/Library/Application Support/V2RayX/system_proxy_backup.plist",NSHomeDirectory()]]];
Expand All @@ -71,11 +65,19 @@ int main(int argc, const char * argv[])
NSString *hardware = [dict valueForKeyPath:@"Interface.Hardware"];
// NSLog(@"%@", hardware);
if ([hardware isEqualToString:@"AirPort"] || [hardware isEqualToString:@"Wi-Fi"] || [hardware isEqualToString:@"Ethernet"]) {

NSMutableDictionary *proxies = [sets[key][@"Proxies"] mutableCopy];
[proxies setObject:[NSNumber numberWithInt:0] forKey:(NSString *)kCFNetworkProxiesHTTPEnable];
[proxies setObject:[NSNumber numberWithInt:0] forKey:(NSString *)kCFNetworkProxiesHTTPSEnable];
[proxies setObject:[NSNumber numberWithInt:0] forKey:(NSString *)kCFNetworkProxiesProxyAutoConfigEnable];
[proxies setObject:[NSNumber numberWithInt:0] forKey:(NSString *)kCFNetworkProxiesSOCKSEnable];

if ([mode isEqualToString:@"restore"]) {
if ([originalSets objectForKey:key]){
proxies = originalSets[key][@"Proxies"];
}
}

if ([mode isEqualToString:@"auto"]) {

[proxies setObject:@"http://127.0.0.1:8070/proxy.pac" forKey:(NSString *)kCFNetworkProxiesProxyAutoConfigURLString];
Expand Down
2 changes: 1 addition & 1 deletion v2rayx_sysconf/sysconf_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
#define sysconf_version_h


#define VERSION @"v2rayx_sysconf 1.3.0"
#define VERSION @"v2rayx_sysconf 1.4.0"

#endif /* sysconf_version_h */

0 comments on commit 8204670

Please # to comment.