Skip to content

Commit 34f9f73

Browse files
authored
Merge pull request #15 from Narakuku/master
Add VLESS/XTLS support in GUI thank @Narakuku
2 parents e29cc5e + f3becd1 commit 34f9f73

11 files changed

+304
-195
lines changed

V2RayX/AdvancedWindow.xib

+6-6
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="19455" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
2+
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="20037" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
33
<dependencies>
44
<deployment identifier="macosx"/>
5-
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="19455"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="20037"/>
66
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
77
</dependencies>
88
<objects>
@@ -62,7 +62,7 @@
6262
<windowStyleMask key="styleMask" titled="YES" closable="YES"/>
6363
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
6464
<rect key="contentRect" x="196" y="240" width="540" height="455"/>
65-
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1025"/>
65+
<rect key="screenRect" x="0.0" y="0.0" width="2240" height="1235"/>
6666
<view key="contentView" wantsLayer="YES" id="EiT-Mj-1SZ">
6767
<rect key="frame" x="0.0" y="0.0" width="540" height="455"/>
6868
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
@@ -247,7 +247,7 @@ Gw
247247
</subviews>
248248
</clipView>
249249
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="Foc-Ri-DSS">
250-
<rect key="frame" x="1" y="-15" width="0.0" height="16"/>
250+
<rect key="frame" x="1" y="251" width="420" height="16"/>
251251
<autoresizingMask key="autoresizingMask"/>
252252
</scroller>
253253
<scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="ebi-F0-0yH">
@@ -1063,7 +1063,7 @@ will match all private IPs.</string>
10631063
<autoresizingMask key="autoresizingMask"/>
10641064
<clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="RDn-zh-dIS">
10651065
<rect key="frame" x="0.0" y="0.0" width="260" height="133"/>
1066-
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
1066+
<autoresizingMask key="autoresizingMask"/>
10671067
<subviews>
10681068
<textView importsGraphics="NO" richText="NO" verticallyResizable="YES" spellingCorrection="YES" smartInsertDelete="YES" id="1mD-il-bEM">
10691069
<rect key="frame" x="0.0" y="0.0" width="260" height="133"/>
@@ -1131,7 +1131,7 @@ Gw
11311131
<autoresizingMask key="autoresizingMask"/>
11321132
<clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="jPy-Y0-jqx">
11331133
<rect key="frame" x="0.0" y="0.0" width="260" height="133"/>
1134-
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
1134+
<autoresizingMask key="autoresizingMask"/>
11351135
<subviews>
11361136
<textView importsGraphics="NO" richText="NO" verticallyResizable="YES" spellingCorrection="YES" smartInsertDelete="YES" id="3kN-VI-6Jc">
11371137
<rect key="frame" x="0.0" y="0.0" width="260" height="133"/>

V2RayX/ConfigImporter.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ + (ServerProfile*)importFromVLESSOfXray:(NSString*)vlessStr {
455455
// }
456456

457457
ServerProfile* newProfile = [[ServerProfile alloc] init];
458-
newProfile.protocol = @"vless";
458+
newProfile.protocol = vless;
459459
newProfile.outboundTag = nilCoalescing([url fragment], @"VLESS");
460460
newProfile.address = nilCoalescing([url host], @"");
461461
newProfile.port = [nilCoalescing([url port], @0) intValue];

V2RayX/ConfigWindow.xib

+181-126
Large diffs are not rendered by default.

V2RayX/ServerProfile.h

+30-14
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,28 @@
99
#import "AppDelegate.h"
1010
#import "utilities.h"
1111

12+
typedef enum ProtocolType : NSUInteger {
13+
vmess,
14+
vless
15+
} ProtocolType;
16+
1217
typedef enum SecurityType : NSUInteger {
13-
auto_,
18+
none_security,
19+
auto_security,
1420
aes_128_gcm,
15-
chacha20_poly130,
16-
none
21+
chacha20_poly130
1722
} SecurityType;
1823

24+
typedef enum FlowType : NSUInteger {
25+
none_flow,
26+
xtls_rprx_direct,
27+
xtls_rprx_direct_udp443,
28+
xtls_rprx_origin,
29+
xtls_rprx_origin_udp443,
30+
xtls_rprx_splice,
31+
xtls_rprx_splice_udp443
32+
} FlowType;
33+
1934
typedef enum NetWorkType : NSUInteger {
2035
tcp,
2136
kcp,
@@ -25,21 +40,22 @@ typedef enum NetWorkType : NSUInteger {
2540
} NetWorkType;
2641

2742
@interface ServerProfile : NSObject
28-
- (NSMutableDictionary*)outboundProfile;
29-
+ (ServerProfile* _Nullable )readFromAnOutboundDic:(NSDictionary*)outDict;
30-
+ (NSArray*)profilesFromJson:(NSDictionary*)outboundJson;
31-
-(ServerProfile*)deepCopy;
43+
- (NSMutableDictionary* _Null_unspecified)outboundProfile;
44+
+ (ServerProfile* _Nullable)readFromAnOutboundDic:(NSDictionary* _Null_unspecified)outDict;
45+
+ (NSArray* _Null_unspecified)profilesFromJson:(NSDictionary* _Null_unspecified)outboundJson;
46+
-(ServerProfile* _Null_unspecified)deepCopy;
3247

33-
@property (nonatomic) NSString* address;
34-
@property (nonatomic) NSString* protocol;
48+
@property (nonatomic) NSString* _Null_unspecified address;
49+
@property (nonatomic) ProtocolType protocol;
3550
@property (nonatomic) NSUInteger port;
36-
@property (nonatomic) NSString* userId;
51+
@property (nonatomic) NSString* _Null_unspecified userId;
3752
@property (nonatomic) NSUInteger alterId;
3853
@property (nonatomic) NSUInteger level;
39-
@property (nonatomic) NSString* outboundTag;
54+
@property (nonatomic) NSString* _Null_unspecified outboundTag;
55+
@property (nonatomic) FlowType flow;
4056
@property (nonatomic) SecurityType security;
4157
@property (nonatomic) NetWorkType network;
42-
@property (nonatomic) NSString* sendThrough;
43-
@property (nonatomic) NSDictionary* streamSettings; // except network type.
44-
@property (nonatomic) NSDictionary* muxSettings;
58+
@property (nonatomic) NSString* _Null_unspecified sendThrough;
59+
@property (nonatomic) NSDictionary* _Null_unspecified streamSettings; // except network type.
60+
@property (nonatomic) NSDictionary* _Null_unspecified muxSettings;
4561
@end

V2RayX/ServerProfile.m

+13-5
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ @implementation ServerProfile
1212
- (ServerProfile*)init {
1313
self = [super init];
1414
if (self) {
15-
[self setProtocol:@"vmess"];
15+
[self setProtocol:vmess];
1616
[self setAddress:@"server.cc"];
1717
[self setPort:10086];
1818
[self setUserId:@"00000000-0000-0000-0000-000000000000"];
1919
[self setAlterId:64];
2020
[self setLevel:0];
2121
[self setOutboundTag:@"test server"];
22-
[self setSecurity:auto_];
22+
[self setFlow:none_flow];
23+
[self setSecurity:none_security];
2324
[self setNetwork:tcp];
2425
[self setSendThrough:@"0.0.0.0"];
2526
[self setStreamSettings:@{
@@ -30,6 +31,9 @@ - (ServerProfile*)init {
3031
@"allowInsecure": [NSNumber numberWithBool:NO],
3132
@"allowInsecureCiphers": [NSNumber numberWithBool:NO]
3233
},
34+
@"xtlsSettings": @{
35+
@"allowInsecure": [NSNumber numberWithBool:NO]
36+
},
3337
@"tcpSettings": @{
3438
@"header": @{
3539
@"type": @"none"
@@ -87,7 +91,7 @@ + (NSArray*)profilesFromJson:(NSDictionary*)outboundJson {
8791
}
8892
for (NSDictionary* vnext in [outboundJson valueForKeyPath:@"settings.vnext"]) {
8993
ServerProfile* profile = [[ServerProfile alloc] init];
90-
profile.protocol = nilCoalescing(outboundJson[@"protocol"], @"vmess");
94+
profile.protocol = searchInArray(outboundJson[@"protocol"], PROTOCOL_LIST);
9195
profile.address = nilCoalescing(vnext[@"address"], @"127.0.0.1");
9296
profile.outboundTag = nilCoalescing(outboundJson[@"tag"], @"");
9397
profile.port = [vnext[@"port"] unsignedIntegerValue];
@@ -97,6 +101,7 @@ + (NSArray*)profilesFromJson:(NSDictionary*)outboundJson {
97101
profile.userId = nilCoalescing(vnext[@"users"][0][@"id"], @"23ad6b10-8d1a-40f7-8ad0-e3e35cd38287");
98102
profile.alterId = [vnext[@"users"][0][@"alterId"] unsignedIntegerValue];
99103
profile.level = [vnext[@"users"][0][@"level"] unsignedIntegerValue];
104+
profile.flow = searchInArray(vnext[@"users"][0][@"flow"], VLESS_FLOW_LIST);
100105
profile.security = searchInArray(vnext[@"users"][0][@"security"], VMESS_SECURITY_LIST);
101106
if (outboundJson[@"streamSettings"] != nil) {
102107
profile.streamSettings = outboundJson[@"streamSettings"];
@@ -122,13 +127,14 @@ + (ServerProfile* _Nullable )readFromAnOutboundDic:(NSDictionary*)outDict {
122127

123128
-(ServerProfile*)deepCopy {
124129
ServerProfile* aCopy = [[ServerProfile alloc] init];
125-
aCopy.protocol = [NSString stringWithString:nilCoalescing(self.protocol, @"")];
130+
aCopy.protocol = self.protocol;
126131
aCopy.address = [NSString stringWithString:nilCoalescing(self.address, @"")];
127132
aCopy.port = self.port;
128133
aCopy.userId = [NSString stringWithString:nilCoalescing(self.userId, @"")];
129134
aCopy.alterId = self.alterId;
130135
aCopy.level = self.level;
131136
aCopy.outboundTag = [NSString stringWithString:nilCoalescing(self.outboundTag, @"")];
137+
aCopy.flow = self.flow;
132138
aCopy.security = self.security;
133139
aCopy.network = self.network;
134140
aCopy.sendThrough = [NSString stringWithString:nilCoalescing(self.sendThrough, @"")];
@@ -144,7 +150,7 @@ - (NSMutableDictionary*)outboundProfile {
144150
@{
145151
@"sendThrough": sendThrough,
146152
@"tag": nilCoalescing(outboundTag, @""),
147-
@"protocol": nilCoalescing(protocol, @"vmess"),
153+
@"protocol": PROTOCOL_LIST[protocol],
148154
@"settings": [@{
149155
@"vnext": @[
150156
@{
@@ -154,6 +160,7 @@ - (NSMutableDictionary*)outboundProfile {
154160
@{
155161
@"id": userId != nil ? [userId stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]: @"",
156162
@"alterId": [NSNumber numberWithUnsignedInteger:alterId],
163+
@"flow": VLESS_FLOW_LIST[flow],
157164
@"security": VMESS_SECURITY_LIST[security],
158165
@"level": [NSNumber numberWithUnsignedInteger:level],
159166
@"encryption": @"none"
@@ -181,6 +188,7 @@ - (NSMutableDictionary*)outboundProfile {
181188
@synthesize alterId;
182189
@synthesize level;
183190
@synthesize outboundTag;
191+
@synthesize flow;
184192
@synthesize security;
185193
@synthesize network;
186194
@synthesize sendThrough;

0 commit comments

Comments
 (0)