socks_socket 2.1.0
socks_socket: ^2.1.0 copied to clipboard
SOCKS version 5 sockets for Dart and Flutter, *eg.* ElectrumX and/or Fulcrum over Tor via socket(s).
2.1.0 #
- Add
onBadCertificatetoSOCKSSocket.create()andSocksConnection.start(), passed through toRawSecureSocket.secure.allowBadCertificates: truestill accepts everything.
2.0.0 #
- Breaking: Remove
SOCKSSocket.socketso transport operations cannot bypass the wrapper's write queue and lifecycle tracking. Usedestroy(),closeOutput(),close(),write(),outputStream, andinputStreaminstead.closeOutput()preserves the native socket's write-side half-close behavior. - Breaking: Caller-managed TLS through
SecureSocket.secure(socks.socket)is no longer supported. UseSOCKSSocket.create(sslEnabled: true, securityContext: ...)to negotiate TLS duringconnectTo(). - Breaking: Remove the
SOCKSSocket()constructor, deprecated since 1.2.0; it never awaited the proxy connection. UseSOCKSSocket.create(). - Breaking: Remove
responseControllerandsubscription, which exposed the stream controller and subscription behindinputStream; closing or cancelling them bypassed the lifecycle tracking. UseinputStream. - Add
destroy()to abort without draining output; writes it cuts short fail instead of reporting success (#2). It also ends a connect, TLS handshake orreconnect()in flight, and a laterclose()completes normally even when it failed a close that was already draining. - Add
closeOutput()to drain and half-close the sending direction while preserving input for protocols that respond after request EOF. - Add
closeOnPeerEoftocreate(); passfalseto keep writing after the peer half-closes (#3). closeOutput()rejects new writes as soon as draining starts, preserves accepted uploads, and aborts the connection and pending output if draining fails or times out.close()now ends areconnect()or TLS handshake in flight instead of being overtaken by the reconnect or waiting for the handshake deadline.- Give the greeting and username/password authentication exchanges separate handshake timeout budgets, preserving the previous slow-proxy behavior.
- Roll back
outputStream.addStream()bookkeeping if the supplied stream rejects its subscription, so later output shutdown cannot wait forever. - Make
close()consistently rethrow a recorded write failure whether it came fromwrite()oroutputStream. - Make
closeOutput()rethrow the same recorded write failure asclose()instead of replacing it with a state error. - Release the underlying socket after callers close both input and output, while still allowing writes between input cancellation and output shutdown.
- Validate
SOCKSSocket.create()proxy and timeout arguments before connecting. - The handshake timeout message reports sub-second deadlines in milliseconds instead of "0 seconds".
- Fail a handshake read or write at once when the socket reports its error synchronously, as macOS does for a reset peer, instead of waiting for the handshake deadline.
SocksConnectionshares the fix. - Document that
reconnect()works aftercancel(). - Drive
SOCKSSocketfrom one private lifecycle phase instead of a dozen flags. No API change.statenow readsdisconnectedas soon asclose()starts draining, not only once it completes. - Carry the plain connection over the same raw channel as TLS and
SocksConnection, so transport errors read the same on both transports. - Read handshake replies straight from the channel, as
SocksConnectiondoes. A greeting or authentication reply with trailing bytes still fails the handshake, and a stray byte before the CONNECT reply now fails it too instead of being dropped. Handshake failure messages come from the shared protocol code. - Migrate the Android example to Flutter's declarative Gradle plugins and grant release builds network access.
1.4.0 #
- Add
SocksConnection.startforHttpClient.connectionFactory(Dart 3.5). - Validate targets, tokens and proxy replies.
- Keep handshake replies out of
inputStream; buffer input until a listener attaches. - Bound SSL handshakes; add
securityContextandrequireIsolation(defaults to true with a token: a no-auth proxy is now rejected). - Serialize
writeandoutputStream; report transport failures asSocksConnectionException. - Reject overlapping connect calls; track peer close in
state;close()orcancel()during connect spends the instance. - Rename
ConnectionStatetoSocksSocketState(alias kept); addsocks.dartfor Flutter.
1.3.0 #
Features #
- Typed exception hierarchy: sealed
SocksExceptionwithSocksHandshakeException,SocksRequestException,SocksConnectionException, andSocksCancelledException. All implementExceptionfor backward compatibility. SocksReplyCodeenum covering all 8 SOCKS5 reply codes (RFC 1928) withfromByte()lookup.- Tor circuit isolation via
isolationTokenparameter oncreate()andreconnect(). Sends token as SOCKS5 username/password auth (RFC 1929) to request separate Tor circuits. cancel()method to abort in-flightconnect()/connectTo()operations. No-op when already connected or disconnected.
1.2.0 (unpublished; included in 1.3.0) #
Bug Fixes #
- Fix fragmented SOCKS5 response reassembly (previously caused RangeError).
- Fix connection hang when proxy drops without responding; now times out.
- Fix SSL socket leak in
close(). - Fix
outputStreamcreating a newStreamControlleron every access. - Fix error handler double-reporting errors as both Object and String.
- Deprecate non-async
SOCKSSocket()constructor (causesLateInitializationError); useSOCKSSocket.create(). - Fix broadcast stream subscription race during handshake via Completer-based approach.
Features #
- Configurable
handshakeTimeoutandoperationTimeoutoncreate()(default 30s). write()newline option for line-delimited protocols.ConnectionStateenum (disconnected, connecting, connected, error).reconnect()to re-establish a dropped connection without creating a new instance.
1.1.1 #
- Example fixes only.
1.1.0 #
- Add
inputStreamandoutputStream.
1.0.0 #
- Dart & Flutter 3.
- Supports SOCKS version 5 protocol.
- SSL support.
- Supports ElectrumX and Fulcrum servers via socket(s).
- Async support for non-blocking network communication.
- Lightweight and minimal dependencies.
- Working example.