Skip to content

Commit

Permalink
fix: repair import Vmess server type null anomaly #3
Browse files Browse the repository at this point in the history
  • Loading branch information
tzmax committed Apr 15, 2022
1 parent 3441c86 commit b05b5e9
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion V2RayX/ConfigImporter.m
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,12 @@ + (ServerProfile*)importFromVmessOfV2RayN:(NSString*)vmessStr {
NSMutableDictionary* streamSettings = [newProfile.streamSettings mutableDeepCopy];
switch (newProfile.network) {
case tcp:
if (![sharedServer objectForKey:@"type"] || !([sharedServer[@"type"] isEqualToString:@"none"] || [sharedServer[@"type"] isEqualToString:@"http"])) {
{
NSString* sharedServerType = [sharedServer objectForKey:@"type"];
if(!sharedServerType || [sharedServerType isEqual:[NSNull null]]) {
break;
}
if (!([sharedServerType isEqualToString:@"none"] || [sharedServerType isEqualToString:@"http"])) {
break;
}
streamSettings[@"tcpSettings"][@"header"][@"type"] = sharedServer[@"type"];
Expand All @@ -357,7 +362,9 @@ + (ServerProfile*)importFromVmessOfV2RayN:(NSString*)vmessStr {
}
}
break;
}
case kcp:
{
if (![sharedServer objectForKey:@"type"]) {
break;
}
Expand All @@ -377,7 +384,9 @@ + (ServerProfile*)importFromVmessOfV2RayN:(NSString*)vmessStr {
streamSettings[@"wsSettings"][@"headers"][@"Host"] = nilCoalescing([sharedServer objectForKey:@"host"], @"");
}
break;
}
case http:
{
if ([[sharedServer objectForKey:@"host"] containsString:@";"]) {
NSArray *tempPathHostArray = [[sharedServer objectForKey:@"host"] componentsSeparatedByString:@";"];
streamSettings[@"wsSettings"][@"path"] = tempPathHostArray[0];
Expand All @@ -393,8 +402,11 @@ + (ServerProfile*)importFromVmessOfV2RayN:(NSString*)vmessStr {
}
}
break;
}
default:
{
break;
}
}
if ([sharedServer objectForKey:@"tls"] && [sharedServer[@"tls"] isEqualToString:@"tls"]) {
streamSettings[@"security"] = @"tls";
Expand Down

0 comments on commit b05b5e9

Please sign in to comment.