commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1748152 - in /commons/proper/net/trunk/src: changes/changes.xml main/java/org/apache/commons/net/SocketClient.java
Date Mon, 13 Jun 2016 09:24:31 GMT
Author: sebb
Date: Mon Jun 13 09:24:30 2016
New Revision: 1748152

URL: http://svn.apache.org/viewvc?rev=1748152&view=rev
Log:
NET-593 HostnameVerifier is called with ip addess instead of the provided hostname

Modified:
    commons/proper/net/trunk/src/changes/changes.xml
    commons/proper/net/trunk/src/main/java/org/apache/commons/net/SocketClient.java

Modified: commons/proper/net/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/changes/changes.xml?rev=1748152&r1=1748151&r2=1748152&view=diff
==============================================================================
--- commons/proper/net/trunk/src/changes/changes.xml [utf-8] (original)
+++ commons/proper/net/trunk/src/changes/changes.xml [utf-8] Mon Jun 13 09:24:30 2016
@@ -64,6 +64,9 @@ The <action> type attribute can be add,u
 
     <body>
         <release version="3.6" date="TBA" description="">
+            <action issue="NET-593" type="fix" dev="sebb" due-to="J├Ârg Weule">
+            HostnameVerifier is called with ip addess instead of the provided hostname
+            </action>
             <action issue="NET-594" type="fix" dev="sebb" due-to="Brad Worrral">
             TelnetClient._closeOutputStream unhandled exception from FilterOutputStream.close
             </action>

Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/SocketClient.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/SocketClient.java?rev=1748152&r1=1748151&r2=1748152&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/org/apache/commons/net/SocketClient.java (original)
+++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/SocketClient.java Mon Jun
13 09:24:30 2016
@@ -178,15 +178,7 @@ public abstract class SocketClient
     throws SocketException, IOException
     {
         _hostname_ = null;
-        _socket_ = _socketFactory_.createSocket();
-        if (receiveBufferSize != -1) {
-            _socket_.setReceiveBufferSize(receiveBufferSize);
-        }
-        if (sendBufferSize != -1) {
-            _socket_.setSendBufferSize(sendBufferSize);
-        }
-        _socket_.connect(new InetSocketAddress(host, port), connectTimeout);
-        _connectAction_();
+        _connect(host, port, null, -1);
     }
 
     /**
@@ -206,8 +198,8 @@ public abstract class SocketClient
     public void connect(String hostname, int port)
     throws SocketException, IOException
     {
-        connect(InetAddress.getByName(hostname), port);
         _hostname_ = hostname;
+        _connect(InetAddress.getByName(hostname), port, null, -1);
     }
 
 
@@ -231,6 +223,13 @@ public abstract class SocketClient
     throws SocketException, IOException
     {
         _hostname_ = null;
+        _connect(host, port, localAddr, localPort);
+    }
+
+    // helper method to allow code to be shared with connect(String,...) methods
+    private void _connect(InetAddress host, int port, InetAddress localAddr, int localPort)
+        throws SocketException, IOException
+    {
         _socket_ = _socketFactory_.createSocket();
         if (receiveBufferSize != -1) {
             _socket_.setReceiveBufferSize(receiveBufferSize);
@@ -238,12 +237,13 @@ public abstract class SocketClient
         if (sendBufferSize != -1) {
             _socket_.setSendBufferSize(sendBufferSize);
         }
-        _socket_.bind(new InetSocketAddress(localAddr, localPort));
+        if (localAddr != null) {
+            _socket_.bind(new InetSocketAddress(localAddr, localPort));
+        }
         _socket_.connect(new InetSocketAddress(host, port), connectTimeout);
         _connectAction_();
     }
 
-
     /**
      * Opens a Socket connected to a remote host at the specified port and
      * originating from the specified local address and port.
@@ -264,8 +264,8 @@ public abstract class SocketClient
                         InetAddress localAddr, int localPort)
     throws SocketException, IOException
     {
-       connect(InetAddress.getByName(hostname), port, localAddr, localPort);
-       _hostname_ = hostname;
+        _hostname_ = hostname;
+       _connect(InetAddress.getByName(hostname), port, localAddr, localPort);
     }
 
 
@@ -303,8 +303,8 @@ public abstract class SocketClient
      */
     public void connect(String hostname) throws SocketException, IOException
     {
-        connect(hostname, _defaultPort_);
         _hostname_ = hostname;
+        connect(hostname, _defaultPort_);
     }
 
 



Mime
View raw message