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

Commit 53c39ba

Browse files
committed
authorize helper manually; version updated
1 parent 26bcf34 commit 53c39ba

File tree

3 files changed

+36
-27
lines changed

3 files changed

+36
-27
lines changed

V2RayX/AppDelegate.m

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
4444
// create a serial queue used for NSTask operations
4545
taskQueue = dispatch_queue_create("cenmrev.v2rayx.nstask", DISPATCH_QUEUE_SERIAL);
4646

47-
if (![self installHelper]) {
47+
if (![self installHelper:false]) {
4848
[[NSApplication sharedApplication] terminate:nil];// installation failed or stopped by user,
4949
};
5050

@@ -689,35 +689,38 @@ -(BOOL)currentProxySetByMe {
689689
return YES;
690690
}*/
691691

692-
- (BOOL)installHelper {
692+
- (IBAction)authorizeV2sys:(id)sender {
693+
[self installHelper:true];
694+
}
695+
696+
- (BOOL)installHelper:(BOOL)force {
693697
NSFileManager *fileManager = [NSFileManager defaultManager];
694-
if (![fileManager fileExistsAtPath:kV2RayXHelper] || ![self isSysconfVersionOK]) {
695-
NSAlert *installAlert = [[NSAlert alloc] init];
696-
[installAlert addButtonWithTitle:@"Install"];
697-
[installAlert addButtonWithTitle:@"Quit"];
698-
[installAlert setMessageText:@"V2RayX needs to install a small tool to /Library/Application Support/V2RayX/ with administrator privileges to set system proxy quickly.\nOtherwise you need to type in the administrator password every time you change system proxy through V2RayX."];
699-
if ([installAlert runModal] == NSAlertFirstButtonReturn) {
700-
NSLog(@"start install");
701-
NSString *helperPath = [NSString stringWithFormat:@"%@/%@", [[NSBundle mainBundle] resourcePath], @"install_helper.sh"];
702-
NSLog(@"run install script: %@", helperPath);
703-
NSDictionary *error;
704-
NSString *script = [NSString stringWithFormat:@"do shell script \"bash %@\" with administrator privileges", helperPath];
705-
NSAppleScript *appleScript = [[NSAppleScript new] initWithSource:script];
706-
if ([appleScript executeAndReturnError:&error]) {
707-
NSLog(@"installation success");
708-
return YES;
709-
} else {
710-
NSLog(@"installation failure");
711-
//unknown failure
712-
return NO;
713-
}
698+
if (!force && [fileManager fileExistsAtPath:kV2RayXHelper] && [self isSysconfVersionOK]) {
699+
// helper already installed
700+
return YES;
701+
}
702+
NSAlert *installAlert = [[NSAlert alloc] init];
703+
[installAlert addButtonWithTitle:@"Install"];
704+
[installAlert addButtonWithTitle:@"Quit"];
705+
[installAlert setMessageText:@"V2RayX needs to install a small tool to /Library/Application Support/V2RayX/ with administrator privileges to set system proxy quickly.\nOtherwise you need to type in the administrator password every time you change system proxy through V2RayX."];
706+
if ([installAlert runModal] == NSAlertFirstButtonReturn) {
707+
NSLog(@"start install");
708+
NSString *helperPath = [NSString stringWithFormat:@"%@/%@", [[NSBundle mainBundle] resourcePath], @"install_helper.sh"];
709+
NSLog(@"run install script: %@", helperPath);
710+
NSDictionary *error;
711+
NSString *script = [NSString stringWithFormat:@"do shell script \"bash %@\" with administrator privileges", helperPath];
712+
NSAppleScript *appleScript = [[NSAppleScript new] initWithSource:script];
713+
if ([appleScript executeAndReturnError:&error]) {
714+
NSLog(@"installation success");
715+
return YES;
714716
} else {
715-
// stopped by user
717+
NSLog(@"installation failure");
718+
//unknown failure
716719
return NO;
717720
}
718721
} else {
719-
// helper already installed
720-
return YES;
722+
// stopped by user
723+
return NO;
721724
}
722725
}
723726

V2RayX/Base.lproj/MainMenu.xib

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,12 @@
756756
<action selector="resetPac:" target="Voe-Tx-rLC" id="WUw-A2-aU5"/>
757757
</connections>
758758
</menuItem>
759+
<menuItem title="Authorize v2rayx_sysconf..." id="mOc-zi-Beb">
760+
<modifierMask key="keyEquivalentModifierMask"/>
761+
<connections>
762+
<action selector="authorizeV2sys:" target="Voe-Tx-rLC" id="ycW-j1-Sv7"/>
763+
</connections>
764+
</menuItem>
759765
<menuItem isSeparatorItem="YES" id="YAD-DW-T91"/>
760766
<menuItem title="Help" id="Yq1-i5-ecF">
761767
<modifierMask key="keyEquivalentModifierMask"/>

V2RayX/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
<key>CFBundlePackageType</key>
1818
<string>APPL</string>
1919
<key>CFBundleShortVersionString</key>
20-
<string>1.0.0</string>
20+
<string>1.1.1</string>
2121
<key>CFBundleSignature</key>
2222
<string>????</string>
2323
<key>CFBundleVersion</key>
24-
<string>198</string>
24+
<string>201</string>
2525
<key>LSMinimumSystemVersion</key>
2626
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
2727
<key>LSUIElement</key>

0 commit comments

Comments
 (0)