Class Socks5ClientConnector

java.lang.Object
org.eclipse.jgit.internal.transport.sshd.proxy.AbstractClientProxyConnector
org.eclipse.jgit.internal.transport.sshd.proxy.Socks5ClientConnector
All Implemented Interfaces:
org.apache.sshd.client.session.ClientProxyConnector, StatefulProxyConnector

public class Socks5ClientConnector extends AbstractClientProxyConnector
A AbstractClientProxyConnector to connect through a SOCKS5 proxy.
See Also:
  • Field Details

    • SOCKS_VERSION_5

      private static final byte SOCKS_VERSION_5
      See Also:
    • SOCKS_CMD_CONNECT

      private static final byte SOCKS_CMD_CONNECT
      See Also:
    • SOCKS_ADDRESS_IPv4

      private static final byte SOCKS_ADDRESS_IPv4
      See Also:
    • SOCKS_ADDRESS_FQDN

      private static final byte SOCKS_ADDRESS_FQDN
      See Also:
    • SOCKS_ADDRESS_IPv6

      private static final byte SOCKS_ADDRESS_IPv6
      See Also:
    • SOCKS_REPLY_SUCCESS

      private static final byte SOCKS_REPLY_SUCCESS
      See Also:
    • SOCKS_REPLY_FAILURE

      private static final byte SOCKS_REPLY_FAILURE
      See Also:
    • SOCKS_REPLY_FORBIDDEN

      private static final byte SOCKS_REPLY_FORBIDDEN
      See Also:
    • SOCKS_REPLY_NETWORK_UNREACHABLE

      private static final byte SOCKS_REPLY_NETWORK_UNREACHABLE
      See Also:
    • SOCKS_REPLY_HOST_UNREACHABLE

      private static final byte SOCKS_REPLY_HOST_UNREACHABLE
      See Also:
    • SOCKS_REPLY_CONNECTION_REFUSED

      private static final byte SOCKS_REPLY_CONNECTION_REFUSED
      See Also:
    • SOCKS_REPLY_TTL_EXPIRED

      private static final byte SOCKS_REPLY_TTL_EXPIRED
      See Also:
    • SOCKS_REPLY_COMMAND_UNSUPPORTED

      private static final byte SOCKS_REPLY_COMMAND_UNSUPPORTED
      See Also:
    • SOCKS_REPLY_ADDRESS_UNSUPPORTED

      private static final byte SOCKS_REPLY_ADDRESS_UNSUPPORTED
      See Also:
    • state

    • authenticator

      private AuthenticationHandler<org.apache.sshd.common.util.buffer.Buffer,org.apache.sshd.common.util.buffer.Buffer> authenticator
    • context

      private GSSContext context
    • authenticationProposals

      private byte[] authenticationProposals
  • Constructor Details

    • Socks5ClientConnector

      public Socks5ClientConnector(@NonNull InetSocketAddress proxyAddress, @NonNull InetSocketAddress remoteAddress)
      Creates a new Socks5ClientConnector. The connector supports anonymous connections as well as username-password or Kerberos5 (GSS-API) authentication.
      Parameters:
      proxyAddress - of the proxy server we're connecting to
      remoteAddress - of the target server to connect to
    • Socks5ClientConnector

      public Socks5ClientConnector(@NonNull InetSocketAddress proxyAddress, @NonNull InetSocketAddress remoteAddress, String proxyUser, char[] proxyPassword)
      Creates a new Socks5ClientConnector. The connector supports anonymous connections as well as username-password or Kerberos5 (GSS-API) authentication.
      Parameters:
      proxyAddress - of the proxy server we're connecting to
      remoteAddress - of the target server to connect to
      proxyUser - to authenticate at the proxy with
      proxyPassword - to authenticate at the proxy with
  • Method Details

    • sendClientProxyMetadata

      public void sendClientProxyMetadata(org.apache.sshd.client.session.ClientSession sshSession) throws Exception
      Throws:
      Exception
    • getAuthenticationProposals

      private byte[] getAuthenticationProposals()
    • sendConnectInfo

      private void sendConnectInfo(org.apache.sshd.common.io.IoSession session) throws Exception
      Throws:
      Exception
    • doPasswordAuth

      private void doPasswordAuth(org.apache.sshd.common.io.IoSession session) throws Exception
      Throws:
      Exception
    • doGssApiAuth

      private void doGssApiAuth(org.apache.sshd.common.io.IoSession session) throws Exception
      Throws:
      Exception
    • close

      private void close()
    • startAuth

      private void startAuth(org.apache.sshd.common.io.IoSession session) throws Exception
      Throws:
      Exception
    • authStep

      private void authStep(org.apache.sshd.common.io.IoSession session, org.apache.sshd.common.util.buffer.Buffer input) throws Exception
      Throws:
      Exception
    • establishConnection

      private void establishConnection(org.apache.sshd.common.util.buffer.Buffer data) throws Exception
      Throws:
      Exception
    • messageReceived

      public void messageReceived(org.apache.sshd.common.io.IoSession session, org.apache.sshd.common.util.Readable buffer) throws Exception
      Description copied from interface: StatefulProxyConnector
      Handle a received message.
      Parameters:
      session - to use for writing data
      buffer - received data
      Throws:
      Exception - if data cannot be read, or the connection attempt fails
    • versionCheck

      private void versionCheck(byte version) throws Exception
      Throws:
      Exception
    • getAuthMethod

      private Socks5ClientConnector.SocksAuthenticationMethod getAuthMethod(byte value)
    • getRawAddress

      private static byte[] getRawAddress(@NonNull InetSocketAddress address)
    • getGSSContext

      private static GSSContext getGSSContext(@NonNull InetSocketAddress address)