This is an automated email from the ASF dual-hosted git repository.

twolf pushed a commit to branch dev_3.0
in repository https://gitbox.apache.org/repos/asf/mina-sshd.git

commit 40fd25cbc72012c6979ae0c45938894e0e7515c5
Author: Thomas Wolf <tw...@apache.org>
AuthorDate: Sat Apr 5 22:27:33 2025 +0200

    Remove ClientProxyConnector
    
    This interface was never useful; on the client side, connecting through
    a proxy to an SSH server is always a request-reply protocol, not a
    single message.
    
    With the new filter chain, connecting through a proxy can be implemented
    with a filter. The SshClient will need some changes, too, since it must
    open the connection not to the SSH server but to the proxy server. A
    full implementation is deferred to later.
---
 .../apache/sshd/client/ClientFactoryManager.java   |  2 -
 .../java/org/apache/sshd/client/SshClient.java     | 12 ------
 .../sshd/client/session/AbstractClientSession.java | 44 ---------------------
 .../sshd/client/session/ClientProxyConnector.java  | 45 ----------------------
 .../client/session/ClientProxyConnectorHolder.java | 29 --------------
 .../apache/sshd/client/session/ClientSession.java  |  2 +-
 .../sshd/client/session/ClientSessionImpl.java     |  7 ----
 7 files changed, 1 insertion(+), 140 deletions(-)

diff --git 
a/sshd-core/src/main/java/org/apache/sshd/client/ClientFactoryManager.java 
b/sshd-core/src/main/java/org/apache/sshd/client/ClientFactoryManager.java
index 95139d8be..d16b7e592 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/ClientFactoryManager.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/ClientFactoryManager.java
@@ -20,7 +20,6 @@ package org.apache.sshd.client;
 
 import org.apache.sshd.client.config.hosts.HostConfigEntryResolver;
 import org.apache.sshd.client.config.keys.ClientIdentityLoaderManager;
-import org.apache.sshd.client.session.ClientProxyConnectorHolder;
 import org.apache.sshd.client.session.ClientSessionCreator;
 import org.apache.sshd.common.FactoryManager;
 import org.apache.sshd.common.config.keys.FilePasswordProviderManager;
@@ -34,7 +33,6 @@ import 
org.apache.sshd.common.config.keys.FilePasswordProviderManager;
 public interface ClientFactoryManager
         extends FactoryManager,
         ClientSessionCreator,
-        ClientProxyConnectorHolder,
         FilePasswordProviderManager,
         ClientIdentityLoaderManager,
         ClientAuthenticationManager {
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java 
b/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java
index bbb517cb9..6289f2491 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java
@@ -65,7 +65,6 @@ import org.apache.sshd.client.future.DefaultConnectFuture;
 import org.apache.sshd.client.keyverifier.ServerKeyVerifier;
 import org.apache.sshd.client.session.AbstractClientSession;
 import org.apache.sshd.client.session.ClientConnectionServiceFactory;
-import org.apache.sshd.client.session.ClientProxyConnector;
 import org.apache.sshd.client.session.ClientSession;
 import org.apache.sshd.client.session.ClientUserAuthServiceFactory;
 import org.apache.sshd.client.session.SessionFactory;
@@ -184,7 +183,6 @@ public class SshClient extends AbstractFactoryManager 
implements ClientFactoryMa
     protected SessionFactory sessionFactory;
     protected List<UserAuthFactory> userAuthFactories;
 
-    private ClientProxyConnector proxyConnector;
     private ServerKeyVerifier serverKeyVerifier;
     private HostConfigEntryResolver hostConfigEntryResolver;
     private ClientIdentityLoader clientIdentityLoader;
@@ -212,16 +210,6 @@ public class SshClient extends AbstractFactoryManager 
implements ClientFactoryMa
         this.sessionFactory = sessionFactory;
     }
 
-    @Override
-    public ClientProxyConnector getClientProxyConnector() {
-        return proxyConnector;
-    }
-
-    @Override
-    public void setClientProxyConnector(ClientProxyConnector proxyConnector) {
-        this.proxyConnector = proxyConnector;
-    }
-
     @Override
     public ServerKeyVerifier getServerKeyVerifier() {
         return serverKeyVerifier;
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/client/session/AbstractClientSession.java
 
b/sshd-core/src/main/java/org/apache/sshd/client/session/AbstractClientSession.java
index 1c9e0a8ab..d5f40381a 100644
--- 
a/sshd-core/src/main/java/org/apache/sshd/client/session/AbstractClientSession.java
+++ 
b/sshd-core/src/main/java/org/apache/sshd/client/session/AbstractClientSession.java
@@ -94,7 +94,6 @@ public abstract class AbstractClientSession extends 
AbstractSession implements C
     private HostBasedAuthenticationReporter hostBasedAuthenticationReporter;
     private List<UserAuthFactory> userAuthFactories;
     private SocketAddress connectAddress;
-    private ClientProxyConnector proxyConnector;
 
     private volatile boolean useNoneCipher;
 
@@ -239,17 +238,6 @@ public abstract class AbstractClientSession extends 
AbstractSession implements C
         this.hostBasedAuthenticationReporter = reporter;
     }
 
-    @Override
-    public ClientProxyConnector getClientProxyConnector() {
-        ClientFactoryManager manager = getFactoryManager();
-        return resolveEffectiveProvider(ClientProxyConnector.class, 
proxyConnector, manager.getClientProxyConnector());
-    }
-
-    @Override
-    public void setClientProxyConnector(ClientProxyConnector proxyConnector) {
-        this.proxyConnector = proxyConnector;
-    }
-
     @Override
     public void addPasswordIdentity(String password) {
         // DO NOT USE checkNotNullOrNotEmpty SINCE IT TRIMS THE RESULT
@@ -304,38 +292,6 @@ public abstract class AbstractClientSession extends 
AbstractSession implements C
         }
     }
 
-    protected void initializeProxyConnector() throws Exception {
-        ClientProxyConnector proxyConnector = getClientProxyConnector();
-        boolean debugEnabled = log.isDebugEnabled();
-        if (proxyConnector == null) {
-            if (debugEnabled) {
-                log.debug("initializeProxyConnector({}) no proxy to 
initialize", this);
-            }
-            return;
-        }
-
-        try {
-            if (debugEnabled) {
-                log.debug("initializeProxyConnector({}) initialize proxy={}", 
this, proxyConnector);
-            }
-
-            proxyConnector.sendClientProxyMetadata(this);
-
-            if (debugEnabled) {
-                log.debug("initializeProxyConnector({}) proxy={} initialized", 
this, proxyConnector);
-            }
-        } catch (Throwable t) {
-            warn("initializeProxyConnector({}) failed ({}) to send proxy 
metadata: {}",
-                    this, t.getClass().getSimpleName(), t.getMessage(), t);
-
-            if (t instanceof Exception) {
-                throw (Exception) t;
-            } else {
-                throw new RuntimeSshException(t);
-            }
-        }
-    }
-
     @Override
     public ClientChannel createChannel(String type) throws IOException {
         return createChannel(type, null);
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientProxyConnector.java
 
b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientProxyConnector.java
deleted file mode 100644
index 38b938516..000000000
--- 
a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientProxyConnector.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.sshd.client.session;
-
-import org.apache.sshd.core.CoreModuleProperties;
-
-/**
- * Provides a way to implement proxied connections where some metadata about 
the client is sent <U>before</U> the actual
- * SSH protocol is executed - e.g., the <A 
HREF=@http://www.haproxy.org/download/1.6/doc/proxy-protocol.txt";>PROXY
- * protocol</A>. The implementor should use the {@code 
IoSession#write(Buffer)} method to send any packets with the
- * meta-data.
- *
- * @author <a href="mailto:d...@mina.apache.org";>Apache MINA SSHD Project</a>
- */
-@FunctionalInterface
-public interface ClientProxyConnector {
-    /**
-     * Invoked once initial connection has been established so that the proxy 
can open its channel and send the
-     * meta-data to its peer. Upon successful return the SSH identification 
line is eventually sent and the protocol
-     * proceeds as usual.
-     *
-     * @param  session   The {@link ClientSession} instance - <B>Note:</B> at 
this stage the client's identification
-     *                   line is not set yet.
-     * @throws Exception If failed to initialize the proxy - which will also 
terminate the session
-     * @see              CoreModuleProperties#SEND_IMMEDIATE_IDENTIFICATION 
SEND_IMMEDIATE_IDENTIFICATION
-     */
-    void sendClientProxyMetadata(ClientSession session) throws Exception;
-}
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientProxyConnectorHolder.java
 
b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientProxyConnectorHolder.java
deleted file mode 100644
index 6de3bc394..000000000
--- 
a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientProxyConnectorHolder.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.sshd.client.session;
-
-/**
- * @author <a href="mailto:d...@mina.apache.org";>Apache MINA SSHD Project</a>
- */
-public interface ClientProxyConnectorHolder {
-    ClientProxyConnector getClientProxyConnector();
-
-    void setClientProxyConnector(ClientProxyConnector proxyConnector);
-}
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSession.java 
b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSession.java
index b72fc80b6..e792c5d72 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSession.java
@@ -86,7 +86,7 @@ import org.apache.sshd.common.util.net.SshdSocketAddress;
  * @author <a href="mailto:d...@mina.apache.org";>Apache MINA SSHD Project</a>
  */
 public interface ClientSession
-        extends Session, ClientProxyConnectorHolder,
+        extends Session,
         ClientAuthenticationManager, PortForwardingManager {
     enum ClientSessionEvent {
         TIMEOUT,
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSessionImpl.java 
b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSessionImpl.java
index d713d386e..0aeaf89e9 100644
--- 
a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSessionImpl.java
+++ 
b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSessionImpl.java
@@ -86,13 +86,6 @@ public class ClientSessionImpl extends AbstractClientSession 
{
     @Override
     public void start() throws Exception {
         super.start();
-        /*
-         * Must be called regardless of whether the client identification is 
sent or not immediately in order to allow
-         * opening any underlying proxy protocol - e.g., SOCKS or HTTP CONNECT 
- otherwise the server's identification
-         * will never arrive
-         */
-        initializeProxyConnector();
-
         initializeKeyExchangePhase();
     }
 

Reply via email to