From b598fde3177a989304d3e6f0cc60744c97749c1f Mon Sep 17 00:00:00 2001 From: tzmax <71716824+tzmax@users.noreply.github.com> Date: Fri, 9 Dec 2022 18:22:38 +0800 Subject: [PATCH] feat: support grpc protocol #21 --- V2RayX/AdvancedWindow.xib | 14 ++++---- V2RayX/Info.plist | 2 +- V2RayX/ServerProfile.h | 3 +- V2RayX/ServerProfile.m | 3 ++ V2RayX/TransportWindow.xib | 57 ++++++++++++++++++++++++++++-- V2RayX/TransportWindowController.h | 5 +++ V2RayX/TransportWindowController.m | 9 +++++ V2RayX/dlcorex.sh | 2 +- V2RayX/utilities.h | 2 +- 9 files changed, 83 insertions(+), 14 deletions(-) diff --git a/V2RayX/AdvancedWindow.xib b/V2RayX/AdvancedWindow.xib index afcb9e9..7aa333d 100644 --- a/V2RayX/AdvancedWindow.xib +++ b/V2RayX/AdvancedWindow.xib @@ -62,7 +62,7 @@ - + @@ -217,7 +217,7 @@ Gw - + @@ -292,7 +292,7 @@ Gw - + @@ -439,7 +439,7 @@ Gw - + @@ -693,7 +693,7 @@ Gw - + @@ -1063,7 +1063,7 @@ will match all private IPs. - + @@ -1131,7 +1131,7 @@ Gw - + diff --git a/V2RayX/Info.plist b/V2RayX/Info.plist index 296ba60..9ed5866 100644 --- a/V2RayX/Info.plist +++ b/V2RayX/Info.plist @@ -21,7 +21,7 @@ CFBundleSignature ???? CFBundleVersion - 2 + $(CURRENT_PROJECT_VERSION) LSMinimumSystemVersion $(MACOSX_DEPLOYMENT_TARGET) LSUIElement diff --git a/V2RayX/ServerProfile.h b/V2RayX/ServerProfile.h index f95d003..7117d73 100644 --- a/V2RayX/ServerProfile.h +++ b/V2RayX/ServerProfile.h @@ -36,7 +36,8 @@ typedef enum NetWorkType : NSUInteger { kcp, ws, http, - quic + quic, + grpc } NetWorkType; @interface ServerProfile : NSObject diff --git a/V2RayX/ServerProfile.m b/V2RayX/ServerProfile.m index 444d508..7077049 100644 --- a/V2RayX/ServerProfile.m +++ b/V2RayX/ServerProfile.m @@ -66,6 +66,9 @@ - (ServerProfile*)init { @"key": @"", @"header": @{ @"type": @"none" } }, + @"grpcSettings": @{ + @"multiMode": [NSNumber numberWithBool:NO], + }, @"sockopt": @{} }]; [self setMuxSettings:@{ diff --git a/V2RayX/TransportWindow.xib b/V2RayX/TransportWindow.xib index 276e427..fc1e29c 100644 --- a/V2RayX/TransportWindow.xib +++ b/V2RayX/TransportWindow.xib @@ -8,6 +8,8 @@ + + @@ -42,7 +44,7 @@ - + @@ -305,7 +307,7 @@ - + @@ -327,7 +329,7 @@ - + @@ -574,6 +576,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/V2RayX/TransportWindowController.h b/V2RayX/TransportWindowController.h index 678b682..da4c296 100644 --- a/V2RayX/TransportWindowController.h +++ b/V2RayX/TransportWindowController.h @@ -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 diff --git a/V2RayX/TransportWindowController.m b/V2RayX/TransportWindowController.m index c0af9ec..441f880 100644 --- a/V2RayX/TransportWindowController.m +++ b/V2RayX/TransportWindowController.m @@ -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]]; @@ -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]; diff --git a/V2RayX/dlcorex.sh b/V2RayX/dlcorex.sh index 737e652..92b685d 100755 --- a/V2RayX/dlcorex.sh +++ b/V2RayX/dlcorex.sh @@ -1,4 +1,4 @@ -VERSION="1.5.5" +VERSION="1.6.5" RED='\033[0;31m' GREEN='\033[0;32m' BOLD='\033[1m' diff --git a/V2RayX/utilities.h b/V2RayX/utilities.h index 8cd1746..268543b 100644 --- a/V2RayX/utilities.h +++ b/V2RayX/utilities.h @@ -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