summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.ssh.apache
diff options
context:
space:
mode:
authorThomas Wolf <thomas.wolf@paranor.ch>2019-07-04 20:00:48 +0200
committerThomas Wolf <thomas.wolf@paranor.ch>2019-09-02 21:30:28 +0200
commit99faa8bf6d11fef7a5c65fb60867140b3d766da0 (patch)
treee54dafabe02c3413391b320c57ae87e730bb71e5 /org.eclipse.jgit.ssh.apache
parent2d34d0bd9c6e5bad80befd42b76d5658de8e0d4d (diff)
downloadjgit-99faa8bf6d11fef7a5c65fb60867140b3d766da0.tar.gz
jgit-99faa8bf6d11fef7a5c65fb60867140b3d766da0.zip
sshd: fix proxy connections with the DefaultProxyDataFactory
The java.net.ProxySelector is quite a bit different from the one in Eclipse. Eclipse (and the OS) uses "socks" as URI scheme to look up a SOCKS proxy. java.net.ProxySelector needs "socket" as scheme (and internally maps that to "socks" if and when it asks the OS about the proxies). Moreover, java.net.ProxySelector may return unresolved addresses, whereas the Eclipse proxy selector always returns resolved addresses. Fix both by explicitly resolving unresolved proxy addresses and using scheme "socket" in the DefaultProxyDataFactory. Tested manually with the jgit command-line tool using ssh -vvv -D7020 localhost and 3proxy as SOCKS5 proxies on localhost (3proxy with user/password authentication). Start jgit with _JAVA_OPTIONS set to "-DsocksProxyHost=<host> -DsocksProxyPort=<port> -Djava.net.useSystemProxies=false" to test manually. Bug: 548965 Change-Id: Ib81ae8255ac2f9c48268f172e7d8ebb4a792b66d Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.jgit.ssh.apache')
-rw-r--r--org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/JGitSshClient.java4
-rw-r--r--org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/transport/sshd/DefaultProxyDataFactory.java4
2 files changed, 6 insertions, 2 deletions
diff --git a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/JGitSshClient.java b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/JGitSshClient.java
index 98e71dfe4b..377eabb00a 100644
--- a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/JGitSshClient.java
+++ b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/JGitSshClient.java
@@ -177,6 +177,10 @@ public class JGitSshClient extends SshClient {
return remoteAddress;
}
InetSocketAddress address = (InetSocketAddress) proxy.address();
+ if (address.isUnresolved()) {
+ address = new InetSocketAddress(address.getHostName(),
+ address.getPort());
+ }
switch (proxy.type()) {
case HTTP:
setClientProxyConnector(
diff --git a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/transport/sshd/DefaultProxyDataFactory.java b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/transport/sshd/DefaultProxyDataFactory.java
index 97e0da0428..66e595c6cc 100644
--- a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/transport/sshd/DefaultProxyDataFactory.java
+++ b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/transport/sshd/DefaultProxyDataFactory.java
@@ -62,8 +62,8 @@ public class DefaultProxyDataFactory implements ProxyDataFactory {
public ProxyData get(InetSocketAddress remoteAddress) {
try {
List<Proxy> proxies = ProxySelector.getDefault()
- .select(new URI(Proxy.Type.SOCKS.name(),
- "//" + remoteAddress.getHostString(), null)); //$NON-NLS-1$
+ .select(new URI(
+ "socket://" + remoteAddress.getHostString())); //$NON-NLS-1$
ProxyData data = getData(proxies, Proxy.Type.SOCKS);
if (data == null) {
proxies = ProxySelector.getDefault()