feat: 节点测速调整
This commit is contained in:
@@ -8,7 +8,7 @@ import 'package:flutter/foundation.dart';
|
||||
/// 表示出站项列表的模型类
|
||||
class KrOutboundsList {
|
||||
|
||||
|
||||
|
||||
|
||||
/// 服务器分组
|
||||
final List<KRGroupOutboundList> groupOutboundList = []; // 存储服务器分组的列表
|
||||
@@ -18,20 +18,20 @@ class KrOutboundsList {
|
||||
|
||||
/// 全部列表
|
||||
final List<KROutboundItem> allList = []; // 存储国家分组的列表
|
||||
|
||||
|
||||
// 配置json
|
||||
final List<Map<String,dynamic>> configJsonList = [];
|
||||
final List<Map<String,dynamic>> configJsonList = [];
|
||||
|
||||
/// 标签列表
|
||||
final Map<String,KROutboundItem> keyList = {}; // 存储国家分组的列表
|
||||
|
||||
|
||||
|
||||
/// 处理出站项并将其分组
|
||||
/// [list] 是要处理的出站项列表
|
||||
void processOutboundItems(List<KrNodeListItem> list,List<KRNodeGroupListItem> groupList) {
|
||||
final Map<String, List<KROutboundItem>> tagGroups = {};
|
||||
final Map<String, List<KROutboundItem>> countryGroups = {};
|
||||
|
||||
|
||||
// 用于追踪已使用的标签
|
||||
final Map<String, int> tagCounter = {};
|
||||
|
||||
@@ -88,14 +88,11 @@ class KrOutboundsList {
|
||||
}
|
||||
}
|
||||
|
||||
// 生成国家自动选择虚拟节点
|
||||
_generateCountryAutoNodes(countryGroups);
|
||||
|
||||
// 将标签分组转换为 KRGroupOutboundList 并添加到 groupOutboundList
|
||||
for (var tag in tagGroups.keys) {
|
||||
final item = KRGroupOutboundList(
|
||||
final item = KRGroupOutboundList(
|
||||
tag: tag, outboundList: tagGroups[tag]!);
|
||||
|
||||
|
||||
for (var group in groupList) {
|
||||
if (item.tag == group.name) {
|
||||
item.icon = group.icon;
|
||||
@@ -111,41 +108,7 @@ class KrOutboundsList {
|
||||
country: country,
|
||||
outboundList: countryGroups[country]!)); // 添加国家分组到列表
|
||||
}
|
||||
}
|
||||
|
||||
/// 生成国家自动选择虚拟节点
|
||||
void _generateCountryAutoNodes(Map<String, List<KROutboundItem>> countryGroups) {
|
||||
for (var entry in countryGroups.entries) {
|
||||
final country = entry.key;
|
||||
final nodes = entry.value;
|
||||
final autoTag = '${country}-auto';
|
||||
|
||||
if (kDebugMode) {
|
||||
print('🤖 生成国家自动选择节点: $autoTag, 包含 ${nodes.length} 个节点');
|
||||
}
|
||||
|
||||
// 构建 urltest 配置
|
||||
final urltestConfig = {
|
||||
'type': 'urltest',
|
||||
'tag': autoTag,
|
||||
'outbounds': nodes.map((node) => node.tag).toList(),
|
||||
'url': 'https://www.google.com/generate_204',
|
||||
'interval': '10m',
|
||||
'tolerance': 50,
|
||||
"interrupt_exist_connections": true,
|
||||
};
|
||||
|
||||
// 创建虚拟节点
|
||||
final virtualNode = KROutboundItem.fromVirtual(autoTag, country, urltestConfig);
|
||||
|
||||
// 添加到各个列表
|
||||
allList.add(virtualNode);
|
||||
keyList[autoTag] = virtualNode;
|
||||
// configJsonList.add(urltestConfig);
|
||||
|
||||
if (kDebugMode) {
|
||||
print('✅ 生成虚拟节点: $autoTag, 配置: ${urltestConfig.toString()}');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user