CH-J Tools Mobile透過 SSH 管理伺服器
選單
已發布的原始碼

CH-J Tools Mobile

瀏覽特定應用程式版本的目錄與檔案。

下載原始碼 ZIP
CH-J / CH-J Tools Mobile 175 個檔案
sm-mobile-20261016T185235Z-8e93ecc1b59a 新增時間: · 建置時間:
profile_transfer.dart 新增時間: 未記錄日期 1.2 KB · 40 行
程式碼 下載檔案
1import 'dart:convert';
2import '../core/failure.dart';
3import '../models/server_profile.dart';
5class ProfileTransfer {
6 static const maxBytes = 5 * 1024 * 1024;
7 static List<ServerProfile> decode(List<int> bytes) {
8 if (bytes.length > maxBytes) throw const Failure('invalidImport');
9 try {
10 final text = utf8.decode(bytes).replaceFirst(RegExp(r'^\uFEFF'), '');
11 final data = jsonDecode(text);
12 if (data is! Map ||
13 data['format'] != 'chj-server-profiles' ||
14 data['version'] != 1 ||
15 data['servers'] is! List ||
16 data['servers'].isEmpty ||
17 data['servers'].length > 10000) {
18 throw const Failure('invalidImport');
19 }
20 return (data['servers'] as List)
21 .map(
22 (e) => ServerProfile.fromJson(
23 Map<String, dynamic>.from(e),
24 portable: true,
25 ),
26 )
27 .toList();
28 } catch (_) {
29 throw const Failure('invalidImport');
30 }
31 }
33 static List<int> encode(List<ServerProfile> profiles) => utf8.encode(
34 const JsonEncoder.withIndent(' ').convert({
35 'format': 'chj-server-profiles',
36 'version': 1,
37 'servers': profiles.map((p) => p.portable()).toList(),
38 }),
39 );
SHA-2569d6b8526a0dabf2e6524e9ddf9a0ed29048131d73d927d0e3262a5e596f93b9a

CH-J Proprietary Software License 1.14 · 原始碼依 CH-J Proprietary Software License 1.14 提供。公開原始碼不會改變授權條款,也不會授予額外的權利。

壓縮檔 SHA-25646e427a43e87af091004f36145590bda8fe90086dfb0f631afeb5029fb0b5655
檔案