forked from TerminalStudio/dartssh2
-
Notifications
You must be signed in to change notification settings - Fork 1
Merge upstream v2.16.0 #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
2b7ae79
chore: update CHANGELOG.md with release date and contributor links
vicajilau f5d4168
chore: update version to 2.16.0 and clarify stdio handling for CLI-on…
vicajilau a34416b
style: format code for better readability in shell.dart
vicajilau 0a046af
fix(channel): make sendEnv awaitable to prevent race condition with p…
vicajilau 0695950
feat(keys): support legacy EC PRIVATE KEY parsing
vicajilau 8557522
test(keys): add coverage for legacy EC PRIVATE KEY parser paths
vicajilau 07dfa35
test(keys): add tests for ECDSA nistp384 and nistp521 private key han…
vicajilau 3de396d
Merge pull request #147 from TerminalStudio/fix/issue-121-shell-stdio…
vicajilau 416694b
test: add integration test for SftpClient.listdir method
vicajilau 2fd9949
feat(client): add runWithResult with exit metadata
vicajilau 447a436
feat(example): implement runWithResult with exit metadata and shell flow
vicajilau 885acf7
docs(README): add examples for runWithResult and end-to-end flow
vicajilau 8eed8a5
Merge pull request #148 from TerminalStudio/fix/102-sendenv-race-cond…
vicajilau f9b9ea1
test(client): add unit coverage for runWithResult
vicajilau e649e64
Merge pull request #149 from TerminalStudio/feat/109-legacy-ec-privat…
vicajilau aa5d5e7
Merge pull request #150 from TerminalStudio/feat/99-run-with-result
vicajilau 58a86e4
feat(sftp): add download APIs and integration coverage
vicajilau b86bc03
fix(ci): update integration test trigger to include pull requests
vicajilau b2c7a23
feat(sftp): add download progress reporting and streaming write funct…
vicajilau 5a291ad
Merge pull request #151 from TerminalStudio/feat/sftp-download-api-124
vicajilau 0627ee8
fix(sftp): tolerate malformed UTF-8 filenames (#95)
vicajilau efdd62b
fix(tests): handle null exit codes in SSH command results
vicajilau 1323d28
Merge pull request #152 from TerminalStudio/feat/sftp-nonutf8-filenam…
vicajilau 0817921
docs(README): update client.run() documentation for clarity on output…
vicajilau e17591f
docs(README): add web support section with guidance on SSHSocket usag…
vicajilau 6ec65df
fix(ssh_socket): update error handling for web socket connections
vicajilau c369227
docs(CHANGELOG): update release date for version 2.16.0
vicajilau 1e62efc
feat: Added new features and fixed several issues
GT-610 eccf26f
fix: Fixed an error in the X11 screen number type and added RSA signa…
GT-610 bd6f8d2
fix(ssh_client): Fixed an issue where completion callbacks for stdout…
GT-610 804379f
fix(ssh_key_pair): Properly handle UnsupportedError and validate the …
GT-610 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| import 'dart:convert'; | ||
| import 'dart:io'; | ||
| import 'dart:typed_data'; | ||
|
|
||
| import 'package:dartssh2/dartssh2.dart'; | ||
|
|
||
| Future<Uint8List> _collectBytes(Stream<Uint8List> stream) async { | ||
| final builder = BytesBuilder(copy: false); | ||
| await for (final chunk in stream) { | ||
| builder.add(chunk); | ||
| } | ||
| return builder.takeBytes(); | ||
| } | ||
|
|
||
| Future<void> main(List<String> args) async { | ||
| final host = Platform.environment['SSH_HOST'] ?? 'localhost'; | ||
| final port = int.tryParse(Platform.environment['SSH_PORT'] ?? '') ?? 22; | ||
| final username = Platform.environment['SSH_USERNAME'] ?? 'root'; | ||
|
|
||
| final runShellDemo = args.contains('--shell'); | ||
|
|
||
| final client = SSHClient( | ||
| await SSHSocket.connect(host, port), | ||
| username: username, | ||
| onPasswordRequest: () { | ||
| final envPassword = Platform.environment['SSH_PASSWORD']; | ||
| if (envPassword != null) { | ||
| return envPassword; | ||
| } | ||
|
|
||
| if (!stdin.hasTerminal || !stdout.hasTerminal) { | ||
| throw StateError( | ||
| 'No terminal attached. Set SSH_PASSWORD environment variable.', | ||
| ); | ||
| } | ||
|
|
||
| stdout.write('Password for $username@$host:$port: '); | ||
| try { | ||
| stdin.echoMode = false; | ||
| final password = stdin.readLineSync(); | ||
| if (password == null || password.isEmpty) { | ||
| throw StateError('Empty password'); | ||
| } | ||
| return password; | ||
| } finally { | ||
| stdin.echoMode = true; | ||
| stdout.writeln(); | ||
| } | ||
| }, | ||
| ); | ||
|
|
||
| try { | ||
| // 1) Convenience run() for simple command output. | ||
| final runOutput = await client.run('echo run-ok'); | ||
| stdout.writeln('[run] output: ${utf8.decode(runOutput).trim()}'); | ||
|
|
||
| // 2) runWithResult() with exit metadata. | ||
| final runResult = await client.runWithResult( | ||
| 'sh -lc "echo runWithResult-out; echo runWithResult-err 1>&2; exit 7"', | ||
| ); | ||
| stdout.writeln('[runWithResult] exitCode: ${runResult.exitCode}'); | ||
| stdout.writeln('[runWithResult] stdout: ${utf8.decode(runResult.stdout)}'); | ||
| stdout.writeln('[runWithResult] stderr: ${utf8.decode(runResult.stderr)}'); | ||
|
|
||
| // 3) execute() for lower-level session control. | ||
| final session = await client.execute('echo execute-ok'); | ||
| final executeStdoutFuture = _collectBytes(session.stdout); | ||
| final executeStderrFuture = _collectBytes(session.stderr); | ||
| await session.done; | ||
| final executeStdout = await executeStdoutFuture; | ||
| final executeStderr = await executeStderrFuture; | ||
| stdout.writeln('[execute] exitCode: ${session.exitCode}'); | ||
| stdout.writeln('[execute] stdout: ${utf8.decode(executeStdout).trim()}'); | ||
| if (executeStderr.isNotEmpty) { | ||
| stdout.writeln('[execute] stderr: ${utf8.decode(executeStderr).trim()}'); | ||
| } | ||
|
|
||
| // 4) Optional shell flow for interactive/pty scenarios. | ||
| if (runShellDemo) { | ||
| final shell = await client.shell(pty: const SSHPtyConfig()); | ||
| final shellStdoutFuture = _collectBytes(shell.stdout); | ||
| final shellStderrFuture = _collectBytes(shell.stderr); | ||
|
|
||
| shell.write(Uint8List.fromList('echo shell-ok; exit\n'.codeUnits)); | ||
| await shell.stdin.close(); | ||
| await shell.done; | ||
|
|
||
| final shellStdout = await shellStdoutFuture; | ||
| final shellStderr = await shellStderrFuture; | ||
| stdout.writeln('[shell] exitCode: ${shell.exitCode}'); | ||
| stdout.writeln('[shell] stdout: ${utf8.decode(shellStdout).trim()}'); | ||
| if (shellStderr.isNotEmpty) { | ||
| stdout.writeln('[shell] stderr: ${utf8.decode(shellStderr).trim()}'); | ||
| } | ||
| } else { | ||
| stdout.writeln('Shell flow skipped. Use --shell to run it.'); | ||
| } | ||
| } finally { | ||
| client.close(); | ||
| await client.done; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Removed CHANGELOG link definitions for contributors still referenced in text
The link definitions for
[@shihuili1218]and[@isegal]were removed from the CHANGELOG footer, but both are still referenced in the 2.14.0 section (lines 20-21). This results in broken markdown links — the rendered text will show raw[@shihuili1218]and[@isegal]brackets instead of clickable hyperlinks.Was this helpful? React with 👍 or 👎 to provide feedback.