/** * @param protocol Scheme * @param hostname The hostname of the server * @param credentials Login credentials */ public Host(final Protocol protocol, final String hostname, final Credentials credentials) { this(protocol, hostname, protocol.getDefaultPort(), credentials); }
/** * @param port The port number to connect to or -1 to use the default port for this protocol */ public void setPort(final int port) { this.port = -1 == port ? protocol.getDefaultPort() : port; }
/** * @param protocol Scheme * @param hostname The hostname of the server */ public Host(final Protocol protocol, final String hostname) { this(protocol, hostname, protocol.getDefaultPort()); }
@Override public int getDefaultPort() { final String v = this.value("Default Port"); if(StringUtils.isBlank(v)) { return parent.getDefaultPort(); } try { return Integer.valueOf(v); } catch(NumberFormatException e) { log.warn(String.format("Port %s is not a number", e.getMessage())); } return parent.getDefaultPort(); }
int port = protocol.getDefaultPort();
@Action public void protocolComboboxClicked(NSPopUpButton sender) { final Protocol selected = ProtocolFactory.get().forName(sender.selectedItem().representedObject()); preferences.setProperty("connection.protocol.default", selected.getIdentifier()); preferences.setProperty("connection.port.default", selected.getDefaultPort()); }
log.debug(String.format("Protocol selection changed to %s", selected)); bookmark.setPort(selected.getDefaultPort()); if(!bookmark.getProtocol().isHostnameConfigurable()) {
final Host host = new Host(profile, profile.getDefaultHostname(), profile.getDefaultPort()); newDocument().addBookmark(host);
protected void configure(final FTPClient client) throws IOException { client.setProtocol(host.getProtocol()); client.setSocketFactory(new ProxySocketFactory(host.getProtocol(), new DefaultTrustManagerHostnameCallback(host))); client.setControlEncoding(host.getEncoding()); final int timeout = preferences.getInteger("connection.timeout.seconds") * 1000; client.setConnectTimeout(timeout); client.setDefaultTimeout(timeout); client.setDataTimeout(timeout); client.setDefaultPort(host.getProtocol().getDefaultPort()); client.setParserFactory(new FTPParserFactory()); client.setRemoteVerificationEnabled(preferences.getBoolean("ftp.datachannel.verify")); final int buffer = preferences.getInteger("ftp.socket.buffer"); client.setBufferSize(buffer); if(preferences.getInteger("connection.buffer.receive") > 0) { client.setReceiveBufferSize(preferences.getInteger("connection.buffer.receive")); } if(preferences.getInteger("connection.buffer.send") > 0) { client.setSendBufferSize(preferences.getInteger("connection.buffer.send")); } if(preferences.getInteger("connection.buffer.receive") > 0) { client.setReceieveDataSocketBufferSize(preferences.getInteger("connection.buffer.receive")); } if(preferences.getInteger("connection.buffer.send") > 0) { client.setSendDataSocketBufferSize(preferences.getInteger("connection.buffer.send")); } client.setStrictMultilineParsing(preferences.getBoolean("ftp.parser.multiline.strict")); client.setStrictReplyParsing(preferences.getBoolean("ftp.parser.reply.strict")); }