Skip to content

Commit 9ba67b6

Browse files
committed
release v2.2.1
1 parent 1d78ea7 commit 9ba67b6

File tree

10 files changed

+228
-27
lines changed

10 files changed

+228
-27
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 2.2.1
2+
* Fix bug in isConnected that affected sftp connections in iOS
3+
* Add function to get host fingerprint
4+
* Add function to get host banner
5+
16
## 2.2.0
27
* Change NMSSH to GZ-NMSSH: https://github.com/gaetanzanella/NMSSH/tree/feature/catalyst
38
* Updated libssh and libssl

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Add `ssh2` as a [dependency in your pubspec.yaml file](https://flutter.io/using-
1010

1111
## Known issue
1212

13-
- Older Gradle versions are not supported due to incompatibilities with the newer JSch depencendy. This release was tested with Gradle version 7.0.2.
13+
- Older Gradle versions are not supported due to incompatibilities with the newer JSch dependency. This release was tested with Gradle version 7.0.2.
1414

1515
## Usage
1616

@@ -73,6 +73,16 @@ await client.disconnect();
7373
var result = await client.execute("ps");
7474
```
7575

76+
### Get the fingerprint of the remote host
77+
```dart
78+
var result = await client.getHostFingerprint();
79+
```
80+
81+
### Get the banner of the remote host
82+
```dart
83+
var result = await client.getBanner();
84+
```
85+
7686
### Shell
7787

7888
#### Start shell:

android/src/main/java/flutter/ssh2/SshPlugin.java

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import com.jcraft.jsch.ChannelSftp;
1414
import com.jcraft.jsch.ChannelSftp.LsEntry;
1515
import com.jcraft.jsch.ChannelShell;
16+
import com.jcraft.jsch.HostKey;
1617
import com.jcraft.jsch.JSch;
1718
import com.jcraft.jsch.JSchException;
1819
import com.jcraft.jsch.Session;
@@ -195,8 +196,14 @@ public void onMethodCall(MethodCall call, @NonNull Result rawResult) {
195196
case "disconnect":
196197
disconnect((HashMap) call.arguments);
197198
break;
198-
case "isConnected":
199-
isConnected((HashMap) call.arguments, result);
199+
case "flutterIsConnected":
200+
flutterIsConnected((HashMap) call.arguments, result);
201+
break;
202+
case "getHostFingerprint":
203+
getHostFingerprint((HashMap) call.arguments, result);
204+
break;
205+
case "getRemoteBanner":
206+
getRemoteBanner((HashMap) call.arguments, result);
200207
break;
201208
default:
202209
result.notImplemented();
@@ -207,6 +214,7 @@ public void onMethodCall(MethodCall call, @NonNull Result rawResult) {
207214
private static class SSHClient {
208215
Session _session;
209216
String _key;
217+
String _hostKey;
210218
BufferedReader _bufferedReader;
211219
DataOutputStream _dataOutputStream;
212220
Channel _channel = null;
@@ -275,6 +283,11 @@ private void connectToHost(final HashMap args, final Result result) {
275283
SSHClient client = new flutter.ssh2.SshPlugin.SSHClient();
276284
client._session = session;
277285
client._key = key;
286+
287+
HostKey hostKey = session.getHostKey();
288+
client._hostKey = hostKey.getHost()+" "+
289+
hostKey.getType()+" "+
290+
hostKey.getFingerPrint(jsch);
278291
clientPool.put(key, client);
279292

280293
Log.d(LOGTAG, "Session connected");
@@ -443,7 +456,6 @@ private void sftpLs(final HashMap args, final Result result) {
443456
SSHClient client = clientPool.get(args.get("id"));
444457
ChannelSftp channelSftp = Objects.requireNonNull(client)._sftpSession;
445458

446-
@SuppressWarnings("unchecked")
447459
Vector<LsEntry> files = channelSftp.ls(Objects.requireNonNull(args.get("path")).toString());
448460
List<Map<String, Object>> response = new ArrayList<>();
449461

@@ -601,15 +613,29 @@ private void disconnect(final HashMap args) {
601613
client._session.disconnect();
602614
}
603615

604-
private void isConnected(final HashMap args, final Result result) {
616+
private void flutterIsConnected(final HashMap args, final Result result) {
605617
SSHClient client = clientPool.get(args.get("id"));
606618
if (client == null) {
607619
result.success("false");
608620
} else if ( client._session == null || ! client._session.isConnected()) {
609621
result.success("false");
610622
} else {
611623
result.success("true");
612-
}
624+
}
625+
}
626+
627+
private void getHostFingerprint(final HashMap args, final Result result) {
628+
SSHClient client = clientPool.get(args.get("id"));
629+
if (client != null) {
630+
result.success(client._hostKey);
631+
}
632+
}
633+
634+
private void getRemoteBanner(final HashMap args, final Result result) {
635+
SSHClient client = clientPool.get(args.get("id"));
636+
if (client != null) {
637+
result.success(client._session.getServerVersion());
638+
}
613639
}
614640

615641
private void sendEvent(Map<String, Object> event) {

example/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ buildscript {
66
}
77

88
dependencies {
9-
classpath 'com.android.tools.build:gradle:7.0.0'
9+
classpath 'com.android.tools.build:gradle:7.0.1'
1010
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1111
}
1212
}

example/ios/Podfile.lock

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
PODS:
2+
- Flutter (1.0.0)
3+
- GZ-NMSSH (4.1.5)
4+
- path_provider (0.0.1):
5+
- Flutter
6+
- ssh2 (2.2.1):
7+
- Flutter
8+
- GZ-NMSSH (~> 4.1.5)
9+
10+
DEPENDENCIES:
11+
- Flutter (from `Flutter`)
12+
- path_provider (from `.symlinks/plugins/path_provider/ios`)
13+
- ssh2 (from `.symlinks/plugins/ssh2/ios`)
14+
15+
SPEC REPOS:
16+
trunk:
17+
- GZ-NMSSH
18+
19+
EXTERNAL SOURCES:
20+
Flutter:
21+
:path: Flutter
22+
path_provider:
23+
:path: ".symlinks/plugins/path_provider/ios"
24+
ssh2:
25+
:path: ".symlinks/plugins/ssh2/ios"
26+
27+
SPEC CHECKSUMS:
28+
Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c
29+
GZ-NMSSH: d749f8ae2fd0094b953cd1d5abd8e0cab3c93f8d
30+
path_provider: abfe2b5c733d04e238b0d8691db0cfd63a27a93c
31+
ssh2: e3b392bc3ccaad3cb058c0e0d3630907033cf143
32+
33+
PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c
34+
35+
COCOAPODS: 1.10.2

example/pubspec.lock

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,14 @@ packages:
7070
name: ffi
7171
url: "https://pub.dartlang.org"
7272
source: hosted
73-
version: "1.0.0"
73+
version: "1.1.2"
7474
file:
7575
dependency: transitive
7676
description:
7777
name: file
7878
url: "https://pub.dartlang.org"
7979
source: hosted
80-
version: "6.1.1"
80+
version: "6.1.2"
8181
flutter:
8282
dependency: "direct main"
8383
description: flutter
@@ -115,21 +115,21 @@ packages:
115115
name: path_provider
116116
url: "https://pub.dartlang.org"
117117
source: hosted
118-
version: "2.0.1"
118+
version: "2.0.2"
119119
path_provider_linux:
120120
dependency: transitive
121121
description:
122122
name: path_provider_linux
123123
url: "https://pub.dartlang.org"
124124
source: hosted
125-
version: "2.0.0"
125+
version: "2.0.2"
126126
path_provider_macos:
127127
dependency: transitive
128128
description:
129129
name: path_provider_macos
130130
url: "https://pub.dartlang.org"
131131
source: hosted
132-
version: "2.0.0"
132+
version: "2.0.2"
133133
path_provider_platform_interface:
134134
dependency: transitive
135135
description:
@@ -143,28 +143,28 @@ packages:
143143
name: path_provider_windows
144144
url: "https://pub.dartlang.org"
145145
source: hosted
146-
version: "2.0.1"
146+
version: "2.0.3"
147147
platform:
148148
dependency: transitive
149149
description:
150150
name: platform
151151
url: "https://pub.dartlang.org"
152152
source: hosted
153-
version: "3.0.0"
153+
version: "3.0.2"
154154
plugin_platform_interface:
155155
dependency: transitive
156156
description:
157157
name: plugin_platform_interface
158158
url: "https://pub.dartlang.org"
159159
source: hosted
160-
version: "2.0.0"
160+
version: "2.0.1"
161161
process:
162162
dependency: transitive
163163
description:
164164
name: process
165165
url: "https://pub.dartlang.org"
166166
source: hosted
167-
version: "4.2.1"
167+
version: "4.2.3"
168168
sky_engine:
169169
dependency: transitive
170170
description: flutter
@@ -183,7 +183,7 @@ packages:
183183
path: ".."
184184
relative: true
185185
source: path
186-
version: "2.1.2"
186+
version: "2.2.1"
187187
stack_trace:
188188
dependency: transitive
189189
description:
@@ -246,7 +246,7 @@ packages:
246246
name: win32
247247
url: "https://pub.dartlang.org"
248248
source: hosted
249-
version: "2.0.5"
249+
version: "2.2.7"
250250
xdg_directories:
251251
dependency: transitive
252252
description:
@@ -255,5 +255,5 @@ packages:
255255
source: hosted
256256
version: "0.2.0"
257257
sdks:
258-
dart: ">=2.12.0 <3.0.0"
258+
dart: ">=2.13.0 <3.0.0"
259259
flutter: ">=2.0.0"

0 commit comments

Comments
 (0)