Skip to content

Commit

Permalink
vers 0.9.9: improved dns parsing code, improved installer, proj cleanup
Browse files Browse the repository at this point in the history
-dns parsing now handles multiple cnames and anames
-installer doesn't re-enumerate existing apps on upgrade
-installer checks and warns about removing beta during upgrade
-removed old (fatal) error handling code (now uses Senty.io)
  • Loading branch information
Patrick Wardle committed Aug 6, 2018
1 parent 978e379 commit 516dc0e
Show file tree
Hide file tree
Showing 22 changed files with 311 additions and 451 deletions.
7 changes: 0 additions & 7 deletions configure/Configure/AppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#import "Configure.h"
#import "HelperComms.h"
#import "AboutWindowController.h"
#import "ErrorWindowController.h"
#import "ConfigureWindowController.h"

//block for install/uninstall
Expand Down Expand Up @@ -41,16 +40,10 @@ typedef void (^block)(NSNumber*);
//configure window controller
@property(nonatomic, retain)ConfigureWindowController* configureWindowController;

//error window controller
@property(nonatomic, retain)ErrorWindowController* errorWindowController;


/* METHODS */

//display configuration window w/ 'install' || 'uninstall' button
-(void)displayConfigureWindow:(BOOL)isInstalled;

//display error window
-(void)displayErrorWindow:(NSDictionary*)errorInfo;

@end
56 changes: 2 additions & 54 deletions configure/Configure/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ @implementation AppDelegate
@synthesize configureObj;

@synthesize aboutWindowController;
@synthesize errorWindowController;
@synthesize configureWindowController;

//main app interface
Expand All @@ -48,6 +47,7 @@ -(void)applicationDidFinishLaunching:(NSNotification *)notification
-(BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender
{
#pragma unused(sender)

return YES;
}

Expand All @@ -67,61 +67,9 @@ -(void)displayConfigureWindow:(BOOL)isInstalled
return;
}

//display error window
-(void)displayErrorWindow:(NSDictionary*)errorInfo
{
//alloc error window
errorWindowController = [[ErrorWindowController alloc] initWithWindowNibName:@"ErrorWindowController"];

//main thread
// just show UI alert, unless its fatal (then load URL)
if(YES == [NSThread isMainThread])
{
//non-fatal errors
// show error error popup
if(YES != [errorInfo[KEY_ERROR_URL] isEqualToString:FATAL_ERROR_URL])
{
//display it
// call this first to so that outlets are connected
[self.errorWindowController display];

//configure it
[self.errorWindowController configure:errorInfo];
}
//fatal error
// launch browser to go to fatal error page, then exit
else
{
//launch browser
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:errorInfo[KEY_ERROR_URL]]];

//then exit
[NSApp terminate:self];
}
}
//background thread
// have to show error window on main thread
else
{
//show alert
// in main UI thread
dispatch_sync(dispatch_get_main_queue(), ^{

//display it
// call this first to so that outlets are connected
[self.errorWindowController display];

//configure it
[self.errorWindowController configure:errorInfo];

});
}

return;
}

//menu handler for 'about'
- (IBAction)displayAboutWindow:(id)sender
-(IBAction)displayAboutWindow:(id)sender
{
#pragma unused(sender)

Expand Down
3 changes: 3 additions & 0 deletions configure/Configure/Configure.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
//determine if LuLu is installed
-(BOOL)isInstalled;

//determine if installed version is a beta
-(BOOL)isBetaInstalled;

//invokes appropriate install || uninstall logic
-(BOOL)configure:(NSInteger)parameter;

Expand Down
84 changes: 75 additions & 9 deletions configure/Configure/Configure.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ -(BOOL)configure:(NSInteger)parameter
//return var
BOOL wasConfigured = NO;

//uninstall flag
BOOL uninstallFlag = UNINSTALL_FULL;

//get help
if(YES != [self initHelper])
{
Expand All @@ -38,22 +41,42 @@ -(BOOL)configure:(NSInteger)parameter
goto bail;
}

//install extension
//install
if(ACTION_INSTALL_FLAG == parameter)
{
//dbg msg
logMsg(LOG_DEBUG, @"installing...");

//already installed?
// uninstall everything first
// perform an uninstall
if(YES == [self isInstalled])
{
//dbg msg
logMsg(LOG_DEBUG, @"already installed, so uninstalling...");

//existing install, a beta?
// set flag to perform full uninstall
if(YES == [self isBetaInstalled])
{
//dbg msg
logMsg(LOG_DEBUG, @"previous version is a beta, so will fully uninstall");

//set flag
uninstallFlag = UNINSTALL_FULL;
}
//non-beta
// set flag to perform partial uninstall
else
{
//dbg msg
logMsg(LOG_DEBUG, @"previous version is not beta, so only partially uninstall");

//set flag
uninstallFlag = UNINSTALL_PARTIAL;
}

//uninstall
// but do partial
if(YES != [self uninstall:UNINSTALL_PARTIAL])
if(YES != [self uninstall:uninstallFlag])
{
//bail
goto bail;
Expand All @@ -74,14 +97,13 @@ -(BOOL)configure:(NSInteger)parameter
logMsg(LOG_DEBUG, @"installed!");

}
//uninstall extension
//uninstall
else if(ACTION_UNINSTALL_FLAG == parameter)
{
//dbg msg
logMsg(LOG_DEBUG, @"uninstalling...");

//uninstall
// and relaunch Finder
if(YES != [self uninstall:UNINSTALL_FULL])
{
//bail
Expand All @@ -101,7 +123,7 @@ -(BOOL)configure:(NSInteger)parameter
}

//determine if installed
// simply checks if extension binary exists
// check if various firewall components are present
-(BOOL)isInstalled
{
//flag
Expand All @@ -126,13 +148,57 @@ -(BOOL)isInstalled
appPath = [@"/Applications" stringByAppendingPathComponent:APP_NAME];

//check for installed components
installed = ( (YES == [[NSFileManager defaultManager] fileExistsAtPath:appPath]) ||
installed = ( (YES == [[NSFileManager defaultManager] fileExistsAtPath:KEXT]) ||
(YES == [[NSFileManager defaultManager] fileExistsAtPath:appPath]) ||
(YES == [[NSFileManager defaultManager] fileExistsAtPath:launchDaemon]) ||
(YES == [[NSFileManager defaultManager] fileExistsAtPath:launchDaemonPlist]) );

return installed;
}

//determine if installed version is a beta
// just checks app bundle version, to see if it's starts w/ "0."
-(BOOL)isBetaInstalled
{
//flag
BOOL betaInstalled = NO;

//app bundle
NSBundle* appBundle = nil;

//app version
NSString* appVersion = nil;

//load app bundle
appBundle = [NSBundle bundleWithPath:[@"/Applications" stringByAppendingPathComponent:APP_NAME]];
if(nil == appBundle)
{
//bail
goto bail;
}

//extract version
appVersion = appBundle.infoDictionary[@"CFBundleVersion"];
if(nil == appVersion)
{
//bail
goto bail;
}

//check for beta
// version string that starts with 0
if(YES == [appVersion hasPrefix:@"0."])
{
//set flag
betaInstalled = YES;
}

bail:

return betaInstalled;
}


//init helper tool
// install and establish XPC connection
-(BOOL)initHelper
Expand Down Expand Up @@ -341,7 +407,7 @@ -(BOOL)install
};

//install
// note this is async
// note, this is async
[xpcComms install:block];

//wait for installer logic to be completed by XPC
Expand Down
37 changes: 34 additions & 3 deletions configure/Configure/ConfigureWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ -(void)configure:(BOOL)isInstalled

//app already installed?
// enable 'uninstall' button
// change install button to say 'upgrade'
// change 'install' button to say 'upgrade'
if(YES == isInstalled)
{
//enable 'uninstall'
Expand Down Expand Up @@ -123,6 +123,9 @@ -(IBAction)buttonHandler:(id)sender
//action
NSInteger action = 0;

//'beta installed' alert
NSAlert* betaInstalled = nil;

//dbg msg
logMsg(LOG_DEBUG, [NSString stringWithFormat:@"handling action click: %@", ((NSButton*)sender).title]);

Expand Down Expand Up @@ -155,6 +158,30 @@ -(IBAction)buttonHandler:(id)sender
//install || uninstall
else
{
//upgrade/uninstall
// warn if beta is installed
if( (action != ACTION_UNINSTALL_FLAG) &&
(YES == [((AppDelegate*)[[NSApplication sharedApplication] delegate]).configureObj isBetaInstalled]) )
{
//init alert
betaInstalled = [[NSAlert alloc] init];

//set style
betaInstalled.alertStyle = NSAlertStyleInformational;

//main text
betaInstalled.messageText = @"Beta Version Already Installed";

//details
betaInstalled.informativeText = @"Please note, it will be fully uninstalled first!";

//add button
[betaInstalled addButtonWithTitle:@"Ok"];

//show
[betaInstalled runModal];
}

//disable 'x' button
// don't want user killing app during install/upgrade
[[self.window standardWindowButton:NSWindowCloseButton] setEnabled:NO];
Expand Down Expand Up @@ -225,10 +252,14 @@ -(void)lifeCycleEvent:(NSInteger)event
//set flag
status = YES;

//for install
//for fresh install
// wait until enum'ing of installed apps is done
if(ACTION_INSTALL_FLAG == event)
if( (ACTION_INSTALL_FLAG == event) &&
(YES != [[NSFileManager defaultManager] fileExistsAtPath:[INSTALL_DIRECTORY stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.plist", INSTALLED_APPS]]]) )
{
//dbg msg
logMsg(LOG_DEBUG, @"enumerating (pre)installed applications");

//nap
// give time for 'system_profiler' to start....
[NSThread sleepForTimeInterval:1.0];
Expand Down
43 changes: 0 additions & 43 deletions configure/Configure/ErrorWindowController.h

This file was deleted.

Loading

0 comments on commit 516dc0e

Please sign in to comment.