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

Commit cd0d881

Browse files
committed
support tcp, kcp and ws
1 parent 9ee2e66 commit cd0d881

File tree

4 files changed

+39
-19
lines changed

4 files changed

+39
-19
lines changed

V2RayX/AppDelegate.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ - (NSDictionary*)readDefaultsAsDictionary {
218218
[newProfile setAlterId:[aProfile[@"alterId"] integerValue]];
219219
[newProfile setRemark:aProfile[@"remark"]];
220220
[newProfile setAllowPassive:aProfile[@"allowPassive"]];
221-
[newProfile setUseMkcp:aProfile[@"useMkcp"]];
221+
[newProfile setNetwork:aProfile[@"network"]];
222222
[dProfiles addObject:newProfile];
223223
}
224224
dServerIndex = [defaults objectForKey:@"selectedServerIndex"];

V2RayX/ConfigWindow.xib

+29-12
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11201" systemVersion="16A323" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11762" systemVersion="15G1212" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
33
<dependencies>
44
<deployment identifier="macosx"/>
5-
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11201"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11762"/>
66
<capability name="box content view" minToolsVersion="7.0"/>
7+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
78
</dependencies>
89
<objects>
910
<customObject id="-2" userLabel="File's Owner" customClass="ConfigWindowController">
@@ -323,17 +324,33 @@
323324
<binding destination="-2" name="value" keyPath="self.selectedProfile.allowPassive" id="9Za-En-syg"/>
324325
</connections>
325326
</button>
326-
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="rOT-dn-UUf">
327-
<rect key="frame" x="127" y="18" width="84" height="18"/>
327+
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="tMD-b4-w2E">
328+
<rect key="frame" x="193" y="13" width="95" height="26"/>
328329
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
329-
<buttonCell key="cell" type="check" title="use mKCP" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="q3a-bh-2eo">
330-
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
330+
<popUpButtonCell key="cell" type="push" title="tcp" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="Jhw-Hk-xHQ" id="07T-9g-FQm">
331+
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
332+
<font key="font" metaFont="menu"/>
333+
<menu key="menu" id="OwV-ph-tBz">
334+
<items>
335+
<menuItem title="tcp" state="on" id="Jhw-Hk-xHQ"/>
336+
<menuItem title="kcp" id="5Eb-2c-mug"/>
337+
<menuItem title="WebSocket" id="PPM-JS-9Su"/>
338+
</items>
339+
</menu>
340+
<connections>
341+
<binding destination="-2" name="selectedIndex" keyPath="self.selectedProfile.network" id="75g-Vf-9I5"/>
342+
</connections>
343+
</popUpButtonCell>
344+
</popUpButton>
345+
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="c51-zU-mXj">
346+
<rect key="frame" x="130" y="19" width="59" height="17"/>
347+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
348+
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Network:" id="Dkz-gS-91s">
331349
<font key="font" metaFont="system"/>
332-
</buttonCell>
333-
<connections>
334-
<binding destination="-2" name="value" keyPath="self.selectedProfile.useMkcp" id="2XO-IT-AFS"/>
335-
</connections>
336-
</button>
350+
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
351+
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
352+
</textFieldCell>
353+
</textField>
337354
</subviews>
338355
</view>
339356
</box>

V2RayX/ServerProfile.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@
1818
@property (nonatomic) NSInteger alterId;
1919
@property (nonatomic) NSString* remark;
2020
@property (nonatomic) NSNumber* allowPassive;
21-
@property (nonatomic) NSNumber* useMkcp;
21+
@property (nonatomic) NSNumber* network; //0:tcp, 1:kcp, 2:ws
2222
@end

V2RayX/ServerProfile.m

+8-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ - (ServerProfile*)init {
1919
[self setAlterId:64];
2020
[self setRemark:@"test server"];
2121
[self setAllowPassive:[NSNumber numberWithBool:false]];//does not allow passive as default
22-
[self setUseMkcp:[NSNumber numberWithBool:false]];
22+
[self setNetwork:[NSNumber numberWithInteger:0]];
23+
//[self setUseMkcp:[NSNumber numberWithBool:false]];
2324

2425
}
2526
return self;
@@ -36,7 +37,7 @@ - (NSDictionary*)dictionaryForm {
3637
@"alterId": [NSNumber numberWithInteger:alterId],
3738
@"remark": remark != nil ? remark : @"",
3839
@"allowPassive": allowPassive,
39-
@"useMkcp": useMkcp};
40+
@"network": network};
4041
}
4142

4243
- (NSDictionary*)v2rayConfigWithLocalPort:(NSInteger)localPort
@@ -57,9 +58,11 @@ - (NSDictionary*)v2rayConfigWithLocalPort:(NSInteger)localPort
5758
} else {
5859
[config[@"outbound"][@"settings"][@"vnext"][0][@"users"][0] removeObjectForKey:@"alterId"];
5960
}
60-
if ([self.useMkcp boolValue] == true) {
61+
config[@"outbound"][@"streamSettings"] = @{@"network": @[@"tcp", @"kcp", @"ws"][self.network.integerValue]};
62+
/*
63+
if ([self.network boolValue] == true) {
6164
config[@"outbound"][@"streamSettings"] = @{@"network": @"kcp"};
62-
}
65+
}*/
6366
NSArray* dnsArray = [[[NSUserDefaults standardUserDefaults] objectForKey:@"dns"] componentsSeparatedByString:@","];
6467
if ([dnsArray count] > 0) {
6568
config[@"dns"][@"servers"] = dnsArray;
@@ -75,5 +78,5 @@ - (NSDictionary*)v2rayConfigWithLocalPort:(NSInteger)localPort
7578
@synthesize alterId;
7679
@synthesize remark;
7780
@synthesize allowPassive;
78-
@synthesize useMkcp;
81+
@synthesize network;
7982
@end

0 commit comments

Comments
 (0)