diff --git a/V2RayX/ConfigImporter.m b/V2RayX/ConfigImporter.m index 911c3d9..8d6ef91 100644 --- a/V2RayX/ConfigImporter.m +++ b/V2RayX/ConfigImporter.m @@ -438,7 +438,7 @@ + (ServerProfile*)importFromVmessOfV2RayN:(NSString*)vmessStr { return newProfile; } -// 目前为初步提案, 详情请见 VMessAEAD / VLESS 分享链接标准提案 https://github.com/XTLS/Xray-core/issues/91 +// 目前为初步提案, 详情请见 VMessAEAD / VLESS 分享链接标准提案 https://github.com/XTLS/Xray-core/discussions/716 + (ServerProfile*)importFromVLESSOfXray:(NSString*)vlessStr { // decode base64String NSString *base64String = [self decodeBase64String:vlessStr]; @@ -543,6 +543,7 @@ + (ServerProfile*)importFromVLESSOfXray:(NSString*)vlessStr { } break; case grpc: + streamSettings[@"grpcSettings"][@"headerType"] = nilCoalescing([sharedServer objectForKey:@"headerType"], @""); streamSettings[@"grpcSettings"][@"serviceName"] = nilCoalescing([sharedServer objectForKey:@"serviceName"], @""); if ([[sharedServer objectForKey:@"mode"] containsString:@"multi"]) { streamSettings[@"grpcSettings"][@"multiMode"] = @YES; @@ -570,12 +571,26 @@ + (ServerProfile*)importFromVLESSOfXray:(NSString*)vlessStr { settingsName = @"tlsSettings"; } + // temporarily compatible with xtls configuration, will be obsolete soon if ([sharedServer[@"security"] isEqualToString:@"xtls"] && [sharedServer objectForKey:@"flow"]) { newProfile.flow = searchInArray(nilCoalescing(sharedServer[@"flow"], @""), VLESS_FLOW_LIST); settingsName = @"xtlsSettings"; } + if ([sharedServer[@"security"] isEqualToString:@"reality"]) { + newProfile.flow = searchInArray(nilCoalescing(sharedServer[@"flow"], @""), VLESS_FLOW_LIST); + settingsName = @"realitySettings"; + streamSettings[settingsName][@"fingerprint"] = nilCoalescing(sharedServer[@"fp"], @"chrome"); + streamSettings[settingsName][@"shortId"] = nilCoalescing(sharedServer[@"sid"], @""); + streamSettings[settingsName][@"spiderX"] = [nilCoalescing(sharedServer[@"spx"], @"") stringByRemovingPercentEncoding]; + if ([sharedServer objectForKey:@"pbk"]) { + streamSettings[settingsName][@"publicKey"] = nilCoalescing(sharedServer[@"pbk"], @""); + } + } + if ([settingsName isNotEqualTo:@""]) { + streamSettings[settingsName][@"allowInsecure"] = nilCoalescing(sharedServer[@"allowInsecure"], @NO); + streamSettings[settingsName][@"allowInsecureCiphers"] = nilCoalescing(sharedServer[@"allowInsecureCiphers"], @NO); streamSettings[settingsName][@"serverName"] = nilCoalescing(sharedServer[@"sni"], newProfile.address); if ([sharedServer objectForKey:@"alpn"]) { streamSettings[settingsName][@"alpn"] = [sharedServer[@"alpn"] stringByRemovingPercentEncoding]; diff --git a/V2RayX/utilities.h b/V2RayX/utilities.h index 93d1357..b1f4587 100644 --- a/V2RayX/utilities.h +++ b/V2RayX/utilities.h @@ -19,7 +19,7 @@ #define VMESS_SECURITY_LIST (@[@"none", @"auto", @"aes-128-gcm", @"chacha20-poly1305"]) #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 TLS_SECURITY_LIST (@[@"none", @"tls", @"xtls", @"reality"]) #define nilCoalescing(a,b) ( (a != nil) ? (a) : (b) ) // equivalent to ?? operator in Swift #define TCP_NONE_HEADER_OBJECT (@"{\"type\": \"none\"}")