Skip to content

Commit

Permalink
added option to turn off crash/error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
objective-see committed Apr 5, 2023
1 parent 3f930b7 commit 7d8bf18
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "getsentry/sentry-cocoa" "7.18.1"
github "getsentry/sentry-cocoa" "8.4.0"
2 changes: 1 addition & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "getsentry/sentry-cocoa" "7.18.1"
github "getsentry/sentry-cocoa" "8.4.0"
18 changes: 17 additions & 1 deletion LuLu/App/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
// Copyright (c) 2020 Objective-See. All rights reserved.
//

@import Sentry;

#import "consts.h"
#import "Update.h"
#import "utilities.h"
Expand Down Expand Up @@ -471,7 +473,7 @@ -(void)toggleIcon:(NSDictionary*)preferences
//dbg msg
os_log_debug(logHandle, "method '%s' invoked", __PRETTY_FUNCTION__);

//should run with no icon?
//should run with icon?
// init and show status bar item
if(YES != [preferences[PREF_NO_ICON_MODE] boolValue])
{
Expand Down Expand Up @@ -597,6 +599,20 @@ -(void)completeInitialization:(NSDictionary*)initialPreferences
//dbg msg
os_log_debug(logHandle, "loaded preferences %{public}@", preferences);

//init crash reporting
// unless user has turned it off
if(YES != [preferences[PREF_NO_ERROR_REPORTING] boolValue])
{
//dbg msg
os_log_debug(logHandle, "enabling crash reporting");

//init crash reporting
[SentrySDK startWithConfigureOptions:^(SentryOptions *options) {
options.dsn = SENTRY_DSN;
options.debug = YES;
}];
}

//run with status bar icon?
if(YES != [preferences[PREF_NO_ICON_MODE] boolValue])
{
Expand Down
35 changes: 32 additions & 3 deletions LuLu/App/Preferences.xib
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21507" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21701" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21507"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21701"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
Expand Down Expand Up @@ -339,14 +339,43 @@
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button fixedFrame="YES" tag="8" translatesAutoresizingMaskIntoConstraints="NO" id="JmJ-L9-MH7">
<rect key="frame" x="39" y="46" width="29" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="Deq-O6-Fhe">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="menu" size="14"/>
</buttonCell>
<connections>
<action selector="togglePreference:" target="-2" id="UUp-pt-ZEd"/>
</connections>
</button>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ytx-MG-kDx">
<rect key="frame" x="72" y="44" width="185" height="19"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="No Error Reporting Mode" id="RKl-Z3-esW">
<font key="font" size="13" name="Menlo-Bold"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" allowsCharacterPickerTouchBarItem="YES" preferredMaxLayoutWidth="471" translatesAutoresizingMaskIntoConstraints="NO" id="Zev-ON-cb3">
<rect key="frame" x="72" y="20" width="475" height="25"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" title="Run without submitting any errors or crash reports." id="kJn-Y0-Gci">
<font key="font" size="13" name="Menlo-Regular"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
<point key="canvasLocation" x="502" y="481.5"/>
</customView>
<customView id="1OV-sl-cSe" userLabel="Update">
<rect key="frame" x="0.0" y="0.0" width="618" height="297"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<button fixedFrame="YES" tag="8" translatesAutoresizingMaskIntoConstraints="NO" id="dml-JS-liI">
<button fixedFrame="YES" tag="9" translatesAutoresizingMaskIntoConstraints="NO" id="dml-JS-liI">
<rect key="frame" x="39" y="245" width="29" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="ljs-bE-JTP">
Expand Down
44 changes: 40 additions & 4 deletions LuLu/App/PrefsWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
// copyright (c) 2017 Objective-See. All rights reserved.
//

@import Sentry;

#import "consts.h"
#import "Update.h"
#import "utilities.h"
Expand Down Expand Up @@ -51,8 +53,11 @@ @implementation PrefsWindowController
//'no-icon mode' button
#define BUTTON_NO_ICON_MODE 7

//'no-icon mode' button
#define BUTTON_NO_ERROR_REPORTING_MODE 8

//'update mode' button
#define BUTTON_NO_UPDATE_MODE 8
#define BUTTON_NO_UPDATE_MODE 9

//init 'general' view
// add it, and make it selected
Expand Down Expand Up @@ -136,6 +141,9 @@ -(IBAction)toolbarButtonHandler:(id)sender
//set 'no icon' button state
((NSButton*)[view viewWithTag:BUTTON_NO_ICON_MODE]).state = [self.preferences[PREF_NO_ICON_MODE] boolValue];

//set 'no error reporting' button state
((NSButton*)[view viewWithTag:BUTTON_NO_ERROR_REPORTING_MODE]).state = [self.preferences[PREF_NO_ERROR_REPORTING] boolValue];

break;

//update
Expand Down Expand Up @@ -219,6 +227,7 @@ -(IBAction)togglePreference:(id)sender

//block mode
case BUTTON_BLOCK_MODE:
updatedPreferences[PREF_BLOCK_MODE] = state;

//enable?
// show alert
Expand All @@ -228,14 +237,43 @@ -(IBAction)togglePreference:(id)sender
showAlert(@"Outgoing traffic will now be blocked.", @"Note however:\r\n▪ Existing connections will not be impacted.\r\n▪ OS traffic (not routed thru LuLu) will not be blocked.");
}

updatedPreferences[PREF_BLOCK_MODE] = state;

break;

//no icon mode
case BUTTON_NO_ICON_MODE:
updatedPreferences[PREF_NO_ICON_MODE] = state;
break;

//no error reporting more
case BUTTON_NO_ERROR_REPORTING_MODE:
updatedPreferences[PREF_NO_ERROR_REPORTING] = state;

//off?
if(NSControlStateValueOn == state.longValue)
{
//dbg msg
os_log_debug(logHandle, "turning off error/crash reporting");

//stop
[SentrySDK close];
}
//on?
else
{
//dbg msg
os_log_debug(logHandle, "turning on error/crash reporting");

//start
[SentrySDK startWithConfigureOptions:^(SentryOptions *options) {
options.dsn = SENTRY_DSN;
options.debug = YES;
}];
}

break;


//no update mode
case BUTTON_NO_UPDATE_MODE:
updatedPreferences[PREF_NO_UPDATE_MODE] = state;
Expand Down Expand Up @@ -292,7 +330,6 @@ -(IBAction)selectBlockList:(id)sender
return;
}


//invoked when block list path is (manually entered)
-(IBAction)updateBlockList:(id)sender
{
Expand Down Expand Up @@ -406,7 +443,6 @@ -(void)updateResponse:(NSInteger)result newVersion:(NSString*)newVersion
break;
}


return;
}

Expand Down
6 changes: 0 additions & 6 deletions LuLu/App/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@ int main(int argc, const char * argv[]) {
//dbg msg(s)
os_log_debug(logHandle, "started: %{public}@ (pid: %d / uid: %d)", NSProcessInfo.processInfo.arguments.firstObject, getpid(), getuid());
os_log_debug(logHandle, "arguments: %{public}@", NSProcessInfo.processInfo.arguments);

//init crash reporting
[SentrySDK startWithConfigureOptions:^(SentryOptions *options) {
options.dsn = SENTRY_DSN;
options.debug = YES;
}];
}

//main app interface
Expand Down
20 changes: 14 additions & 6 deletions LuLu/Extension/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@ int main(int argc, char *argv[])
//dbg msg
os_log_debug(logHandle, "started: %{public}@ (pid: %d / uid: %d)", NSProcessInfo.processInfo.arguments.firstObject, getpid(), getuid());

//init crash reporting
[SentrySDK startWithConfigureOptions:^(SentryOptions *options) {
options.dsn = SENTRY_DSN;
options.debug = YES;
}];

//start sysext
// Apple notes, "call [this] as early as possible"
[NEProvider startSystemExtensionMode];
Expand All @@ -50,6 +44,20 @@ int main(int argc, char *argv[])
//alloc/init/load prefs
preferences = [[Preferences alloc] init];

//init crash reporting
// unless user has turned it off
if(YES != [preferences.preferences[PREF_NO_ERROR_REPORTING] boolValue])
{
//dbg msg
os_log_debug(logHandle, "enabling crash reporting");

//init crash reporting
[SentrySDK startWithConfigureOptions:^(SentryOptions *options) {
options.dsn = SENTRY_DSN;
options.debug = YES;
}];
}

//alloc/init alerts object
alerts = [[Alerts alloc] init];

Expand Down
4 changes: 4 additions & 0 deletions LuLu/Shared/consts.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ enum Signer{None, Apple, AppStore, DevID, AdHoc};
// block mode
#define PREF_BLOCK_MODE @"blockMode"

//prefs
// no error reporting
#define PREF_NO_ERROR_REPORTING @"noErorrReporting"

//prefs
// icon mode
#define PREF_NO_ICON_MODE @"noIconMode"
Expand Down

0 comments on commit 7d8bf18

Please sign in to comment.