Skip to content

Commit

Permalink
feat: support grpc protocol #21
Browse files Browse the repository at this point in the history
  • Loading branch information
tzmax committed Dec 9, 2022
1 parent a3ae476 commit b598fde
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 14 deletions.
14 changes: 7 additions & 7 deletions V2RayX/AdvancedWindow.xib
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<windowStyleMask key="styleMask" titled="YES" closable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="196" y="240" width="540" height="455"/>
<rect key="screenRect" x="0.0" y="0.0" width="2240" height="1235"/>
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1050"/>
<view key="contentView" wantsLayer="YES" id="EiT-Mj-1SZ">
<rect key="frame" x="0.0" y="0.0" width="540" height="455"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
Expand Down Expand Up @@ -217,7 +217,7 @@ Gw
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<clipView key="contentView" id="Vi9-1X-hgV">
<rect key="frame" x="1" y="1" width="458" height="273"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" alternatingRowBackgroundColors="YES" columnReordering="NO" columnResizing="NO" multipleSelection="NO" autosaveColumns="NO" typeSelect="NO" id="WsS-Gf-yrN">
<rect key="frame" x="0.0" y="0.0" width="458" height="273"/>
Expand Down Expand Up @@ -292,7 +292,7 @@ Gw
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<clipView key="contentView" id="R4k-Ta-qWH">
<rect key="frame" x="1" y="1" width="112" height="321"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" alternatingRowBackgroundColors="YES" columnReordering="NO" columnResizing="NO" multipleSelection="NO" emptySelection="NO" autosaveColumns="NO" typeSelect="NO" id="wbH-CA-T9F">
<rect key="frame" x="0.0" y="0.0" width="112" height="321"/>
Expand Down Expand Up @@ -439,7 +439,7 @@ Gw
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<clipView key="contentView" id="svV-1v-pv5">
<rect key="frame" x="1" y="1" width="85" height="228"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" alternatingRowBackgroundColors="YES" columnReordering="NO" columnResizing="NO" multipleSelection="NO" emptySelection="NO" autosaveColumns="NO" typeSelect="NO" id="VlQ-mV-pLn">
<rect key="frame" x="0.0" y="0.0" width="85" height="228"/>
Expand Down Expand Up @@ -693,7 +693,7 @@ Gw
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<clipView key="contentView" id="Jkw-Zi-tMR">
<rect key="frame" x="1" y="1" width="458" height="266"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" alternatingRowBackgroundColors="YES" columnReordering="NO" columnResizing="NO" multipleSelection="NO" autosaveColumns="NO" typeSelect="NO" id="sAX-Hf-7on">
<rect key="frame" x="0.0" y="0.0" width="458" height="266"/>
Expand Down Expand Up @@ -1063,7 +1063,7 @@ will match all private IPs.</string>
<autoresizingMask key="autoresizingMask"/>
<clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="RDn-zh-dIS">
<rect key="frame" x="0.0" y="0.0" width="260" height="133"/>
<autoresizingMask key="autoresizingMask"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView importsGraphics="NO" richText="NO" verticallyResizable="YES" spellingCorrection="YES" smartInsertDelete="YES" id="1mD-il-bEM">
<rect key="frame" x="0.0" y="0.0" width="260" height="133"/>
Expand Down Expand Up @@ -1131,7 +1131,7 @@ Gw
<autoresizingMask key="autoresizingMask"/>
<clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="jPy-Y0-jqx">
<rect key="frame" x="0.0" y="0.0" width="260" height="133"/>
<autoresizingMask key="autoresizingMask"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView importsGraphics="NO" richText="NO" verticallyResizable="YES" spellingCorrection="YES" smartInsertDelete="YES" id="3kN-VI-6Jc">
<rect key="frame" x="0.0" y="0.0" width="260" height="133"/>
Expand Down
2 changes: 1 addition & 1 deletion V2RayX/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>2</string>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>LSUIElement</key>
Expand Down
3 changes: 2 additions & 1 deletion V2RayX/ServerProfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ typedef enum NetWorkType : NSUInteger {
kcp,
ws,
http,
quic
quic,
grpc
} NetWorkType;

@interface ServerProfile : NSObject
Expand Down
3 changes: 3 additions & 0 deletions V2RayX/ServerProfile.m
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ - (ServerProfile*)init {
@"key": @"",
@"header": @{ @"type": @"none" }
},
@"grpcSettings": @{
@"multiMode": [NSNumber numberWithBool:NO],
},
@"sockopt": @{}
}];
[self setMuxSettings:@{
Expand Down
57 changes: 54 additions & 3 deletions V2RayX/TransportWindow.xib
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="TransportWindowController">
<connections>
<outlet property="grpcMultiMode" destination="bVE-E3-6zs" id="3d9-tO-zOf"/>
<outlet property="grpcServiceNameField" destination="g6G-XM-aQF" id="HJu-5u-gHH"/>
<outlet property="httpHostsField" destination="Plk-Mg-LyC" id="cQM-TX-wT7"/>
<outlet property="httpPathField" destination="gQZ-V1-coF" id="HTe-LZ-IuC"/>
<outlet property="kcpCongestionButton" destination="qto-Yo-ddA" id="yX1-AC-ezO"/>
Expand Down Expand Up @@ -42,7 +44,7 @@
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="196" y="240" width="523" height="246"/>
<rect key="screenRect" x="0.0" y="0.0" width="2240" height="1235"/>
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1050"/>
<view key="contentView" wantsLayer="YES" id="EiT-Mj-1SZ">
<rect key="frame" x="0.0" y="0.0" width="523" height="246"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
Expand Down Expand Up @@ -305,7 +307,7 @@
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="pRh-vR-SHO">
<rect key="frame" x="87" y="17" width="157" height="17"/>
<rect key="frame" x="87" y="14" width="157" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="{ &quot;Host&quot;: &quot;v2ray.com&quot; }" id="5Nf-oY-kxe">
<font key="font" metaFont="fixedUser" size="11"/>
Expand All @@ -327,7 +329,7 @@
<autoresizingMask key="autoresizingMask"/>
<clipView key="contentView" drawsBackground="NO" id="Ijl-Ha-SNR">
<rect key="frame" x="1" y="1" width="311" height="58"/>
<autoresizingMask key="autoresizingMask"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView importsGraphics="NO" richText="NO" verticallyResizable="YES" allowsCharacterPickerTouchBarItem="NO" allowsUndo="YES" allowsNonContiguousLayout="YES" textCompletion="NO" spellingCorrection="YES" id="5WV-Rv-Aia">
<rect key="frame" x="0.0" y="0.0" width="311" height="58"/>
Expand Down Expand Up @@ -574,6 +576,55 @@
</subviews>
</view>
</tabViewItem>
<tabViewItem label="GRPC" identifier="" id="TBB-xD-BEu">
<view key="view" id="aOV-np-3U4">
<rect key="frame" x="10" y="33" width="477" height="135"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField verticalHuggingPriority="750" fixedFrame="YES" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="g6G-XM-aQF">
<rect key="frame" x="124" y="101" width="336" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" usesSingleLineMode="YES" id="5Go-vI-k2n">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Jr2-yz-kfC">
<rect key="frame" x="19" y="104" width="87" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="serviceName:" id="ske-TU-9sE">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Piu-fw-rHo">
<rect key="frame" x="19" y="64" width="72" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="multiMode:" id="Uoh-Wd-4Uu">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="bVE-E3-6zs">
<rect key="frame" x="121" y="58" width="81" height="26"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" title="false" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="hme-zo-YsN" id="QX5-HL-xT2">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="menu"/>
<menu key="menu" id="HEr-JL-lAS">
<items>
<menuItem title="false" state="on" id="hme-zo-YsN"/>
<menuItem title="true" id="xa5-xM-Dxf"/>
</items>
</menu>
</popUpButtonCell>
</popUpButton>
</subviews>
</view>
</tabViewItem>
<tabViewItem label="···" identifier="" id="QwI-cq-3dE">
<view key="view" id="qEg-0O-lVX">
<rect key="frame" x="10" y="33" width="477" height="135"/>
Expand Down
5 changes: 5 additions & 0 deletions V2RayX/TransportWindowController.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ NS_ASSUME_NONNULL_BEGIN
//tcp fast open
@property (weak) IBOutlet NSButton *tfoEnableButton;

// grpc fields
@property (weak) IBOutlet NSTextField *grpcServiceNameField;
@property (weak) IBOutlet NSPopUpButton *grpcMultiMode;


@end

NS_ASSUME_NONNULL_END
9 changes: 9 additions & 0 deletions V2RayX/TransportWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ - (void)fillStream:(NSDictionary*)streamSettings andMuxSettings:(NSDictionary*)m
// mux
[_muxEnableButton setState:[nilCoalescing(muxSettings[@"enabled"], @NO) boolValue]];
[_muxConcurrencyField setIntegerValue:[nilCoalescing(muxSettings[@"concurrency"], @8) integerValue]];

// grpc
[_grpcServiceNameField setStringValue:nilCoalescing(streamSettings[@"grpcSettings"][@"serviceName"], @"")];
[_grpcMultiMode setState:[nilCoalescing(streamSettings[@"grpcSettings"][@"multiMode"], @NO) boolValue]];

// tcp fast open
NSDictionary* tfoSettings = [streamSettings objectForKey:@"sockopt"];
[_tfoEnableButton setState:[tfoSettings[@"tcpFastOpen"] boolValue]];
Expand Down Expand Up @@ -236,6 +241,10 @@ - (NSArray*)generateSettings {
@"allowInsecure": [NSNumber numberWithBool:[self->_tlsAiButton state]==1],
@"alpn": [[[_tlsAlpnField stringValue] stringByReplacingOccurrencesOfString:@" " withString:@""] componentsSeparatedByString:@","]
},
@"grpcSettings": @{
@"serviceName": [[_grpcServiceNameField stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]],
@"multiMode":[NSNumber numberWithBool:[self->_grpcMultiMode indexOfSelectedItem] != 0],
},
@"httpSettings": httpSettings
};
NSMutableDictionary *streamSettings = [streamSettingsImmutable mutableCopy];
Expand Down
2 changes: 1 addition & 1 deletion V2RayX/dlcorex.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION="1.5.5"
VERSION="1.6.5"
RED='\033[0;31m'
GREEN='\033[0;32m'
BOLD='\033[1m'
Expand Down
2 changes: 1 addition & 1 deletion V2RayX/utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#define OBFU_LIST (@[@"none", @"srtp", @"utp", @"wechat-video", @"dtls", @"wireguard"])
#define VLESS_FLOW_LIST (@[@"", @"xtls-rprx-direct", @"xtls-rprx-direct-udp443", @"xtls-rprx-origin", @"xtls-rprx-origin-udp443", @"xtls-rprx-splice", @"xtls-rprx-splice-udp443"])
#define VMESS_SECURITY_LIST (@[@"none", @"auto", @"aes-128-gcm", @"chacha20-poly1305"])
#define NETWORK_LIST (@[@"tcp", @"kcp", @"ws", @"http", @"quic"])
#define NETWORK_LIST (@[@"tcp", @"kcp", @"ws", @"http", @"quic", @"grpc"])
#define QUIC_SECURITY_LIST (@[@"none", @"aes-128-gcm", @"chacha20-poly1305"])
#define TLS_SECURITY_LIST (@[@"none", @"tls", @"xtls"])
#define nilCoalescing(a,b) ( (a != nil) ? (a) : (b) ) // equivalent to ?? operator in Swift
Expand Down

0 comments on commit b598fde

Please sign in to comment.