-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Close channel correctly when receiving SSH_Message_Channel_Close
Fixes #116 When receiving a SSH_Message_Channel_Close message, the channel was not being properly closed. This caused the stdout stream to remain open, preventing the drain() operation from completing. The fix: 1. Let the channel handle the close message properly 2. Added test to verify channel close behavior
- Loading branch information
Showing
3 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 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,30 @@ | ||
import 'package:dartssh2/dartssh2.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
import '../../test_utils.dart'; | ||
|
||
void main() { | ||
group('SSHChannel', () { | ||
late SSHClient client; | ||
late SSHSession session; | ||
|
||
setUp(() async { | ||
client = await getTestClient(); | ||
await client.authenticated; | ||
session = await client.shell(); | ||
}); | ||
|
||
tearDown(() { | ||
client.close(); | ||
}); | ||
|
||
test('stdout stream handles remote channel close correctly', () async { | ||
final drainFuture = session.stdout.drain<void>(); | ||
|
||
final closeMessage = createChannelCloseMessage(0); | ||
client.handlePacket(closeMessage); | ||
|
||
await drainFuture; | ||
}, timeout: const Timeout(Duration(seconds: 1))); | ||
}); | ||
} |
This file contains 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