From 6ca7749d9bea3bddfea15c49dce333a2f892c6c9 Mon Sep 17 00:00:00 2001 From: Alter Step Date: Tue, 28 Jul 2015 00:01:03 +0200 Subject: [PATCH] Add a button to the preference pane to disable ipv6 --- DNSCrypt-Preference-Pane/DNSCrypt/DNSCrypt.h | 3 + DNSCrypt-Preference-Pane/DNSCrypt/DNSCrypt.m | 29 ++++++++ .../DNSCrypt/en.lproj/DNSCrypt.xib | 72 ++++++++++++++++--- .../usr/scripts/get-aaaa-blocking-status.sh | 9 +++ 4 files changed, 103 insertions(+), 10 deletions(-) create mode 100755 DNSCrypt-Preference-Pane/DNSCrypt/extra/usr/scripts/get-aaaa-blocking-status.sh diff --git a/DNSCrypt-Preference-Pane/DNSCrypt/DNSCrypt.h b/DNSCrypt-Preference-Pane/DNSCrypt/DNSCrypt.h index a452188..ee4d5bf 100644 --- a/DNSCrypt-Preference-Pane/DNSCrypt/DNSCrypt.h +++ b/DNSCrypt-Preference-Pane/DNSCrypt/DNSCrypt.h @@ -38,6 +38,7 @@ typedef enum { NSButton *_dnscryptButton; NSButton *_fallbackButton; + NSButton *_disableIPv6Button; NSTextField *_currentResolverTextField; NSImageView *_statusImageView; @@ -59,6 +60,7 @@ typedef enum { @property (nonatomic, strong) IBOutlet NSButton *dnscryptButton; @property (nonatomic, strong) IBOutlet NSButton *fallbackButton; +@property (nonatomic, strong) IBOutlet NSButton *disableIPv6Button; @property (nonatomic, strong) IBOutlet NSTextField *currentResolverTextField; @property (nonatomic, strong) IBOutlet NSImageView *statusImageView; @@ -84,6 +86,7 @@ typedef enum { - (IBAction)dnscryptButtonPressed:(NSButton *)sender; - (IBAction)fallbackButtonPressed:(NSButton *)sender; +- (IBAction)disableIPv6ButtonPressed:(NSButton *)sender; - (IBAction)providerLinkPushed:(NSButton *)sender; - (IBAction)uninstallPushed:(NSButton *)sender; diff --git a/DNSCrypt-Preference-Pane/DNSCrypt/DNSCrypt.m b/DNSCrypt-Preference-Pane/DNSCrypt/DNSCrypt.m index abe9c22..f82ea22 100644 --- a/DNSCrypt-Preference-Pane/DNSCrypt/DNSCrypt.m +++ b/DNSCrypt-Preference-Pane/DNSCrypt/DNSCrypt.m @@ -16,6 +16,7 @@ @synthesize exceptionsTextField = _exceptionsTextField; @synthesize dnscryptButton = _dnscryptButton; @synthesize fallbackButton = _fallbackButton; +@synthesize disableIPv6Button = _disableIPv6Button; @synthesize statusImageView = _statusImageView; @synthesize statusText = _statusText; @synthesize currentResolverTextField = _currentResolverTextField; @@ -55,6 +56,7 @@ NSArray *resolversList; _dnscryptButton.state = 0; _fallbackButton.state = 0; + _disableIPv6Button.state = 0; res = [self fromCommand: @"/bin/csh" withArguments: [NSArray arrayWithObjects: @"-c", @"cd '" kDNSCRIPT_SCRIPTS_BASE_DIR @"' && exec ./get-dnscrypt-status.sh", nil]]; if ([res isEqualToString: @"yes"]) { @@ -64,6 +66,10 @@ NSArray *resolversList; if ([res isEqualToString: @"yes"]) { [_fallbackButton setState: 1]; } + res = [self fromCommand: @"/bin/csh" withArguments: [NSArray arrayWithObjects: @"-c", @"cd '" kDNSCRIPT_SCRIPTS_BASE_DIR @"' && exec ./get-aaaa-blocking-status.sh", nil]]; + if ([res isEqualToString: @"yes"]) { + [_disableIPv6Button setState: 1]; + } res = [self fromCommand: @"/bin/csh" withArguments: [NSArray arrayWithObjects: @"-c", @"cd '" kDNSCRIPT_SCRIPTS_BASE_DIR @"' && exec ./get-static-resolvers.sh", nil]]; [_staticResolversTextField setStringValue: res]; res = [self fromCommand: @"/bin/csh" withArguments: [NSArray arrayWithObjects: @"-c", @"cd '" kDNSCRIPT_SCRIPTS_BASE_DIR @"' && exec ./get-query-logging-status.sh", nil]]; @@ -202,6 +208,20 @@ NSArray *resolversList; return TRUE; } +- (BOOL) setDisableIPv6On { + [self showSpinners]; + NSString *res = [self fromCommand: @"/bin/csh" withArguments: [NSArray arrayWithObjects: @"-c", @"cd '" kDNSCRIPT_SCRIPTS_BASE_DIR @"' && ./create-ticket.sh && ./switch-aaaa-blocking-on.sh", nil]]; + (void) res; + return TRUE; +} + +- (BOOL) setDisableIPv6Off { + [self showSpinners]; + NSString *res = [self fromCommand: @"/bin/csh" withArguments: [NSArray arrayWithObjects: @"-c", @"cd '" kDNSCRIPT_SCRIPTS_BASE_DIR @"' && ./create-ticket.sh && ./switch-aaaa-blocking-off.sh", nil]]; + (void) res; + return TRUE; +} + - (IBAction)dnscryptButtonPressed:(NSButton *)sender { if (sender.state != 0) { @@ -220,6 +240,15 @@ NSArray *resolversList; } } +- (IBAction)disableIPv6ButtonPressed:(NSButton *)sender +{ + if (sender.state != 0) { + [self setDisableIPv6On]; + } else { + [self setDisableIPv6Off]; + } +} + - (void) waitForUpdate { NSString *res; static unsigned int tries; diff --git a/DNSCrypt-Preference-Pane/DNSCrypt/en.lproj/DNSCrypt.xib b/DNSCrypt-Preference-Pane/DNSCrypt/en.lproj/DNSCrypt.xib index ba15215..d33527b 100644 --- a/DNSCrypt-Preference-Pane/DNSCrypt/en.lproj/DNSCrypt.xib +++ b/DNSCrypt-Preference-Pane/DNSCrypt/en.lproj/DNSCrypt.xib @@ -1,9 +1,9 @@ - + - - - + + + @@ -15,6 +15,7 @@ + @@ -33,8 +34,8 @@ - - + + @@ -47,6 +48,7 @@ + @@ -57,6 +59,7 @@ - + + @@ -166,6 +180,7 @@ + @@ -175,6 +190,7 @@ + @@ -191,7 +207,22 @@ + + @@ -202,6 +233,7 @@ + @@ -211,6 +243,7 @@ + @@ -227,6 +260,7 @@ + @@ -396,16 +445,19 @@ ads.* + + + diff --git a/DNSCrypt-Preference-Pane/DNSCrypt/extra/usr/scripts/get-aaaa-blocking-status.sh b/DNSCrypt-Preference-Pane/DNSCrypt/extra/usr/scripts/get-aaaa-blocking-status.sh new file mode 100755 index 0000000..e4f17f7 --- /dev/null +++ b/DNSCrypt-Preference-Pane/DNSCrypt/extra/usr/scripts/get-aaaa-blocking-status.sh @@ -0,0 +1,9 @@ +#! /bin/sh + +. ./common.inc + +if [ -e "$AAAA_BLOCKING_FILE" ]; then + echo 'yes' +else + echo 'no' +fi