You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2018/08/05 21:28:00 UTC
[jira] [Commented] (CAMEL-12711) SFTP: Cannot specify bind address
of local network interface
[ https://issues.apache.org/jira/browse/CAMEL-12711?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16569580#comment-16569580 ]
ASF GitHub Bot commented on CAMEL-12711:
----------------------------------------
ffeisst 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_r207748936
##########
File path: components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java
##########
@@ -1074,4 +1096,70 @@ 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(String host, int port, String bindAddress, 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 RuntimeException(message, (Throwable)e);
+ throw new RuntimeException(message);
+ }
+ }
+ final String _host=host;
+ final int _port=port;
+ final Socket[] sockp=new Socket[1];
+ final Exception[] ee=new Exception[1];
+ String message="";
+ Thread tmp=new Thread(new Runnable(){
Review comment:
I wanted to stay as close as possible to the original socket creation implementation. Therefore I copied the mentioned Util method (which has package protected access, btw) and added the possibility to specify the bind address to it (the original method does not support specifying the bind address). I've also added a comment on the method with a link to the original method.
The runnable here is used to implement the timeout behavior.
----------------------------------------------------------------
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:
users@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)