@Override public HostConfigEntry resolveEffectiveHost(String host, int port, String username) throws IOException { try { HostConfigEntryResolver delegate = Objects.requireNonNull(resolveEffectiveResolver(host, port, username), "No delegate"); HostConfigEntry entry = delegate.resolveEffectiveHost(host, port, username); if (log.isDebugEnabled()) { log.debug("resolveEffectiveHost({}@{}:{}) => {}", username, host, port, entry); } return entry; } catch (Throwable e) { if (log.isDebugEnabled()) { log.debug("resolveEffectiveHost({}@{}:{}) failed ({}) to resolve: {}", username, host, port, e.getClass().getSimpleName(), e.getMessage()); } if (log.isTraceEnabled()) { log.trace("resolveEffectiveHost(" + username + "@" + host + ":" + port + ") resolution failure details", e); } if (e instanceof IOException) { throw (IOException) e; } else { throw new IOException(e); } } }
@Override public HostConfigEntry resolveEffectiveHost( String host, int port, SocketAddress localAddress, String username, AttributeRepository context) throws IOException { try { HostConfigEntryResolver delegate = Objects.requireNonNull(resolveEffectiveResolver(host, port, username), "No delegate"); HostConfigEntry entry = delegate.resolveEffectiveHost(host, port, localAddress, username, context); if (log.isDebugEnabled()) { log.debug("resolveEffectiveHost({}@{}:{}) => {}", username, host, port, entry); } return entry; } catch (Throwable e) { if (log.isDebugEnabled()) { log.debug("resolveEffectiveHost({}@{}:{}) failed ({}) to resolve: {}", username, host, port, e.getClass().getSimpleName(), e.getMessage()); } if (log.isTraceEnabled()) { log.trace("resolveEffectiveHost(" + username + "@" + host + ":" + port + ") resolution failure details", e); } if (e instanceof IOException) { throw (IOException) e; } else { throw new IOException(e); } } }
@Override public ConnectFuture connect( String username, SocketAddress targetAddress, SocketAddress localAddress) throws IOException { Objects.requireNonNull(targetAddress, "No target address"); if (targetAddress instanceof InetSocketAddress) { InetSocketAddress inetAddress = (InetSocketAddress) targetAddress; String host = ValidateUtils.checkNotNullAndNotEmpty(inetAddress.getHostString(), "No host"); int port = inetAddress.getPort(); ValidateUtils.checkTrue(port > 0, "Invalid port: %d", port); HostConfigEntryResolver resolver = getHostConfigEntryResolver(); HostConfigEntry entry = resolver.resolveEffectiveHost(host, port, username); if (entry == null) { if (log.isDebugEnabled()) { log.debug("connect({}@{}:{}) no overrides", username, host, port); } return doConnect(username, targetAddress, localAddress, Collections.emptyList(), true); } else { if (log.isDebugEnabled()) { log.debug("connect({}@{}:{}) effective: {}", username, host, port, entry); } return connect(entry); } } else { if (log.isDebugEnabled()) { log.debug("connect({}@{}) not an InetSocketAddress: {}", username, targetAddress, targetAddress.getClass().getName()); } return doConnect(username, targetAddress, localAddress, Collections.emptyList(), true); } }
@Override public ConnectFuture connect( String username, SocketAddress targetAddress, AttributeRepository context, SocketAddress localAddress) throws IOException { Objects.requireNonNull(targetAddress, "No target address"); if (targetAddress instanceof InetSocketAddress) { InetSocketAddress inetAddress = (InetSocketAddress) targetAddress; String host = ValidateUtils.checkNotNullAndNotEmpty(inetAddress.getHostString(), "No host"); int port = inetAddress.getPort(); ValidateUtils.checkTrue(port > 0, "Invalid port: %d", port); HostConfigEntryResolver resolver = getHostConfigEntryResolver(); HostConfigEntry entry = resolver.resolveEffectiveHost(host, port, localAddress, username, context); if (entry == null) { if (log.isDebugEnabled()) { log.debug("connect({}@{}:{}) no overrides", username, host, port); } return doConnect(username, targetAddress, context, localAddress, KeyIdentityProvider.EMPTY_KEYS_PROVIDER, true); } else { if (log.isDebugEnabled()) { log.debug("connect({}@{}:{}) effective: {}", username, host, port, entry); } return connect(entry, context, localAddress); } } else { if (log.isDebugEnabled()) { log.debug("connect({}@{}) not an InetSocketAddress: {}", username, targetAddress, targetAddress.getClass().getName()); } return doConnect(username, targetAddress, context, localAddress, KeyIdentityProvider.EMPTY_KEYS_PROVIDER, true); } }
@Override public ConnectFuture connect( String username, String host, int port, SocketAddress localAddress) throws IOException { HostConfigEntryResolver resolver = getHostConfigEntryResolver(); HostConfigEntry entry = resolver.resolveEffectiveHost(host, port, username); if (entry == null) { // generate a synthetic entry if (log.isDebugEnabled()) { log.debug("connect({}@{}:{}) no overrides", username, host, port); } // IPv6 addresses have a format which means they need special treatment, separate from pattern validation if (SshdSocketAddress.isIPv6Address(host)) { // Not using a pattern as the host name passed in was a valid IPv6 address entry = new HostConfigEntry("", host, port, username); } else { entry = new HostConfigEntry(host, host, port, username); } } else { if (log.isDebugEnabled()) { log.debug("connect({}@{}:{}) effective: {}", username, host, port, entry); } } return connect(entry, localAddress); }
@Override public ConnectFuture connect( String username, String host, int port, AttributeRepository context, SocketAddress localAddress) throws IOException { HostConfigEntryResolver resolver = getHostConfigEntryResolver(); HostConfigEntry entry = resolver.resolveEffectiveHost(host, port, localAddress, username, context); if (entry == null) { // generate a synthetic entry if (log.isDebugEnabled()) { log.debug("connect({}@{}:{}) no overrides", username, host, port); } // IPv6 addresses have a format which means they need special treatment, separate from pattern validation if (SshdSocketAddress.isIPv6Address(host)) { // Not using a pattern as the host name passed in was a valid IPv6 address entry = new HostConfigEntry("", host, port, username); } else { entry = new HostConfigEntry(host, host, port, username); } } else { if (log.isDebugEnabled()) { log.debug("connect({}@{}:{}) effective: {}", username, host, port, entry); } } return connect(entry, context, localAddress); }