Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix
  • Loading branch information
DHR60 committed Feb 5, 2026
commit e47dc40488704e0c209bb3afaa4213840b2c29df
57 changes: 37 additions & 20 deletions v2rayN/ServiceLib/Manager/AppManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ public bool InitComponents()
_ = StatePort;
_ = StatePort2;

_ = MigrateProfileExtra();
Task.Run(async () =>
{
await MigrateProfileExtra();
}).Wait();

return true;
}
Expand Down Expand Up @@ -277,29 +280,33 @@ public async Task MigrateProfileExtra()
break;
}

var batchSuccessCount = 0;
foreach (var item in batch)
{
var extra = item.GetProtocolExtra();

if (item.ConfigType is EConfigType.PolicyGroup or EConfigType.ProxyChain)
try
{
extra = extra with { GroupType = nameof(item.ConfigType) };
groupItems.TryGetValue(item.IndexId, out var groupItem);
if (groupItem != null && !groupItem.NotHasChild())
var extra = item.GetProtocolExtra();

if (item.ConfigType is EConfigType.PolicyGroup or EConfigType.ProxyChain)
{
extra = extra with
extra = extra with { GroupType = nameof(item.ConfigType) };
groupItems.TryGetValue(item.IndexId, out var groupItem);
if (groupItem != null && !groupItem.NotHasChild())
{
ChildItems = groupItem.ChildItems,
SubChildItems = groupItem.SubChildItems,
Filter = groupItem.Filter,
MultipleLoad = groupItem.MultipleLoad,
};
extra = extra with
{
ChildItems = groupItem.ChildItems,
SubChildItems = groupItem.SubChildItems,
Filter = groupItem.Filter,
MultipleLoad = groupItem.MultipleLoad,
};
}
}

switch (item.ConfigType)
{
case EConfigType.Shadowsocks:
extra = extra with {SsMethod = item.Security.NullIfEmpty() };
extra = extra with { SsMethod = item.Security.NullIfEmpty() };
break;
case EConfigType.VMess:
extra = extra with
Expand All @@ -312,6 +319,7 @@ public async Task MigrateProfileExtra()
extra = extra with
{
Flow = item.Flow.NullIfEmpty(),
VlessEncryption = item.Security,
};
break;
case EConfigType.Hysteria2:
Expand Down Expand Up @@ -341,18 +349,27 @@ public async Task MigrateProfileExtra()
WgMtu = int.TryParse(item.ShortId, out var mtu) ? mtu : 1280
};
break;
default:
break;
}
}

item.SetProtocolExtra(extra);
item.SetProtocolExtra(extra);

item.Password = item.Id;
item.Password = item.Id;

item.ConfigVersion = 3;
await SQLiteHelper.Instance.UpdateAsync(item);
item.ConfigVersion = 3;
await SQLiteHelper.Instance.UpdateAsync(item);
batchSuccessCount++;
}
catch (Exception ex)
{
Logging.SaveLog($"MigrateProfileExtra Error: {ex}");
}
}

offset += pageSize;
// Only increment offset by the number of failed items that remain in the result set
// Successfully updated items are automatically excluded from future queries due to ConfigVersion = 3
offset += batch.Count - batchSuccessCount;
}

//await ProfileGroupItemManager.Instance.ClearAll();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@ private async Task<int> GenOutbound(ProfileItem node, Outbound4Sbox outbound)

outbound.packet_encoding = "xudp";

if (protocolExtra.Flow.IsNullOrEmpty())
if (!protocolExtra.Flow.IsNullOrEmpty())
{
await GenOutboundMux(node, outbound);
outbound.flow = protocolExtra.Flow;
}
else
{
outbound.flow = protocolExtra.Flow;
await GenOutboundMux(node, outbound);
}

await GenOutboundTransport(node, outbound);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,12 @@ private async Task<int> GenOutbound(ProfileItem node, Outbounds4Ray outbound)
usersItem.email = Global.UserEMail;
usersItem.encryption = protocolExtra.VlessEncryption;

if (protocolExtra.Flow.IsNullOrEmpty())
if (!protocolExtra.Flow.IsNullOrEmpty())
{
await GenOutboundMux(node, outbound, muxEnabled, muxEnabled);
usersItem.flow = protocolExtra.Flow;
}
else
{
usersItem.flow = protocolExtra.Flow;
await GenOutboundMux(node, outbound, false, muxEnabled);
}
outbound.settings.servers = null;
Expand Down