Set static resolvers from the preferences pane.

This commit is contained in:
Frank Denis
2012-09-24 09:33:38 +02:00
parent e889c387e1
commit 052febc509
5 changed files with 47 additions and 5 deletions
@@ -49,6 +49,7 @@ typedef enum {
@property (nonatomic, retain) IBOutlet WebView *releaseNotesWebView;
@property (nonatomic, retain) IBOutlet WebView *feedbackWebView;
@property (nonatomic, retain) IBOutlet WebView *aboutWebView;
@property (nonatomic, retain) IBOutlet NSTextFieldCell *staticResolversTextField;
- (void) mainViewDidLoad;
@@ -59,5 +60,6 @@ typedef enum {
- (IBAction)openDNSLinkPushed:(NSButton *)sender;
- (IBAction)uninstallPushed:(NSButton *)sender;
- (IBAction)staticResolversTextFieldChanged:(NSTextField *)sender;
@end
+11 -2
View File
@@ -12,12 +12,11 @@
@synthesize tabView = _tabView;
@synthesize aboutTabViewItem = _aboutTabViewItem;
@synthesize releaseNotesTabViewItem = _releaseNotesTabViewItem;
@synthesize previewNotesWebView = _previewNotesWebView;
@synthesize releaseNotesWebView = _releaseNotesWebView;
@synthesize feedbackWebView = _feedbackWebView;
@synthesize aboutWebView = _aboutWebView;
@synthesize staticResolversTextField = _staticResolversTextField;
@synthesize dnscryptButton = _dnscryptButton;
@synthesize opendnsButton = _opendnsButton;
@synthesize fallbackButton = _fallbackButton;
@@ -82,6 +81,8 @@ DNSConfigurationState currentState = kDNS_CONFIGURATION_UNKNOWN;
if ([res isEqualToString: @"yes"]) {
[_fallbackButton setState: 1];
}
res = [self fromCommand: @"/bin/ksh" withArguments: [NSArray arrayWithObjects: @"-c", @"cd '" kDNSCRIPT_SCRIPTS_BASE_DIR @"' && exec ./get-static-resolvers.sh", nil]];
[_staticResolversTextField setStringValue: res];
}
- (void) updateLedStatus
@@ -346,5 +347,13 @@ DNSConfigurationState currentState = kDNS_CONFIGURATION_UNKNOWN;
[self fromCommand: @"/bin/ksh" withArguments: [NSArray arrayWithObjects: @"-c", @"cd '" kDNSCRIPT_BIN_BASE_DIR @"' && /usr/bin/open ./Uninstall.app", nil]];
}
- (IBAction)staticResolversTextFieldChanged:(NSTextField *)sender {
NSString *staticResolvers = sender.stringValue;
NSCharacterSet *charset = [[NSCharacterSet characterSetWithCharactersInString: @"0123456789abcdefABCDEF:. "] invertedSet];
staticResolvers = [[staticResolvers componentsSeparatedByCharactersInSet: charset] componentsJoinedByString: @" "];
sender.stringValue = staticResolvers;
setenv("STATIC_RESOLVERS", [staticResolvers UTF8String], 1);
[self fromCommand: @"/bin/ksh" withArguments: [NSArray arrayWithObjects: @"-c", @"cd '" kDNSCRIPT_SCRIPTS_BASE_DIR @"' && exec ./set-static-resolvers.sh \"$STATIC_RESOLVERS\"", staticResolvers, nil]];
}
@end
@@ -842,7 +842,7 @@ aW91cy5leGFtcGxlLm5ldA</string>
<string key="NSFrame">{{511, 0}, {25, 25}}</string>
<reference key="NSSuperview" ref="42710935"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<reference key="NSNextKeyView" ref="821865429"/>
<string key="NSReuseIdentifierKey">_NS:1598</string>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="933364045">
@@ -1328,6 +1328,22 @@ aW91cy5leGFtcGxlLm5ldA</string>
</object>
<int key="connectionID">422</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">staticResolversTextFieldChanged:</string>
<reference key="source" ref="294453543"/>
<reference key="destination" ref="1038497103"/>
</object>
<int key="connectionID">432</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">staticResolversTextField</string>
<reference key="source" ref="294453543"/>
<reference key="destination" ref="684654118"/>
</object>
<int key="connectionID">433</int>
</object>
</array>
<object class="IBMutableOrderedSet" key="objectRecords">
<array key="orderedObjects">
@@ -2047,7 +2063,7 @@ aW91cy5leGFtcGxlLm5ldA</string>
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">429</int>
<int key="maxID">433</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -2060,6 +2076,7 @@ aW91cy5leGFtcGxlLm5ldA</string>
<string key="familyShieldButtonPressed:">NSButton</string>
<string key="openDNSLinkPushed:">NSButton</string>
<string key="opendnsButtonPressed:">NSButton</string>
<string key="staticResolversTextFieldChanged:">NSTextField</string>
<string key="uninstallPushed:">NSButton</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="actionInfosByName">
@@ -2083,6 +2100,10 @@ aW91cy5leGFtcGxlLm5ldA</string>
<string key="name">opendnsButtonPressed:</string>
<string key="candidateClassName">NSButton</string>
</object>
<object class="IBActionInfo" key="staticResolversTextFieldChanged:">
<string key="name">staticResolversTextFieldChanged:</string>
<string key="candidateClassName">NSTextField</string>
</object>
<object class="IBActionInfo" key="uninstallPushed:">
<string key="name">uninstallPushed:</string>
<string key="candidateClassName">NSButton</string>
@@ -2100,6 +2121,7 @@ aW91cy5leGFtcGxlLm5ldA</string>
<string key="previewNotesWebView">WebView</string>
<string key="releaseNotesTabViewItem">NSTabViewItem</string>
<string key="releaseNotesWebView">WebView</string>
<string key="staticResolversTextField">NSTextFieldCell</string>
<string key="statusImageView">NSImageView</string>
<string key="statusText">NSTextField</string>
<string key="tabView">NSTabView</string>
@@ -2149,6 +2171,10 @@ aW91cy5leGFtcGxlLm5ldA</string>
<string key="name">releaseNotesWebView</string>
<string key="candidateClassName">WebView</string>
</object>
<object class="IBToOneOutletInfo" key="staticResolversTextField">
<string key="name">staticResolversTextField</string>
<string key="candidateClassName">NSTextFieldCell</string>
</object>
<object class="IBToOneOutletInfo" key="statusImageView">
<string key="name">statusImageView</string>
<string key="candidateClassName">NSImageView</string>
@@ -0,0 +1,5 @@
#! /bin/sh
. ./common.inc
[ -r "$STATIC_RESOLVERS_FILE" ] && cat "$STATIC_RESOLVERS_FILE"
@@ -13,5 +13,5 @@ done
if [ "$servers" = "" ]; then
rm -f "$STATIC_RESOLVERS_FILE"
else
echo "$servers" > "$STATIC_RESOLVERS_FILE"
echo "$servers" | sed 's/^ *//;s/ *$//' > "$STATIC_RESOLVERS_FILE"
fi