readd: jump server

This commit is contained in:
lollipopkit
2024-04-21 00:42:00 +08:00
parent 9d1df94f89
commit 23764f8c93
5 changed files with 110 additions and 113 deletions

View File

@@ -1,7 +1,8 @@
import 'package:flutter/material.dart';
import 'package:toolbox/view/widget/cardx.dart';
extension WidgetX on Widget {
Widget get card {
return Card(child: this);
return CardX(child: this);
}
}

View File

@@ -60,28 +60,25 @@ Future<SSHClient> genClient(
onStatus?.call(GenSSHClientStatus.socket);
final socket = await () async {
/// Issues #210
/// Temporarily comment out the proxy function
// Proxy
// final jumpSpi_ = () {
// // Multi-thread or key login
// if (jumpSpi != null) return jumpSpi;
// // Main thread
// if (spi.jumpId != null) return Stores.server.box.get(spi.jumpId);
// }();
// if (jumpSpi_ != null) {
// final jumpClient = await genClient(
// jumpSpi_,
// privateKey: jumpPrivateKey,
// timeout: timeout,
// );
final jumpSpi_ = () {
// Multi-thread or key login
if (jumpSpi != null) return jumpSpi;
// Main thread
if (spi.jumpId != null) return Stores.server.box.get(spi.jumpId);
}();
if (jumpSpi_ != null) {
final jumpClient = await genClient(
jumpSpi_,
privateKey: jumpPrivateKey,
timeout: timeout,
);
// return await jumpClient.forwardLocal(
// spi.ip,
// spi.port,
// );
// }
return await jumpClient.forwardLocal(
spi.ip,
spi.port,
);
}
// Direct
try {

View File

@@ -259,9 +259,8 @@ class _ServerEditPageState extends State<ServerEditPage> {
),
),
_buildAuth(),
//_buildJumpServer(),
_buildPVE(),
_buildCustomCmd(),
_buildJumpServer(),
_buildMore(),
];
return SingleChildScrollView(
padding: const EdgeInsets.fromLTRB(17, 17, 17, 47),
@@ -356,10 +355,13 @@ class _ServerEditPageState extends State<ServerEditPage> {
);
}
Widget _buildPVE() {
Widget _buildMore() {
return ExpandTile(
title: const Text('PVE'),
title: Text(l10n.more),
children: [
UIs.height7,
const Text('PVE', style: UIs.text13Grey),
UIs.height7,
Input(
controller: _pveAddrCtrl,
type: TextInputType.url,
@@ -368,8 +370,11 @@ class _ServerEditPageState extends State<ServerEditPage> {
hint: 'https://example.com:8006',
),
ListTile(
leading: const Icon(MingCute.certificate_line),
title: Text(l10n.ignoreCert),
leading: const Padding(
padding: EdgeInsets.only(left: 10),
child: Icon(MingCute.certificate_line),
),
title: Text('PVE ${l10n.ignoreCert}'),
subtitle: Text(l10n.pveIgnoreCertTip, style: UIs.text12Grey),
trailing: ListenableBuilder(
listenable: _pveIgnoreCert,
@@ -381,24 +386,22 @@ class _ServerEditPageState extends State<ServerEditPage> {
),
),
).card,
],
);
}
Widget _buildCustomCmd() {
return ExpandTile(
title: Text(l10n.customCmd),
children: [
UIs.height7,
Text(l10n.customCmd, style: UIs.text13Grey),
UIs.height7,
Input(
controller: _customCmdCtrl,
type: TextInputType.text,
maxLines: 3,
label: 'Json',
label: 'JSON',
icon: Icons.code,
hint: '{${l10n.customCmdHint}}',
),
ListTile(
leading: const Icon(MingCute.doc_line),
leading: const Padding(
padding: EdgeInsets.only(left: 10),
child: Icon(MingCute.doc_line),
),
title: Text(l10n.doc),
trailing: const Icon(Icons.open_in_new, size: 17),
onTap: () => openUrl(l10n.customCmdDocUrl),
@@ -427,48 +430,44 @@ class _ServerEditPageState extends State<ServerEditPage> {
);
}
// Widget _buildJumpServer() {
// return ListenableBuilder(
// listenable: _jumpServer,
// builder: (_, __) {
// final children = Pros.server.servers
// .where((element) => element.spi.jumpId == null)
// .where((element) => element.spi.id != widget.spi?.id)
// .map(
// (e) => ListTile(
// title: Text(e.spi.name),
// subtitle: Text(e.spi.id, style: UIs.textGrey),
// trailing: Radio<String>(
// groupValue: _jumpServer.value,
// value: e.spi.id,
// onChanged: (val) => _jumpServer.value = val,
// ),
// onTap: () {
// _jumpServer.value = e.spi.id;
// },
// ),
// )
// .toList();
// children.add(ListTile(
// title: Text(l10n.clear),
// trailing: const Icon(Icons.clear),
// onTap: () => _jumpServer.value = null,
// ));
// return CardX(
// child: ExpandTile(
// leading: const Icon(Icons.map),
// initiallyExpanded: _jumpServer.value != null,
// title: Text(l10n.jumpServer),
// subtitle: const Text(
// "It was temporarily disabled because it has some bugs (Issues #210)",
// style: UIs.textGrey,
// ),
// children: children,
// ),
// );
// },
// );
// }
Widget _buildJumpServer() {
return ListenableBuilder(
listenable: _jumpServer,
builder: (_, __) {
final children = Pros.server.servers
.where((element) => element.spi.jumpId == null)
.where((element) => element.spi.id != widget.spi?.id)
.map(
(e) => ListTile(
title: Text(e.spi.name),
subtitle: Text(e.spi.id, style: UIs.textGrey),
trailing: Radio<String>(
groupValue: _jumpServer.value,
value: e.spi.id,
onChanged: (val) => _jumpServer.value = val,
),
onTap: () {
_jumpServer.value = e.spi.id;
},
),
)
.toList();
children.add(ListTile(
title: Text(l10n.clear),
trailing: const Icon(Icons.clear),
onTap: () => _jumpServer.value = null,
));
return CardX(
child: ExpandTile(
leading: const Icon(Icons.map),
initiallyExpanded: _jumpServer.value != null,
title: Text(l10n.jumpServer),
children: children,
),
);
},
);
}
void _onSave() async {
if (_ipController.text.isEmpty) {

View File

@@ -223,18 +223,18 @@ packages:
dependency: "direct main"
description:
name: countly_flutter
sha256: c5fd3e841af363d284d41d54bc33e8dd9312b0be148ce3600cc531e99203e8e1
sha256: "829853407896350bdb4881ddc92326cf87b8d70ad92a78c4775cd05666d5a965"
url: "https://pub.dev"
source: hosted
version: "23.12.1"
version: "24.4.0"
cross_file:
dependency: transitive
description:
name: cross_file
sha256: fedaadfa3a6996f75211d835aaeb8fede285dae94262485698afd832371b9a5e
sha256: "55d7b444feb71301ef6b8838dbc1ae02e63dd48c8773f3810ff53bb1e2945b32"
url: "https://pub.dev"
source: hosted
version: "0.3.3+8"
version: "0.3.4+1"
crypto:
dependency: transitive
description:
@@ -263,10 +263,10 @@ packages:
dependency: "direct main"
description:
name: dartssh2
sha256: "53a230c7dd6f487b704ceef1b29323ad64d19be89e786ccbc81e157a70417a56"
sha256: "48d35ad9b697627b59f9ebeab4e4936266dc153cff96f02c997d3fe30df4d80a"
url: "https://pub.dev"
source: hosted
version: "2.8.2"
version: "2.9.1-pre"
dio:
dependency: "direct main"
description:
@@ -327,10 +327,10 @@ packages:
dependency: "direct main"
description:
name: file_picker
sha256: "4e42aacde3b993c5947467ab640882c56947d9d27342a5b6f2895b23956954a6"
sha256: b6283d7387310ad83bc4f3bc245b75d223a032ae6eba275afcd585de2b9a1476
url: "https://pub.dev"
source: hosted
version: "6.1.1"
version: "8.0.1"
fixnum:
dependency: transitive
description:
@@ -417,10 +417,10 @@ packages:
dependency: "direct main"
description:
name: flutter_markdown
sha256: "21b085a1c185e46701373866144ced56cfb7a0c33f63c916bb8fe2d0c1491278"
sha256: "15f39b20486760f9b85531ed2ef7f63e3a376210d2ff83614119ee93fda5670c"
url: "https://pub.dev"
source: hosted
version: "0.6.19"
version: "0.7.0"
flutter_native_splash:
dependency: "direct dev"
description:
@@ -531,10 +531,10 @@ packages:
dependency: transitive
description:
name: http
sha256: a2bbf9d017fcced29139daa8ed2bba4ece450ab222871df93ca9eec6f80c34ba
sha256: "761a297c042deedc1ffbb156d6e2af13886bb305c2a343a4d972504cd67dd938"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
version: "1.2.1"
http_multi_server:
dependency: transitive
description:
@@ -979,18 +979,18 @@ packages:
dependency: "direct main"
description:
name: share_plus
sha256: "3ef39599b00059db0990ca2e30fca0a29d8b37aae924d60063f8e0184cf20900"
sha256: fb5319f3aab4c5dda5ebb92dca978179ba21f8c783ee4380910ef4c1c6824f51
url: "https://pub.dev"
source: hosted
version: "7.2.2"
version: "8.0.3"
share_plus_platform_interface:
dependency: transitive
description:
name: share_plus_platform_interface
sha256: df08bc3a07d01f5ea47b45d03ffcba1fa9cd5370fb44b3f38c70e42cced0f956
sha256: "251eb156a8b5fa9ce033747d73535bf53911071f8d3b6f4f0b578505ce0d4496"
url: "https://pub.dev"
source: hosted
version: "3.3.1"
version: "3.4.0"
shared_preferences:
dependency: "direct main"
description:
@@ -1035,10 +1035,10 @@ packages:
dependency: transitive
description:
name: shared_preferences_web
sha256: "7b15ffb9387ea3e237bb7a66b8a23d2147663d391cafc5c8f37b2e7b4bde5d21"
sha256: "9aee1089b36bd2aafe06582b7d7817fd317ef05fc30e6ba14bff247d0933042a"
url: "https://pub.dev"
source: hosted
version: "2.2.2"
version: "2.3.0"
shared_preferences_windows:
dependency: transitive
description:
@@ -1224,10 +1224,10 @@ packages:
dependency: transitive
description:
name: url_launcher_web
sha256: fff0932192afeedf63cdd50ecbb1bc825d31aed259f02bb8dba0f3b729a5e88b
sha256: "8d9e750d8c9338601e709cd0885f95825086bd8b642547f26bda435aade95d8a"
url: "https://pub.dev"
source: hosted
version: "2.2.3"
version: "2.3.1"
url_launcher_windows:
dependency: transitive
description:
@@ -1313,18 +1313,18 @@ packages:
dependency: transitive
description:
name: web
sha256: "4188706108906f002b3a293509234588823c8c979dc83304e229ff400c996b05"
sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27"
url: "https://pub.dev"
source: hosted
version: "0.4.2"
version: "0.5.1"
web_socket_channel:
dependency: transitive
description:
name: web_socket_channel
sha256: "939ab60734a4f8fa95feacb55804fa278de28bdeef38e616dc08e44a84adea23"
sha256: "58c6666b342a38816b2e7e50ed0f1e261959630becd4c879c4f26bfa14aa5a42"
url: "https://pub.dev"
source: hosted
version: "2.4.3"
version: "2.4.5"
webdav_client:
dependency: "direct main"
description:
@@ -1370,8 +1370,8 @@ packages:
dependency: "direct main"
description:
path: "."
ref: master
resolved-ref: "8f17dcbcafa9dc1b56cb3d7075dedfe0487d6a9b"
ref: "03c74c4"
resolved-ref: "03c74c45ceb3481ed98d11f69422e60d59eb1654"
url: "https://github.com/lollipopkit/xterm.dart"
source: git
version: "4.0.0"
@@ -1392,5 +1392,5 @@ packages:
source: hosted
version: "0.0.6"
sdks:
dart: ">=3.3.0-279.1.beta <4.0.0"
dart: ">=3.3.0 <4.0.0"
flutter: ">=3.19.0"

View File

@@ -18,8 +18,8 @@ dependencies:
dio: ^5.2.1
after_layout: ^1.1.0
url_launcher: ^6.1.8
countly_flutter: ^23.6.0
dartssh2: ^2.8.2
countly_flutter: ^24.4.0
dartssh2: ^2.9.1-pre
# newer version has some issues
# git:
# ref: master
@@ -35,15 +35,15 @@ dependencies:
r_upgrade: 0.3.8+2
path_provider: ^2.0.9
easy_isolate: ^1.3.0
share_plus: ^7.0.2
share_plus: ^8.0.3
intl: ^0.18.0
# xterm: ^3.5.0
xterm:
# path: ../xterm.dart
git:
ref: master
ref: 03c74c4
url: https://github.com/lollipopkit/xterm.dart
file_picker: ^6.1.1
file_picker: ^8.0.1
plain_notification_token: ^0.0.4
highlight: ^0.7.0
flutter_highlight: ^0.7.0
@@ -66,7 +66,7 @@ dependencies:
url: https://github.com/lollipopkit/webdav_client
window_manager: ^0.3.7
flutter_displaymode: ^0.6.0
flutter_markdown: ^0.6.18+2
flutter_markdown: ^0.7.0
computer:
git:
ref: master