[ https://issues.apache.org/jira/browse/CAMEL-12711?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16569789#comment-16569789 ]
ASF GitHub Bot commented on CAMEL-12711: ---------------------------------------- onderson commented on a change in pull request #2452: [CAMEL-12711] Add configuration property 'bindAddress' for SFTP URL: https://github.com/apache/camel/pull/2452#discussion_r207785238 ########## File path: components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java ########## @@ -1074,4 +1097,64 @@ public synchronized boolean sendSiteCommand(String command) throws GenericFileOp // is not implemented return true; } + + /* + * adapted from com.jcraft.jsch.Util.createSocket(String, int, int) + * + * added possibility to specify the address of the local network interface, against the + * connection should bind + */ + static Socket createSocketUtil(final String host, final int port, final String bindAddress, final int timeout) { + Socket socket = null; + if (timeout == 0) { + try { + socket = bindAddress == null ? new Socket(host, port) : new Socket(InetAddress.getByName(host), port, InetAddress.getByName(bindAddress), 0); + return socket; + } catch (Exception e) { + String message = e.toString(); + if (e instanceof Throwable) { + throw new RuntimeCamelException(message, (Throwable)e); + } + throw new RuntimeCamelException(message); + } + } + final Socket[] sockp = new Socket[1]; + final Exception[] ee = new Exception[1]; + String message = ""; + Thread tmp = new Thread(new Runnable() { + public void run() { + sockp[0] = null; + try { + sockp[0] = bindAddress == null ? new Socket(host, port) : new Socket(InetAddress.getByName(host), port, InetAddress.getByName(bindAddress), 0); Review comment: not sure if null check for the new configuration option would be nicer before creating&setting socket factory. othwerwise new Socket(host,port) will be created which may affect as-is users unless provide unit test case. I guess test case would be nicer to showcase your requirement. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > SFTP: Cannot specify bind address of local network interface > ------------------------------------------------------------ > > Key: CAMEL-12711 > URL: https://issues.apache.org/jira/browse/CAMEL-12711 > Project: Camel > Issue Type: Bug > Components: camel-ftp > Affects Versions: 2.22.0 > Reporter: Felix Feisst > Priority: Major > > In an environment with multiple network interfaces, it might be necessary to > specify the address of the local interface, to which the SFTP connection > should bind. Unfortunately, this is not possible with the latest version of > camel-ftp. > > A new URI parameter 'bindAddress' should be introduces which can then be set > to the IP-Address of the local network interface against which the SFTP > connection should bind. -- This message was sent by Atlassian JIRA (v7.6.3#76005)