This repository was archived by the owner on Jan 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,11 @@ - (void)windowDidLoad {
2929 NSDictionary *defaultsDic = [[self delegate ] readDefaultsAsDictionary ];
3030 [self setLocalPort: [defaultsDic[@" localPort" ] integerValue ]];
3131 [self setUdpSupport: [defaultsDic[@" udpSupport" ] boolValue ]];
32- [self setDnsString: defaultsDic[@" dns" ]];
32+ if ([defaultsDic[@" dns" ] length ] > 0 ) {
33+ [self setDnsString: defaultsDic[@" dns" ]];
34+ } else {
35+ [self setDnsString: @" localhost" ];
36+ }
3337 profiles = defaultsDic[@" profiles" ];
3438 [_profileTable reloadData ];
3539 _selectedServerIndex = [defaultsDic[@" selectedServerIndex" ] integerValue ];
@@ -104,7 +108,11 @@ - (IBAction)okSave:(id)sender {
104108 }
105109 [defaults setObject: profileDicArray forKey: @" profiles" ];
106110 [defaults setObject: [NSNumber numberWithInteger: _selectedServerIndex] forKey: @" selectedServerIndex" ];
107- [defaults setObject: [[_dnsField stringValue ] stringByReplacingOccurrencesOfString: @" " withString: @" " ] forKey: @" dns" ];
111+ NSString * dnsStr = [[_dnsField stringValue ] stringByReplacingOccurrencesOfString: @" " withString: @" " ];
112+ if ([dnsStr length ] == 0 ) {
113+ dnsStr = @" localhost" ;
114+ }
115+ [defaults setObject: dnsStr forKey: @" dns" ];
108116 [[self delegate ] configurationDidChange ];
109117 [[self window ] close ];
110118}
Original file line number Diff line number Diff line change @@ -63,6 +63,8 @@ - (NSDictionary*)v2rayConfigWithLocalPort:(NSInteger)localPort
6363 NSArray * dnsArray = [[[NSUserDefaults standardUserDefaults ] objectForKey: @" dns" ] componentsSeparatedByString: @" ," ];
6464 if ([dnsArray count ] > 0 ) {
6565 config[@" dns" ][@" servers" ] = dnsArray;
66+ } else {
67+ config[@" dns" ][@" servers" ] = @[@" localhost" ];
6668 }
6769 return config;
6870}
You can’t perform that action at this time.
0 commit comments