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(); }