Files
FlClash/lib/common/constant.dart
T

145 lines
4.5 KiB
Dart
Raw Normal View History

2025-07-31 17:09:18 +08:00
// ignore_for_file: constant_identifier_names
2024-12-03 21:47:12 +08:00
import 'dart:math';
2024-04-30 23:38:49 +08:00
import 'dart:ui';
2024-09-26 14:29:04 +08:00
import 'package:collection/collection.dart';
2024-12-03 21:47:12 +08:00
import 'package:fl_clash/common/common.dart';
2024-07-15 22:06:09 +08:00
import 'package:fl_clash/enum/enum.dart';
2024-09-26 14:29:04 +08:00
import 'package:fl_clash/models/models.dart';
import 'package:material_ui/material_ui.dart';
2024-04-30 23:38:49 +08:00
2025-06-07 01:48:34 +08:00
const appName = 'FlClash';
const appHelperService = 'FlClashHelperService';
2026-08-05 10:55:33 +08:00
const coreManifestName = 'manifest.json';
2025-06-07 01:48:34 +08:00
const coreName = 'clash.meta';
2025-02-09 18:39:38 +08:00
const browserUa =
2025-06-07 01:48:34 +08:00
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36';
const packageName = 'com.follow.clash';
final unixSocketPath = '/tmp/FlClashSocket_${Random().nextInt(10000)}.sock';
2026-08-05 10:55:33 +08:00
final windowsPipeName = '\\\\.\\pipe\\FlClashCore_${_randomPipeId()}';
2024-12-03 21:47:12 +08:00
const helperPort = 47890;
const helperSocketPath = '/run/flclash/helper.sock';
2026-08-05 10:55:33 +08:00
const helperProtocolVersionHeader = 'x-flclash-helper-protocol';
const helperProtocolVersion = '6';
const maxTextScale = 1.4;
const minTextScale = 0.8;
final baseInfoEdgeInsets = EdgeInsets.symmetric(
2025-12-16 11:23:09 +08:00
vertical: 16.mAp,
horizontal: 16.mAp,
2024-12-09 01:40:39 +08:00
);
2025-10-14 15:13:52 +08:00
final listHeaderPadding = EdgeInsets.only(
2025-12-16 11:23:09 +08:00
left: 16.mAp,
right: 8.mAp,
top: 24.mAp,
bottom: 8.mAp,
2025-10-14 15:13:52 +08:00
);
2026-02-02 10:14:13 +08:00
const sheetAppBarHeight = 68.0;
2025-03-12 17:15:31 +08:00
2026-02-02 10:14:13 +08:00
const watchExecution = false;
2025-12-16 11:23:09 +08:00
const safeModeBuild = bool.fromEnvironment('SAFE_MODE');
2026-08-05 10:55:33 +08:00
String _randomPipeId() {
final random = Random.secure();
return List.generate(
16,
(_) => random.nextInt(256).toRadixString(16).padLeft(2, '0'),
).join();
}
2025-05-02 02:24:12 +08:00
final defaultTextScaleFactor =
WidgetsBinding.instance.platformDispatcher.textScaleFactor;
/// How long the Core may spend on one delay test. It spends this twice in the
/// worst case - once queueing for a slot, once on the probe itself - so the
/// guard below has to outlast twice this value.
const delayTestTimeoutDuration = Duration(seconds: 8);
const delayTestGuardDuration = Duration(seconds: 30);
const coreConnectionWaitDuration = Duration(seconds: 10);
/// Keep at or below the Core's delay-test concurrency (`delayTestConcurrency`
/// in core/common.go).
const maxConcurrentDelayTests = 16;
2024-06-23 00:26:24 +08:00
const animateDuration = Duration(milliseconds: 100);
2025-05-02 02:24:12 +08:00
const midDuration = Duration(milliseconds: 200);
2024-12-09 01:40:39 +08:00
const commonDuration = Duration(milliseconds: 300);
2024-05-20 15:15:09 +08:00
const defaultUpdateDuration = Duration(days: 1);
2025-07-31 17:09:18 +08:00
const MMDB = 'GEOIP.metadb';
const ASN = 'ASN.mmdb';
const GEOIP = 'GEOIP.dat';
const GEOSITE = 'GEOSITE.dat';
final double kHeaderHeight = getWindowHeaderHeight(
isDesktop: system.isDesktop,
isMacOS: system.isMacOS,
);
2025-06-07 01:48:34 +08:00
const profilesDirectoryName = 'profiles';
const providersDirectoryName = 'providers';
const proxiesProviderDirectoryName = 'proxies';
const rulesProviderDirectoryName = 'rules';
2025-06-07 01:48:34 +08:00
const localhost = '127.0.0.1';
const clashConfigKey = 'clash_config';
const configKey = 'config';
const systemDnsRecordKey = 'system_dns_record';
const bootRecordKey = 'boot_record';
const defaultSystemDnsFallback = '223.5.5.5';
2024-05-20 15:15:09 +08:00
const double dialogCommonWidth = 300;
2025-06-07 01:48:34 +08:00
const repository = 'chen08209/FlClash';
2024-05-20 15:15:09 +08:00
const maxMobileWidth = 600;
const maxLaptopWidth = 840;
2025-06-07 01:48:34 +08:00
const defaultTestUrl = 'https://www.gstatic.com/generate_204';
2025-03-12 17:15:31 +08:00
final commonFilter = ImageFilter.blur(
2024-05-20 15:15:09 +08:00
sigmaX: 5,
sigmaY: 5,
2026-02-02 10:14:13 +08:00
tileMode: TileMode.clamp,
2024-05-20 15:15:09 +08:00
);
2024-05-11 17:02:34 +08:00
2024-09-26 14:29:04 +08:00
const stringListEquality = ListEquality<String>();
const intListEquality = ListEquality<int>();
2025-10-14 15:13:52 +08:00
const ruleListEquality = ListEquality<Rule>();
2025-12-16 11:23:09 +08:00
const scriptListEquality = ListEquality<Script>();
const profileListEquality = ListEquality<Profile>();
2026-02-02 10:14:13 +08:00
const proxyGroupsEquality = ListEquality<ProxyGroup>();
2024-09-26 14:29:04 +08:00
const hotKeyActionListEquality = ListEquality<HotKeyAction>();
2025-10-14 15:13:52 +08:00
const stringAndStringMapEntryListEquality =
ListEquality<MapEntry<String, String>>();
2024-09-26 14:29:04 +08:00
const keyboardModifierListEquality = SetEquality<KeyboardModifier>();
2025-06-07 01:48:34 +08:00
const proxiesListStoreKey = PageStorageKey<String>('proxies_list');
const toolsStoreKey = PageStorageKey<String>('tools');
const profilesStoreKey = PageStorageKey<String>('profiles');
2025-05-02 02:24:12 +08:00
const defaultPrimaryColor = 0XFFD8C0C3;
2024-12-09 01:40:39 +08:00
double getWidgetHeight(num lines) {
2025-12-16 11:23:09 +08:00
final space = 14.mAp;
return max(lines * (80.ap + space) - space, 0);
2024-12-09 01:40:39 +08:00
}
2025-01-13 19:08:17 +08:00
const maxLogsLength = 5000;
const maxRequestsLength = 2000;
const pausedMaxLogsLength = maxLogsLength * 2;
const pausedMaxRequestsLength = maxRequestsLength * 2;
2025-01-13 19:08:17 +08:00
const trafficSampleLength = 30;
2025-04-09 16:46:14 +08:00
const defaultPrimaryColors = [
0xFF795548,
2025-04-09 16:46:14 +08:00
0xFF03A9F4,
0xFFFFFF00,
0XFFBBC9CC,
0XFFABD397,
defaultPrimaryColor,
2025-04-09 16:46:14 +08:00
0XFF665390,
];
2025-05-02 02:24:12 +08:00
2025-06-07 01:48:34 +08:00
const scriptTemplate = '''
2025-05-02 02:24:12 +08:00
const main = (config) => {
return config;
2025-06-07 01:48:34 +08:00
}''';
2025-12-16 11:23:09 +08:00
const backupDatabaseName = 'database.sqlite';
const configJsonName = 'config.json';