mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-18 07:44:26 +01:00
fix: jump server (#190)
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:toolbox/data/res/logger.dart';
|
||||
import 'package:toolbox/data/res/store.dart';
|
||||
|
||||
import '../../../core/utils/server.dart';
|
||||
import '../server/server_private_info.dart';
|
||||
import 'worker.dart';
|
||||
@@ -10,6 +13,8 @@ class SftpReq {
|
||||
final String localPath;
|
||||
final SftpReqType type;
|
||||
String? privateKey;
|
||||
ServerPrivateInfo? jumpSpi;
|
||||
String? jumpPrivateKey;
|
||||
|
||||
SftpReq(
|
||||
this.spi,
|
||||
@@ -17,8 +22,13 @@ class SftpReq {
|
||||
this.localPath,
|
||||
this.type,
|
||||
) {
|
||||
if (spi.pubKeyId != null) {
|
||||
privateKey = getPrivateKey(spi.pubKeyId!);
|
||||
final keyId = spi.keyId;
|
||||
if (keyId != null) {
|
||||
privateKey = getPrivateKey(keyId);
|
||||
}
|
||||
if (spi.jumpId != null) {
|
||||
jumpSpi = Stores.server.box.get(spi.jumpId);
|
||||
jumpPrivateKey = Stores.key.get(jumpSpi?.keyId)?.key;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -83,7 +93,9 @@ class SftpReqStatus {
|
||||
break;
|
||||
default:
|
||||
error = Exception('sftp worker event: $event');
|
||||
Loggers.app.warning(error);
|
||||
dispose();
|
||||
break;
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@@ -81,7 +81,12 @@ Future<void> _download(
|
||||
try {
|
||||
mainSendPort.send(SftpWorkerStatus.preparing);
|
||||
final watch = Stopwatch()..start();
|
||||
final client = await genClient(req.spi, privateKey: req.privateKey);
|
||||
final client = await genClient(
|
||||
req.spi,
|
||||
privateKey: req.privateKey,
|
||||
jumpSpi: req.jumpSpi,
|
||||
jumpPrivateKey: req.jumpPrivateKey,
|
||||
);
|
||||
mainSendPort.send(SftpWorkerStatus.sshConnectted);
|
||||
|
||||
/// Create the directory if not exists
|
||||
@@ -131,7 +136,12 @@ Future<void> _upload(
|
||||
try {
|
||||
mainSendPort.send(SftpWorkerStatus.preparing);
|
||||
final watch = Stopwatch()..start();
|
||||
final client = await genClient(req.spi, privateKey: req.privateKey);
|
||||
final client = await genClient(
|
||||
req.spi,
|
||||
privateKey: req.privateKey,
|
||||
jumpSpi: req.jumpSpi,
|
||||
jumpPrivateKey: req.jumpPrivateKey,
|
||||
);
|
||||
mainSendPort.send(SftpWorkerStatus.sshConnectted);
|
||||
|
||||
final local = File(req.localPath);
|
||||
|
||||
Reference in New Issue
Block a user