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

Commit

Permalink
support tcp, kcp and ws
Browse files Browse the repository at this point in the history
  • Loading branch information
Cenmrev committed Dec 17, 2016
1 parent 9ee2e66 commit cd0d881
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 19 deletions.
2 changes: 1 addition & 1 deletion V2RayX/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ - (NSDictionary*)readDefaultsAsDictionary {
[newProfile setAlterId:[aProfile[@"alterId"] integerValue]];
[newProfile setRemark:aProfile[@"remark"]];
[newProfile setAllowPassive:aProfile[@"allowPassive"]];
[newProfile setUseMkcp:aProfile[@"useMkcp"]];
[newProfile setNetwork:aProfile[@"network"]];
[dProfiles addObject:newProfile];
}
dServerIndex = [defaults objectForKey:@"selectedServerIndex"];
Expand Down
41 changes: 29 additions & 12 deletions V2RayX/ConfigWindow.xib
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11201" systemVersion="16A323" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11762" systemVersion="15G1212" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11201"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11762"/>
<capability name="box content view" minToolsVersion="7.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="ConfigWindowController">
Expand Down Expand Up @@ -323,17 +324,33 @@
<binding destination="-2" name="value" keyPath="self.selectedProfile.allowPassive" id="9Za-En-syg"/>
</connections>
</button>
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="rOT-dn-UUf">
<rect key="frame" x="127" y="18" width="84" height="18"/>
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="tMD-b4-w2E">
<rect key="frame" x="193" y="13" width="95" height="26"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="use mKCP" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="q3a-bh-2eo">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<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">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="menu"/>
<menu key="menu" id="OwV-ph-tBz">
<items>
<menuItem title="tcp" state="on" id="Jhw-Hk-xHQ"/>
<menuItem title="kcp" id="5Eb-2c-mug"/>
<menuItem title="WebSocket" id="PPM-JS-9Su"/>
</items>
</menu>
<connections>
<binding destination="-2" name="selectedIndex" keyPath="self.selectedProfile.network" id="75g-Vf-9I5"/>
</connections>
</popUpButtonCell>
</popUpButton>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="c51-zU-mXj">
<rect key="frame" x="130" y="19" width="59" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Network:" id="Dkz-gS-91s">
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<binding destination="-2" name="value" keyPath="self.selectedProfile.useMkcp" id="2XO-IT-AFS"/>
</connections>
</button>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
</view>
</box>
Expand Down
2 changes: 1 addition & 1 deletion V2RayX/ServerProfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
@property (nonatomic) NSInteger alterId;
@property (nonatomic) NSString* remark;
@property (nonatomic) NSNumber* allowPassive;
@property (nonatomic) NSNumber* useMkcp;
@property (nonatomic) NSNumber* network; //0:tcp, 1:kcp, 2:ws
@end
13 changes: 8 additions & 5 deletions V2RayX/ServerProfile.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ - (ServerProfile*)init {
[self setAlterId:64];
[self setRemark:@"test server"];
[self setAllowPassive:[NSNumber numberWithBool:false]];//does not allow passive as default
[self setUseMkcp:[NSNumber numberWithBool:false]];
[self setNetwork:[NSNumber numberWithInteger:0]];
//[self setUseMkcp:[NSNumber numberWithBool:false]];

}
return self;
Expand All @@ -36,7 +37,7 @@ - (NSDictionary*)dictionaryForm {
@"alterId": [NSNumber numberWithInteger:alterId],
@"remark": remark != nil ? remark : @"",
@"allowPassive": allowPassive,
@"useMkcp": useMkcp};
@"network": network};
}

- (NSDictionary*)v2rayConfigWithLocalPort:(NSInteger)localPort
Expand All @@ -57,9 +58,11 @@ - (NSDictionary*)v2rayConfigWithLocalPort:(NSInteger)localPort
} else {
[config[@"outbound"][@"settings"][@"vnext"][0][@"users"][0] removeObjectForKey:@"alterId"];
}
if ([self.useMkcp boolValue] == true) {
config[@"outbound"][@"streamSettings"] = @{@"network": @[@"tcp", @"kcp", @"ws"][self.network.integerValue]};
/*
if ([self.network boolValue] == true) {
config[@"outbound"][@"streamSettings"] = @{@"network": @"kcp"};
}
}*/
NSArray* dnsArray = [[[NSUserDefaults standardUserDefaults] objectForKey:@"dns"] componentsSeparatedByString:@","];
if ([dnsArray count] > 0) {
config[@"dns"][@"servers"] = dnsArray;
Expand All @@ -75,5 +78,5 @@ - (NSDictionary*)v2rayConfigWithLocalPort:(NSInteger)localPort
@synthesize alterId;
@synthesize remark;
@synthesize allowPassive;
@synthesize useMkcp;
@synthesize network;
@end

0 comments on commit cd0d881

Please sign in to comment.