Skip to content

Commit 34ec799

Browse files
committed
feat!: remove the responseController and subscription getters
They exposed the broadcast controller and the transport subscription behind inputStream. Closing the controller or cancelling the subscription from outside skipped the lifecycle tracking that 2.0.0 centralises, for the same reason the socket getter was removed. Nothing outside this package's own tests used them; those tests now check the delivered data rather than the subscription's pause state.
1 parent a9e08e5 commit 34ec799

4 files changed

Lines changed: 3 additions & 13 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- **Breaking:** Remove `SOCKSSocket.socket` so transport operations cannot bypass the wrapper's write queue and lifecycle tracking. Use `destroy()`, `close()`, `write()`, `outputStream`, and `inputStream` instead.
44
- **Breaking:** Caller-managed TLS through `SecureSocket.secure(socks.socket)` is no longer supported. Use `SOCKSSocket.create(sslEnabled: true, securityContext: ...)` to negotiate TLS during `connectTo()`.
55
- **Breaking:** Remove the `SOCKSSocket()` constructor, deprecated since 1.2.0; it never awaited the proxy connection. Use `SOCKSSocket.create()`.
6+
- **Breaking:** Remove `responseController` and `subscription`, which exposed the stream controller and subscription behind `inputStream`; closing or cancelling them bypassed the lifecycle tracking. Use `inputStream`.
67
- Add `destroy()` to abort without draining output; writes it cuts short fail instead of reporting success (#2). It also ends a connect, TLS handshake or `reconnect()` in flight, and a later `close()` completes normally even when it failed a close that was already draining.
78
- Add `closeOnPeerEof` to `create()`; pass `false` to keep writing after the peer half-closes (#3).
89
- `close()` now ends a `reconnect()` or TLS handshake in flight instead of being overtaken by the reconnect or waiting for the handshake deadline.

‎README.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ By default the connection closes once the peer closes its side. Pass `closeOnPee
9999

100100
## Migrating to 2.0.0
101101

102-
`SOCKSSocket.socket` has been removed. All transport operations now go through the wrapper so writes and teardown share the same lifecycle tracking.
102+
`SOCKSSocket.socket`, `responseController` and `subscription` have been removed. All transport operations now go through the wrapper so writes and teardown share the same lifecycle tracking.
103103

104104
| Previous operation | Replacement |
105105
| --- | --- |
@@ -108,6 +108,7 @@ By default the connection closes once the peer closes its side. Pass `closeOnPee
108108
| `socks.socket.add(bytes)` | `socks.outputStream.add(bytes)` |
109109
| `socks.socket.addStream(source)` | `await socks.outputStream.addStream(source)` |
110110
| Reading the underlying socket | `socks.inputStream` or `socks.listen(...)` |
111+
| `socks.responseController`, `socks.subscription` | `socks.inputStream`; pause or cancel your own subscription to it |
111112
| `SecureSocket.secure(socks.socket, ...)` | Set `sslEnabled: true` and, if needed, `securityContext` on `SOCKSSocket.create(...)` |
112113

113114
For an awaited binary write, use `await socks.outputStream.addStream(Stream.value(bytes))`. The output sink accepts one stream at a time. For text, use `await socks.write(text)`. To drain and finish the connection, use `await socks.close()`.

‎lib/socks_socket.dart‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -273,12 +273,6 @@ class SOCKSSocket {
273273
/// Reads pause while there is no listener; earlier data is kept.
274274
Stream<List<int>> get inputStream => _input.stream;
275275

276-
/// The controller behind [inputStream].
277-
StreamController<List<int>> get responseController => _input;
278-
279-
/// The subscription that feeds [inputStream], once connected.
280-
StreamSubscription<List<int>>? get subscription => _subscription;
281-
282276
StreamSink<List<int>> get outputStream => _outputSink ??= _newOutputSink();
283277

284278
StreamController<List<int>> _newInput() {

‎test/input_lifecycle_test.dart‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,16 @@ void main() {
4444
await socket.connect();
4545
await socket.connectTo('localhost', 443);
4646
final peer = await accepted.future;
47-
expect(socket.subscription!.isPaused, isTrue);
4847
peer.add([1]);
4948
await peer.flush();
5049
expect(await socket.inputStream.first, [1]);
51-
expect(socket.subscription!.isPaused, isTrue);
5250
peer.add([2]);
5351
await peer.flush();
5452
expect(await socket.inputStream.first, [2]);
55-
expect(socket.subscription!.isPaused, isTrue);
5653
final first = socket.inputStream.listen((_) {});
5754
final second = socket.inputStream.listen((_) {});
5855
await first.cancel();
59-
expect(socket.subscription!.isPaused, isFalse);
6056
await second.cancel();
61-
expect(socket.subscription!.isPaused, isTrue);
6257
});
6358

6459
test(
@@ -83,7 +78,6 @@ void main() {
8378
await socket.reconnect();
8479
final reply = socket.inputStream.first;
8580
await stale.cancel();
86-
expect(socket.subscription!.isPaused, isFalse);
8781
await socket.write('A');
8882
expect(await reply.timeout(const Duration(seconds: 2)), [65]);
8983
});

0 commit comments

Comments
 (0)