From 013211e7a683d31c3928ec56b878887b052a7593 Mon Sep 17 00:00:00 2001 From: cyan Date: Tue, 19 Aug 2025 11:04:08 -0400 Subject: [PATCH] fix: don't close closed sockets (#2462) --- cw_core/lib/utils/proxy_socket/insecure.dart | 6 ++++-- cw_core/lib/utils/proxy_socket/secure.dart | 6 ++++-- cw_core/lib/utils/proxy_socket/socks.dart | 3 ++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/cw_core/lib/utils/proxy_socket/insecure.dart b/cw_core/lib/utils/proxy_socket/insecure.dart index 6c0927409..114156fa8 100644 --- a/cw_core/lib/utils/proxy_socket/insecure.dart +++ b/cw_core/lib/utils/proxy_socket/insecure.dart @@ -15,13 +15,15 @@ class ProxySocketInsecure implements ProxySocket { ProxyAddress get address => ProxyAddress(host: socket.remoteAddress.host, port: socket.remotePort); @override - Future close() { + Future close() async { + if (_isClosed) return; _isClosed = true; return socket.close(); } @override - void destroy() { + void destroy() async { + if (_isClosed) return; _isClosed = true; socket.destroy(); } diff --git a/cw_core/lib/utils/proxy_socket/secure.dart b/cw_core/lib/utils/proxy_socket/secure.dart index 450753bb2..df7d34e4a 100644 --- a/cw_core/lib/utils/proxy_socket/secure.dart +++ b/cw_core/lib/utils/proxy_socket/secure.dart @@ -15,13 +15,15 @@ class ProxySocketSecure implements ProxySocket { ProxyAddress get address => ProxyAddress(host: socket.remoteAddress.host, port: socket.remotePort); @override - Future close() { + Future close() async { + if (_isClosed) return; _isClosed = true; return socket.close(); } @override - void destroy() { + void destroy() async { + if (_isClosed) return; _isClosed = true; socket.destroy(); } diff --git a/cw_core/lib/utils/proxy_socket/socks.dart b/cw_core/lib/utils/proxy_socket/socks.dart index 5a8845a93..4acd216c2 100644 --- a/cw_core/lib/utils/proxy_socket/socks.dart +++ b/cw_core/lib/utils/proxy_socket/socks.dart @@ -14,7 +14,8 @@ class ProxySocketSocks implements ProxySocket { ProxyAddress get address => ProxyAddress(host: socket.proxyHost, port: socket.proxyPort); @override - Future close() { + Future close() async { + if (_isClosed) return; _isClosed = true; return socket.close(); }