[jira] [Commented] (CAMEL-12711) SFTP: Cannot specify bind address of local network interface

2018-08-10 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/CAMEL-12711?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16575991#comment-16575991
 ] 

ASF GitHub Bot commented on CAMEL-12711:


davsclaus commented on issue #2452: [CAMEL-12711] Add configuration property 
'bindAddress' for SFTP
URL: https://github.com/apache/camel/pull/2452#issuecomment-412024782
 
 
   I am merging this, then we can do another PR if we manage to build an unit 
test


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: Improvement
>  Components: camel-ftp
>Affects Versions: 2.22.0
>Reporter: Felix Feisst
>Priority: Major
> Fix For: 2.23.0
>
>
> 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)


[jira] [Commented] (CAMEL-12711) SFTP: Cannot specify bind address of local network interface

2018-08-10 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/CAMEL-12711?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16575984#comment-16575984
 ] 

ASF GitHub Bot commented on CAMEL-12711:


Github user davsclaus closed the pull request at:

https://github.com/apache/camel/pull/2452


> 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: Improvement
>  Components: camel-ftp
>Affects Versions: 2.22.0
>Reporter: Felix Feisst
>Priority: Major
> Fix For: 2.23.0
>
>
> 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)


[jira] [Commented] (CAMEL-12711) SFTP: Cannot specify bind address of local network interface

2018-08-10 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/CAMEL-12711?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16575983#comment-16575983
 ] 

ASF GitHub Bot commented on CAMEL-12711:


davsclaus closed pull request #2452: [CAMEL-12711] Add configuration property 
'bindAddress' for SFTP
URL: https://github.com/apache/camel/pull/2452
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/components/camel-ftp/src/main/docs/sftp-component.adoc 
b/components/camel-ftp/src/main/docs/sftp-component.adoc
index e127442a0e0..cf8d95046c6 100644
--- a/components/camel-ftp/src/main/docs/sftp-component.adoc
+++ b/components/camel-ftp/src/main/docs/sftp-component.adoc
@@ -51,7 +51,7 @@ with the following path and query parameters:
 |===
 
 
- Query Parameters (115 parameters):
+ Query Parameters (116 parameters):
 
 
 [width="100%",cols="2,5,^1,2",options="header"]
@@ -111,6 +111,7 @@ with the following path and query parameters:
 | *synchronous* (advanced) | Sets whether synchronous processing should be 
strictly used, or Camel is allowed to use asynchronous processing (if 
supported). | false | boolean
 | *throwExceptionOnConnect Failed* (advanced) | Should an exception be thrown 
if connection failed (exhausted) By default exception is not thrown and a WARN 
is logged. You can use this to enable exception being thrown and handle the 
thrown exception from the org.apache.camel.spi.PollingConsumerPollStrategy 
rollback method. | false | boolean
 | *timeout* (advanced) | Sets the data timeout for waiting for reply Used only 
by FTPClient | 3 | int
+| *bindAddress* (bindAddress) | Specifies the address of the local interface 
against which the connection should bind. |  | String
 | *antExclude* (filter) | Ant style filter exclusion. If both antInclude and 
antExclude are used, antExclude takes precedence over antInclude. Multiple 
exclusions may be specified in comma-delimited format. |  | String
 | *antFilterCaseSensitive* (filter) | Sets case sensitive flag on ant filter | 
true | boolean
 | *antInclude* (filter) | Ant style filter inclusion. Multiple inclusions may 
be specified in comma-delimited format. |  | String
diff --git 
a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpConfiguration.java
 
b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpConfiguration.java
index 8fc377ad9aa..9be8751aa2d 100644
--- 
a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpConfiguration.java
+++ 
b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpConfiguration.java
@@ -69,6 +69,8 @@
 private LoggingLevel jschLoggingLevel = LoggingLevel.WARN;
 @UriParam(label = "advanced")
 private Integer bulkRequests;
+@UriParam(label = "bindAddress")
+private String bindAddress;
 
 public SftpConfiguration() {
 setProtocol("sftp");
@@ -296,4 +298,15 @@ public void setBulkRequests(Integer bulkRequests) {
 public Integer getBulkRequests() {
 return bulkRequests;
 }
+
+/**
+ * Specifies the address of the local interface against which the 
connection should bind.
+ */
+public void setBindAddress(String bindAddress) {
+this.bindAddress = bindAddress;
+}
+
+public String getBindAddress() {
+return bindAddress;
+}
 }
diff --git 
a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java
 
b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java
index ff82e72b9da..494eeb1544c 100644
--- 
a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java
+++ 
b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java
@@ -24,6 +24,9 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.UnsupportedEncodingException;
+import java.net.InetAddress;
+import java.net.Socket;
+import java.net.UnknownHostException;
 import java.security.KeyPair;
 import java.security.interfaces.DSAPrivateKey;
 import java.security.interfaces.DSAPublicKey;
@@ -41,11 +44,13 @@
 import com.jcraft.jsch.Proxy;
 import com.jcraft.jsch.Session;
 import com.jcraft.jsch.SftpException;
+import com.jcraft.jsch.SocketFactory;
 import com.jcraft.jsch.UIKeyboardInteractive;
 import com.jcraft.jsch.UserInfo;
 import org.apache.camel.Exchange;
 import org.apache.camel.InvalidPayloadException;
 import org.apache.camel.LoggingLevel;
+import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.component.file.FileComponent;
 import org.apache.camel.component.file.GenericFile;
 import org.apache.camel.comp

[jira] [Commented] (CAMEL-12711) SFTP: Cannot specify bind address of local network interface

2018-08-07 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/CAMEL-12711?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16571765#comment-16571765
 ] 

ASF GitHub Bot commented on CAMEL-12711:


davsclaus commented on issue #2452: [CAMEL-12711] Add configuration property 
'bindAddress' for SFTP
URL: https://github.com/apache/camel/pull/2452#issuecomment-411081074
 
 
   The unit test would be nice, but as said its a bit hard to do without real 
containers, so the testcontainer is a possibility. But its not 100% necessary 
(but would be nice to get more integration tests in camel component with 
testcontainers), it seems this code is only active if you set the bindAddress 
option and therefore not in risk of affecting existing behaviour. 


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)


[jira] [Commented] (CAMEL-12711) SFTP: Cannot specify bind address of local network interface

2018-08-07 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/CAMEL-12711?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16571683#comment-16571683
 ] 

ASF GitHub Bot commented on CAMEL-12711:


dmvolod commented on issue #2452: [CAMEL-12711] Add configuration property 
'bindAddress' for SFTP
URL: https://github.com/apache/camel/pull/2452#issuecomment-411063976
 
 
   @ffeisst in advance to @onderson suggestion, you can try to add bindAddress 
unit test with camel-testcontainer functiality. If Docker will find on the test 
env, you can bind to the real address of the chose container.


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)


[jira] [Commented] (CAMEL-12711) SFTP: Cannot specify bind address of local network interface

2018-08-07 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/CAMEL-12711?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16571267#comment-16571267
 ] 

ASF GitHub Bot commented on CAMEL-12711:


davsclaus 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_r208142504
 
 

 ##
 File path: 
components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java
 ##
 @@ -1074,4 +1099,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 = 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] = new Socket(InetAddress.getByName(host), port, 
InetAddress.getByName(bindAddress), 0);
+} catch (Exception e) {
+ee[0] = e;
+if (sockp[0] != null && sockp[0].isConnected()) {
+try {
+sockp[0].close();
+} catch (Exception eee) { }
+}
+sockp[0] = null;
+}
+}
+});
+tmp.setName("Opening Socket " + host);
+tmp.start();
+try {
+tmp.join(timeout);
+message = "timeout: ";
+} catch (java.lang.InterruptedException eee) {
+}
+if (sockp[0] != null && sockp[0].isConnected()) {
+socket = sockp[0];
+} else {
+message += "socket is not established";
+if (ee[0] != null) {
+message = ee[0].toString();
+}
+tmp.interrupt();
+tmp = null;
+throw new RuntimeCamelException(message, ee[0]);
 
 Review comment:
   Should this not be IOException and then let the method have throws 
IOException


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)


[jira] [Commented] (CAMEL-12711) SFTP: Cannot specify bind address of local network interface

2018-08-07 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/CAMEL-12711?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16571266#comment-16571266
 ] 

ASF GitHub Bot commented on CAMEL-12711:


davsclaus 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_r208143260
 
 

 ##
 File path: 
components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpConfiguration.java
 ##
 @@ -69,6 +69,8 @@
 private LoggingLevel jschLoggingLevel = LoggingLevel.WARN;
 @UriParam(label = "advanced")
 private Integer bulkRequests;
+@UriParam(label = "bindAddress")
 
 Review comment:
   I guess this option is more common, so we can remove the label


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)


[jira] [Commented] (CAMEL-12711) SFTP: Cannot specify bind address of local network interface

2018-08-06 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/CAMEL-12711?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16571134#comment-16571134
 ] 

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_r208103667
 
 

 ##
 File path: 
components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java
 ##
 @@ -1074,4 +1099,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 = 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] = new Socket(InetAddress.getByName(host), port, 
InetAddress.getByName(bindAddress), 0);
+} catch (Exception e) {
+ee[0] = e;
+if (sockp[0] != null && sockp[0].isConnected()) {
+try {
+sockp[0].close();
+} catch (Exception eee) { }
+}
+sockp[0] = null;
+}
+}
+});
+tmp.setName("Opening Socket " + host);
+tmp.start();
+try {
+tmp.join(timeout);
+message = "timeout: ";
+} catch (java.lang.InterruptedException eee) {
+}
 
 Review comment:
   Can we at least add here a debug log?


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)


[jira] [Commented] (CAMEL-12711) SFTP: Cannot specify bind address of local network interface

2018-08-06 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/CAMEL-12711?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16571130#comment-16571130
 ] 

ASF GitHub Bot commented on CAMEL-12711:


onderson commented on issue #2452: [CAMEL-12711] Add configuration property 
'bindAddress' for SFTP
URL: https://github.com/apache/camel/pull/2452#issuecomment-410938548
 
 
   maybe you can write a Unit test against your environment and mark those test 
case(s) `@Ignored`. (Of course, when you commit, please mask your ip addresses) 
If it is hard to unit test and we can not use any mocking mechanism, that's 
what we can usually do. if it is more complicated, you can leave it as is i 
suppose (in code terms, AFAIU this now looks like a new option without any 
effect on existing users.)


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)


[jira] [Commented] (CAMEL-12711) SFTP: Cannot specify bind address of local network interface

2018-08-06 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/CAMEL-12711?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16570793#comment-16570793
 ] 

ASF GitHub Bot commented on CAMEL-12711:


ffeisst commented on issue #2452: [CAMEL-12711] Add configuration property 
'bindAddress' for SFTP
URL: https://github.com/apache/camel/pull/2452#issuecomment-410856405
 
 
   @davsclaus I have copied the code from jsch.Util.createSocket(..). The 
comment on the method does also link to the original method. I've done this, to 
stay as close as possible to the original Socket creation implementation (the 
original implementation uses Util.createSocket).
   
   @onderson The null check to activate the new behavior only in case of a bind 
address sounds like a good idea to me. I've changed the commit accordingly. I 
also like the idea of a test case and already thought about it, but I dont know 
how I can setup an environment with multiple interfaces to test the bind 
address behavior in an unit test. Do you know how this can easily be done in an 
unit test? I've tested the implementation in a real world setup with multiple 
interfaces and it is working as expected.


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)


[jira] [Commented] (CAMEL-12711) SFTP: Cannot specify bind address of local network interface

2018-08-06 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/CAMEL-12711?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16570535#comment-16570535
 ] 

ASF GitHub Bot commented on CAMEL-12711:


davsclaus commented on issue #2452: [CAMEL-12711] Add configuration property 
'bindAddress' for SFTP
URL: https://github.com/apache/camel/pull/2452#issuecomment-410790167
 
 
   Thanks for the PR. Is the code where you create a new `Thread` and so some 
socket validation some code you have seen/copied from JCraft or how do you come 
up with that?


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)


[jira] [Commented] (CAMEL-12711) SFTP: Cannot specify bind address of local network interface

2018-08-05 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/CAMEL-12711?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16569792#comment-16569792
 ] 

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_r207785251
 
 

 ##
 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);
 
 Review comment:
   what you do is reasonably good as the class and method has default access 
modifers.


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)


[jira] [Commented] (CAMEL-12711) SFTP: Cannot specify bind address of local network interface

2018-08-05 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/CAMEL-12711?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16569790#comment-16569790
 ] 

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_r207785251
 
 

 ##
 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);
 
 Review comment:
   what you do is reasonably good as the class and method has default access 
modifers.


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)


[jira] [Commented] (CAMEL-12711) SFTP: Cannot specify bind address of local network interface

2018-08-05 Thread ASF GitHub Bot (JIRA)


[ 
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)


[jira] [Commented] (CAMEL-12711) SFTP: Cannot specify bind address of local network interface

2018-08-05 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/CAMEL-12711?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16569788#comment-16569788
 ] 

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_r207785091
 
 

 ##
 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) {
 
 Review comment:
   what you do is reasonably good as the class and method has default access 
modifers.


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)


[jira] [Commented] (CAMEL-12711) SFTP: Cannot specify bind address of local network interface

2018-08-05 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/CAMEL-12711?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16569585#comment-16569585
 ] 

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_r207749074
 
 

 ##
 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(){
+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);
+  }
+  catch(Exception e){
+ee[0]=e;
+if(sockp[0]!=null && sockp[0].isConnected()){
+  try{
+sockp[0].close();
+  }
+  catch(Exception eee){}
+}
+sockp[0]=null;
+  }
+}
+  });
+tmp.setName("Opening Socket "+host);
+tmp.start();
+try{
+  tmp.join(timeout);
+  message="timeout: ";
+}
+catch(java.lang.InterruptedException eee){
+}
+if(sockp[0]!=null && sockp[0].isConnected()){
+  socket=sockp[0];
+}
+else{
+  message+="socket is not established";
+  if(ee[0]!=null){
+message=ee[0].toString();
+  }
+  tmp.interrupt();
+  tmp=null;
+  throw new RuntimeException(message, ee[0]);
 
 Review comment:
   Thanks for the review, I've changed this accordingly.


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)


[jira] [Commented] (CAMEL-12711) SFTP: Cannot specify bind address of local network interface

2018-08-05 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/CAMEL-12711?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16569584#comment-16569584
 ] 

ASF GitHub Bot commented on CAMEL-12711:


ffeisst commented on issue #2452: [CAMEL-12711] Add configuration property 
'bindAddress' for SFTP
URL: https://github.com/apache/camel/pull/2452#issuecomment-410549648
 
 
   I have raised a JIRA issue 
(https://issues.apache.org/jira/browse/CAMEL-12711) and updated the commit 
message. I've also fixed all the checkstyle warnings.


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)


[jira] [Commented] (CAMEL-12711) SFTP: Cannot specify bind address of local network interface

2018-08-05 Thread ASF GitHub Bot (JIRA)


[ 
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:
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)