From 32876f5624eda306d58953489a2e2968c45a3b1e Mon Sep 17 00:00:00 2001 From: Fernando Panizza Date: Mon, 14 Aug 2023 11:29:41 -0300 Subject: [PATCH 1/2] revert: do not close socket in getSocket method. --- common/src/main/java/HTTPClient/SocksClient.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/HTTPClient/SocksClient.java b/common/src/main/java/HTTPClient/SocksClient.java index c08c00b3c..3cf152c29 100644 --- a/common/src/main/java/HTTPClient/SocksClient.java +++ b/common/src/main/java/HTTPClient/SocksClient.java @@ -212,9 +212,15 @@ Socket getSocket(String host, int port, InetAddress localAddr, return sock; } - finally + catch (IOException ioe) { - if (sock != null) sock.close(); + if (sock != null) + { + try { sock.close(); } + catch (IOException ee) {} + } + + throw ioe; } } From 14f2023be8e9031d23bfedd9f17d933483b769a5 Mon Sep 17 00:00:00 2001 From: Fernando Panizza Date: Mon, 14 Aug 2023 11:30:36 -0300 Subject: [PATCH 2/2] revert: do not close socket in getSocket method. do not close socket in sendRequest method. --- .../main/java/HTTPClient/HTTPConnection.java | 133 ++++++++---------- 1 file changed, 61 insertions(+), 72 deletions(-) diff --git a/common/src/main/java/HTTPClient/HTTPConnection.java b/common/src/main/java/HTTPClient/HTTPConnection.java index 91eadf629..2a6d8c5f6 100644 --- a/common/src/main/java/HTTPClient/HTTPConnection.java +++ b/common/src/main/java/HTTPClient/HTTPConnection.java @@ -3323,11 +3323,7 @@ Response sendRequest(Request req, int con_timeout) Log.write(Log.CONN, "Conn: Retrying request"); continue; } - finally - { - if (sock != null) sock.close(); - } - + break; } @@ -3407,39 +3403,38 @@ Response sendRequest(Request req, int con_timeout) private Socket getSocket(int con_timeout) throws IOException { Socket sock = null; - try { - String actual_host; - int actual_port; + String actual_host; + int actual_port; - if (Proxy_Host != null) - { - actual_host = Proxy_Host; - actual_port = Proxy_Port; - } - else - { - actual_host = Host; - actual_port = Port; - } + if (Proxy_Host != null) + { + actual_host = Proxy_Host; + actual_port = Proxy_Port; + } + else + { + actual_host = Host; + actual_port = Port; + } - Log.write(Log.CONN, "Conn: Creating Socket: " + actual_host + ":" + + Log.write(Log.CONN, "Conn: Creating Socket: " + actual_host + ":" + actual_port); - if (con_timeout == 0) // normal connection establishment + if (con_timeout == 0) // normal connection establishment + { + if (Socks_client != null) + sock = Socks_client.getSocket(actual_host, actual_port); + else { - if (Socks_client != null) - sock = Socks_client.getSocket(actual_host, actual_port); - else + // try all A records + InetAddress[] addr_list = InetAddress.getAllByName(actual_host); + for (int idx=0; idx