This repository was archived by the owner on Jan 12, 2024. It is now read-only.
File tree 2 files changed +12
-2
lines changed
2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,11 @@ - (void)windowDidLoad {
29
29
NSDictionary *defaultsDic = [[self delegate ] readDefaultsAsDictionary ];
30
30
[self setLocalPort: [defaultsDic[@" localPort" ] integerValue ]];
31
31
[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
+ }
33
37
profiles = defaultsDic[@" profiles" ];
34
38
[_profileTable reloadData ];
35
39
_selectedServerIndex = [defaultsDic[@" selectedServerIndex" ] integerValue ];
@@ -104,7 +108,11 @@ - (IBAction)okSave:(id)sender {
104
108
}
105
109
[defaults setObject: profileDicArray forKey: @" profiles" ];
106
110
[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" ];
108
116
[[self delegate ] configurationDidChange ];
109
117
[[self window ] close ];
110
118
}
Original file line number Diff line number Diff line change @@ -63,6 +63,8 @@ - (NSDictionary*)v2rayConfigWithLocalPort:(NSInteger)localPort
63
63
NSArray * dnsArray = [[[NSUserDefaults standardUserDefaults ] objectForKey: @" dns" ] componentsSeparatedByString: @" ," ];
64
64
if ([dnsArray count ] > 0 ) {
65
65
config[@" dns" ][@" servers" ] = dnsArray;
66
+ } else {
67
+ config[@" dns" ][@" servers" ] = @[@" localhost" ];
66
68
}
67
69
return config;
68
70
}
You can’t perform that action at this time.
0 commit comments