Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Commit b0c1818

Browse files
committed
add server name, fix #33; add auto security mode
1 parent 1873b16 commit b0c1818

File tree

6 files changed

+49
-15
lines changed

6 files changed

+49
-15
lines changed

V2RayX/AppDelegate.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ - (void) writeDefaultSettings {
9999
@"dns": @"localhost",
100100
@"useTLS": [NSNumber numberWithBool:NO],
101101
@"tlsSettings": @{
102-
@"allowInsecure": [NSNumber numberWithBool:NO]
102+
@"allowInsecure": [NSNumber numberWithBool:NO],
103+
@"serverName": @""
103104
},
104105
@"profiles":@[
105106
@{

V2RayX/ConfigWindow.xib

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="12121" systemVersion="16G29" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
2+
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13196" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
33
<dependencies>
44
<deployment identifier="macosx"/>
5-
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="12121"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13196"/>
66
<capability name="box content view" minToolsVersion="7.0"/>
77
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
88
</dependencies>
@@ -149,7 +149,7 @@
149149
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
150150
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
151151
<tableColumns>
152-
<tableColumn width="135" minWidth="40" maxWidth="1000" id="KrX-3H-19h">
152+
<tableColumn identifier="" width="135" minWidth="40" maxWidth="1000" id="KrX-3H-19h">
153153
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" title="Server list">
154154
<font key="font" metaFont="smallSystem"/>
155155
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
@@ -386,6 +386,9 @@
386386
<menuItem title="aes-128-cfb(default)" state="on" id="max-qR-nJy"/>
387387
<menuItem title="aes-128-gcm" id="92F-Fh-RHW"/>
388388
<menuItem title="chacha20-poly1305" id="1SH-Qb-KKl"/>
389+
<menuItem title="auto" id="clS-ih-hzy">
390+
<modifierMask key="keyEquivalentModifierMask"/>
391+
</menuItem>
389392
</items>
390393
</menu>
391394
</popUpButtonCell>
@@ -467,7 +470,7 @@ Gw
467470
<binding destination="-2" name="value" keyPath="self.shareOverLan" id="eeF-vl-cmx"/>
468471
</connections>
469472
</button>
470-
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" allowsCharacterPickerTouchBarItem="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Jbe-gs-AvT">
473+
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Jbe-gs-AvT">
471474
<rect key="frame" x="18" y="375" width="100" height="17"/>
472475
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
473476
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Local Http Port:" id="eGi-xf-mFk">

V2RayX/ConfigWindowController.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
//tls fields
5050
@property (weak) IBOutlet NSButton *tlsUseButton;
5151
@property (weak) IBOutlet NSButton *tlsAiButton;
52+
@property (weak) IBOutlet NSTextField *tlsSnField;
53+
5254
//mux fields
5355
@property (weak) IBOutlet NSButton *muxEnableButton;
5456
@property (weak) IBOutlet NSTextField *muxConcurrencyField;

V2RayX/ConfigWindowController.m

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ - (IBAction)showtransportSettings:(id)sender {
167167
[_tlsUseButton setState:[[[NSUserDefaults standardUserDefaults] objectForKey:@"useTLS"] boolValue]];
168168
NSDictionary* tlsSettings = [[NSUserDefaults standardUserDefaults] objectForKey:@"tlsSettings"];
169169
[_tlsAiButton setState:[tlsSettings[@"allowInsecure"] boolValue]];
170+
if (tlsSettings[@"serverName"]) {
171+
[_tlsSnField setStringValue:tlsSettings[@"serverName"]];
172+
}
170173
[self useTLS:nil];
171174
// mux
172175
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
@@ -240,7 +243,10 @@ - (IBAction)tOK:(id)sender {
240243
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
241244
[defaults setObject:transportSettings forKey:@"transportSettings"];
242245
[defaults setObject:[NSNumber numberWithBool:[_tlsUseButton state]] forKey:@"useTLS"];
243-
[defaults setObject:@{@"allowInsecure": [NSNumber numberWithBool:[_tlsAiButton state]]} forKey:@"tlsSettings"];
246+
[defaults setObject:@{
247+
@"allowInsecure": [NSNumber numberWithBool:[_tlsAiButton state]],
248+
@"serverName": [_tlsSnField stringValue]
249+
} forKey:@"tlsSettings"];
244250
[defaults setObject:@{@"enable":[NSNumber numberWithBool:[_muxEnableButton state]],
245251
@"concurrency":[NSNumber numberWithInteger:[_muxConcurrencyField integerValue]]
246252
} forKey:@"mux"];
@@ -252,6 +258,7 @@ - (IBAction)tOK:(id)sender {
252258

253259
- (IBAction)useTLS:(id)sender {
254260
[_tlsAiButton setEnabled:[_tlsUseButton state]];
261+
[_tlsSnField setEnabled:[_tlsUseButton state]];
255262
}
256263

257264
- (IBAction)transportHelp:(id)sender {

V2RayX/ServerProfile.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#import "ServerProfile.h"
99

10+
#define N_Securities 4
11+
1012
@implementation ServerProfile
1113

1214
- (ServerProfile*)init {
@@ -60,7 +62,7 @@ - (NSDictionary*)v2rayConfigWithRules:(BOOL)rules
6062
config[@"outbound"][@"settings"][@"vnext"][0][@"port"] = self.port;
6163
config[@"outbound"][@"settings"][@"vnext"][0][@"users"][0][@"id"] = self.userId;
6264
config[@"outbound"][@"settings"][@"vnext"][0][@"users"][0][@"alterId"] = self.alterId;
63-
config[@"outbound"][@"settings"][@"vnext"][0][@"users"][0][@"security"] = @[@"aes-128-cfb", @"aes-128-gcm", @"chacha20-poly1305"][self.security.integerValue % 3];
65+
config[@"outbound"][@"settings"][@"vnext"][0][@"users"][0][@"security"] = @[@"aes-128-cfb", @"aes-128-gcm", @"chacha20-poly1305", @"auto"][self.security.integerValue % N_Securities];
6466
NSMutableDictionary* streamSettings = [[userDefaults objectForKey:@"transportSettings"] mutableCopy];
6567
streamSettings[@"network"] = @[@"tcp", @"kcp", @"ws"][self.network.integerValue % 3];
6668
streamSettings[@"security"] = [[userDefaults objectForKey:@"useTLS"] boolValue] ? @"tls" : @"none";

V2RayX/transportWindow.xib

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="12121" systemVersion="16G29" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
2+
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13196" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
33
<dependencies>
44
<deployment identifier="macosx"/>
5-
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="12121"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13196"/>
66
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
77
</dependencies>
88
<objects>
@@ -21,6 +21,7 @@
2121
<outlet property="tcpCrButton" destination="Gzt-Qt-jT8" id="vFQ-Ca-pH1"/>
2222
<outlet property="tcpHeaderTypeButton" destination="6Hk-Q4-cbb" id="6aw-lM-kYs"/>
2323
<outlet property="tlsAiButton" destination="l3Z-uk-KBr" id="FUU-TQ-bqK"/>
24+
<outlet property="tlsSnField" destination="nw2-5m-34B" id="8nF-Yj-QgG"/>
2425
<outlet property="tlsUseButton" destination="n0X-Fy-rS1" id="8sl-p5-7bG"/>
2526
<outlet property="transportWindow" destination="QvC-M9-y7g" id="EGp-nT-Eil"/>
2627
<outlet property="wsCrButton" destination="fln-bY-kje" id="h5k-Fz-q6g"/>
@@ -44,7 +45,7 @@
4445
<font key="font" metaFont="system"/>
4546
<tabViewItems>
4647
<tabViewItem label="KCP" identifier="1" id="jR2-p0-bjc">
47-
<view key="view" ambiguous="YES" id="GiR-b0-lvV">
48+
<view key="view" id="GiR-b0-lvV">
4849
<rect key="frame" x="10" y="33" width="419" height="135"/>
4950
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
5051
<subviews>
@@ -283,20 +284,20 @@
283284
</view>
284285
</tabViewItem>
285286
<tabViewItem label="TLS" identifier="" id="sCQ-Dt-YCG">
286-
<view key="view" id="yce-Q2-W28">
287+
<view key="view" ambiguous="YES" id="yce-Q2-W28">
287288
<rect key="frame" x="10" y="33" width="419" height="135"/>
288289
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
289290
<subviews>
290291
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="l3Z-uk-KBr">
291-
<rect key="frame" x="15" y="45" width="110" height="18"/>
292+
<rect key="frame" x="15" y="63" width="110" height="18"/>
292293
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
293294
<buttonCell key="cell" type="check" title="Allow insecure" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="Rxl-Fh-p8u">
294295
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
295296
<font key="font" metaFont="system"/>
296297
</buttonCell>
297298
</button>
298299
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="n0X-Fy-rS1">
299-
<rect key="frame" x="15" y="80" width="73" height="18"/>
300+
<rect key="frame" x="15" y="98" width="73" height="18"/>
300301
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
301302
<buttonCell key="cell" type="check" title="Use TLS" bezelStyle="regularSquare" imagePosition="left" alignment="left" state="on" inset="2" id="cY9-cQ-T9f">
302303
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
@@ -306,6 +307,24 @@
306307
<action selector="useTLS:" target="-2" id="bwQ-Hn-WsG"/>
307308
</connections>
308309
</button>
310+
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Nhc-Gl-Mct">
311+
<rect key="frame" x="15" y="27" width="87" height="17"/>
312+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
313+
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Server Name:" id="eb7-WI-WKe">
314+
<font key="font" metaFont="system"/>
315+
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
316+
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
317+
</textFieldCell>
318+
</textField>
319+
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="nw2-5m-34B">
320+
<rect key="frame" x="108" y="25" width="213" height="22"/>
321+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
322+
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="573-7w-T3E">
323+
<font key="font" metaFont="system"/>
324+
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
325+
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
326+
</textFieldCell>
327+
</textField>
309328
</subviews>
310329
</view>
311330
</tabViewItem>
@@ -322,7 +341,7 @@
322341
<font key="font" metaFont="system"/>
323342
</buttonCell>
324343
</button>
325-
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" allowsCharacterPickerTouchBarItem="NO" translatesAutoresizingMaskIntoConstraints="NO" id="0xa-QH-JSG">
344+
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="0xa-QH-JSG">
326345
<rect key="frame" x="28" y="51" width="84" height="17"/>
327346
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
328347
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="concurrency:" id="V4v-kP-BDQ">
@@ -331,7 +350,7 @@
331350
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
332351
</textFieldCell>
333352
</textField>
334-
<textField verticalHuggingPriority="750" fixedFrame="YES" allowsCharacterPickerTouchBarItem="NO" translatesAutoresizingMaskIntoConstraints="NO" id="L11-Bf-Eib">
353+
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="L11-Bf-Eib">
335354
<rect key="frame" x="118" y="48" width="96" height="22"/>
336355
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
337356
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="UVv-qh-s3w">

0 commit comments

Comments
 (0)