opt: auto rm pwd in key page for safe

This commit is contained in:
lollipopkit
2023-02-21 17:12:01 +08:00
parent e423e56152
commit 2986f80f89
6 changed files with 26 additions and 24 deletions

View File

@@ -356,7 +356,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 224;
CURRENT_PROJECT_VERSION = 225;
DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
@@ -364,7 +364,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.224;
MARKETING_VERSION = 1.0.225;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
@@ -486,7 +486,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 224;
CURRENT_PROJECT_VERSION = 225;
DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
@@ -494,7 +494,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.224;
MARKETING_VERSION = 1.0.225;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
@@ -510,7 +510,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 224;
CURRENT_PROJECT_VERSION = 225;
DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
@@ -518,7 +518,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.224;
MARKETING_VERSION = 1.0.225;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";

View File

@@ -8,12 +8,22 @@ import '../../data/store/private_key.dart';
import '../../locator.dart';
/// Must put this func out of any Class.
///
/// Because of this function is called by [compute] in [ServerProvider.genClient].
///
/// https://stackoverflow.com/questions/51998995/invalid-arguments-illegal-argument-in-isolate-message-object-is-a-closure
List<SSHKeyPair> loadIndentity(String key) {
return SSHKeyPair.fromPem(key);
}
/// [args] : [key, pwd]
String decyptPem(List<String> args) {
/// skip when the key is not encrypted, or will throw exception
if (!SSHKeyPair.isEncryptedPem(args[0])) return args[0];
final sshKey = SSHKeyPair.fromPem(args[0], args[1]);
return sshKey.first.toPem();
}
Future<SSHClient> genClient(ServerPrivateInfo spi) async {
final socket = await SSHSocket.connect(
spi.ip,

View File

@@ -2,8 +2,8 @@
class BuildData {
static const String name = "ServerBox";
static const int build = 224;
static const int build = 225;
static const String engine = "Flutter 3.7.3 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision 9944297138 (9 days ago) • 2023-02-08 15:46:04 -0800\nEngine • revision 248290d6d5\nTools • Dart 2.19.2 • DevTools 2.20.1\n";
static const String buildAt = "2023-02-18 13:16:46.172437";
static const int modifications = 1;
static const String buildAt = "2023-02-18 13:22:17.786805";
static const int modifications = 3;
}

View File

@@ -72,8 +72,8 @@ void onError(Object obj, StackTrace stack) {
}
Future<void> main() async {
await initApp();
runInZone(() async {
await initApp();
runApp(
MultiProvider(
providers: [

View File

@@ -1,7 +1,6 @@
import 'dart:io';
import 'package:after_layout/after_layout.dart';
import 'package:dartssh2/dartssh2.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
@@ -9,6 +8,7 @@ import 'package:toolbox/core/extension/numx.dart';
import 'package:toolbox/core/utils/misc.dart';
import 'package:toolbox/data/res/misc.dart';
import '../../../core/utils/server.dart';
import '../../../core/utils/ui.dart';
import '../../../data/model/server/private_key_info.dart';
import '../../../data/provider/private_key.dart';
@@ -158,7 +158,7 @@ class _PrivateKeyEditPageState extends State<PrivateKeyEditPage>
),
);
});
final info = PrivateKeyInfo(name, key, pwd);
final info = PrivateKeyInfo(name, key, '');
bool haveErr = false;
try {
info.privateKey = await compute(decyptPem, [key, pwd]);
@@ -197,11 +197,3 @@ class _PrivateKeyEditPageState extends State<PrivateKeyEditPage>
}
}
}
/// [args] : [key, pwd]
String decyptPem(List<String> args) {
/// skip when the key is not encrypted, or will throw exception
if (!SSHKeyPair.isEncryptedPem(args[0])) return args[0];
final sshKey = SSHKeyPair.fromPem(args[0], args[1]);
return sshKey.first.toPem();
}

View File

@@ -28,9 +28,9 @@ Future<ProcessResult> fvmRun(List<String> args) async {
return await Process.run('fvm', args, runInShell: true);
}
Future<int> getGitCommitCount() async {
Future<void> getGitCommitCount() async {
final result = await Process.run('git', ['log', '--oneline']);
return (result.stdout as String)
build = (result.stdout as String)
.split('\n')
.where((line) => line.isNotEmpty)
.length;
@@ -184,9 +184,9 @@ void main(List<String> args) async {
case 'build':
final stopwatch = Stopwatch()..start();
await dartFormat();
build = await getGitCommitCount();
await updateBuildData();
await getGitCommitCount();
await changeAppleVersion();
await updateBuildData();
if (args.length > 1) {
final platforms = args[1];
for (final platform in platforms.split(',')) {