mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 17:35:35 +02:00
[218880] Apply patch from Johnson Ma: UI for SSH keepalives
This commit is contained in:
parent
e06a68c31e
commit
f9fbde8b7e
6 changed files with 94 additions and 6 deletions
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -8,18 +8,71 @@
|
|||
* Contributors:
|
||||
* Michael Scharf (Wind River) - initial API and implementation
|
||||
* Martin Oberhuber (Wind River) - fixed copyright headers and beautified
|
||||
* Johnson Ma (Wind River) - [218880] Add UI setting for ssh keepalives
|
||||
*******************************************************************************/
|
||||
package org.eclipse.tm.internal.terminal.ssh;
|
||||
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore;
|
||||
|
||||
public interface ISshSettings {
|
||||
/**
|
||||
* Get the host name or IP address of remote system to connect.
|
||||
* @return host name or IP address of the remote system.
|
||||
*/
|
||||
String getHost();
|
||||
|
||||
/**
|
||||
* Get the login name for connecting to the remote system.
|
||||
* @return remote login name
|
||||
*/
|
||||
String getUser();
|
||||
|
||||
/**
|
||||
* Get the password for connecting to the remote system.
|
||||
* May be empty if connecting via SSH public key authentication
|
||||
* (with or without passphrase).
|
||||
* @return password to use
|
||||
*/
|
||||
String getPassword();
|
||||
|
||||
/**
|
||||
* Get the timeout (in seconds) after which the SSH connection is assumed dead.
|
||||
* @return timeout (in seconds) for the SSH connection.
|
||||
*/
|
||||
int getTimeout();
|
||||
|
||||
/**
|
||||
* Get the keepalive interval (in seconds).
|
||||
* After this time of inactivity, the SSH connector will send a message to the
|
||||
* remote system in order to avoid timeouts on the remote. A maximum of 6
|
||||
* keepalive messages will be sent if enabled. When set to 0, the keepalive
|
||||
* feature is disabled.
|
||||
* @return interval (in seconds) for keepalive messages.
|
||||
*/
|
||||
int getKeepalive();
|
||||
|
||||
/**
|
||||
* Get the TCP/IP port on the remote system to use.
|
||||
* @return TCP/IP port on the remote system to use.
|
||||
*/
|
||||
int getPort();
|
||||
|
||||
/**
|
||||
* Return a human-readable String summarizing all relevant connection data.
|
||||
* This String can be displayed in the Terminal caption, for instance.
|
||||
* @return a human-readable String summarizing relevant connection data.
|
||||
*/
|
||||
String getSummary();
|
||||
|
||||
/**
|
||||
* Load connection data from a settings store.
|
||||
* @param store the settings store to access.
|
||||
*/
|
||||
void load(ISettingsStore store);
|
||||
|
||||
/**
|
||||
* Store connection data into a settings store.
|
||||
* @param store the settings store to access.
|
||||
*/
|
||||
void save(ISettingsStore store);
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
* Martin Oberhuber (Wind River) - [198790] make SSH createSession() protected
|
||||
* Mikhail Kalugin <fourdman@xored.com> - [201864] Fix Terminal SSH keyboard interactive authentication
|
||||
* Martin Oberhuber (Wind River) - [155026] Add keepalives for SSH connection
|
||||
* Johnson Ma (Wind River) - [218880] Add UI setting for ssh keepalives
|
||||
*******************************************************************************/
|
||||
package org.eclipse.tm.internal.terminal.ssh;
|
||||
|
||||
|
@ -68,7 +69,6 @@ class SshConnection extends Thread {
|
|||
Session session = service.createSession(hostname, port, username);
|
||||
//session.setTimeout(getSshTimeoutInMillis());
|
||||
session.setTimeout(0); //never time out on the session
|
||||
session.setServerAliveInterval(300000); //5 minutes
|
||||
session.setServerAliveCountMax(6); //give up after 6 tries (remote will be dead after 30 min)
|
||||
if (password != null)
|
||||
session.setPassword(password);
|
||||
|
@ -87,6 +87,7 @@ class SshConnection extends Thread {
|
|||
public void run() {
|
||||
try {
|
||||
int nTimeout = fConn.getTelnetSettings().getTimeout() * 1000;
|
||||
int nKeepalive = fConn.getTelnetSettings().getKeepalive() * 1000;
|
||||
String host = fConn.getTelnetSettings().getHost();
|
||||
String user = fConn.getTelnetSettings().getUser();
|
||||
String password = fConn.getTelnetSettings().getPassword();
|
||||
|
@ -108,6 +109,9 @@ class SshConnection extends Thread {
|
|||
//config.put("StrictHostKeyChecking", "no");
|
||||
//session.setConfig(config);
|
||||
//ui.aboutToConnect();
|
||||
if (nKeepalive > 0) {
|
||||
session.setServerAliveInterval(nKeepalive); //default is 5 minutes
|
||||
}
|
||||
session.connect(nTimeout); // making connection with timeout.
|
||||
|
||||
ChannelShell channel=(ChannelShell) session.openChannel("shell"); //$NON-NLS-1$
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -8,6 +8,7 @@
|
|||
* Contributors:
|
||||
* Michael Scharf (Wind River) - initial API and implementation
|
||||
* Martin Oberhuber (Wind River) - fixed copyright headers and beautified
|
||||
* Johnson Ma (Wind River) - [218880] Add UI setting for ssh keepalives
|
||||
*******************************************************************************/
|
||||
package org.eclipse.tm.internal.terminal.ssh;
|
||||
|
||||
|
@ -22,6 +23,8 @@ public class SshMessages extends NLS {
|
|||
public static String PORT;
|
||||
public static String PASSWORD;
|
||||
public static String TIMEOUT;
|
||||
public static String KEEPALIVE;
|
||||
public static String KEEPALIVE_Tooltip;
|
||||
public static String WARNING;
|
||||
public static String INFO;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
###############################################################################
|
||||
# Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
|
||||
# Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# are made available under the terms of the Eclipse Public License v1.0
|
||||
# which accompanies this distribution, and is available at
|
||||
|
@ -8,12 +8,15 @@
|
|||
# Contributors:
|
||||
# Michael Scharf (Wind River) - initial API and implementation
|
||||
# Martin Oberhuber (Wind River) - fixed copyright headers and beautified
|
||||
# Johnson Ma (Wind River) - [218880] Add UI setting for ssh keepalives
|
||||
###############################################################################
|
||||
HOST = Host
|
||||
USER = User
|
||||
PORT = Port
|
||||
PASSWORD = Password
|
||||
TIMEOUT = Timeout (sec)
|
||||
KEEPALIVE = KeepAlive (sec)
|
||||
KEEPALIVE_Tooltip=Interval for sending keepalive messages in case of inactivity. Enter 0 to disable keepalives.
|
||||
WARNING = Warning
|
||||
INFO = Info
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -9,6 +9,7 @@
|
|||
* Michael Scharf (Wind River) - initial API and implementation
|
||||
* Martin Oberhuber (Wind River) - fixed copyright headers and beautified
|
||||
* Mikhail Kalugin <fourdman@xored.com> - [201867] Improve Terminal SSH connection summary string
|
||||
* Johnson Ma (Wind River) - [218880] Add UI setting for ssh keepalives
|
||||
*******************************************************************************/
|
||||
package org.eclipse.tm.internal.terminal.ssh;
|
||||
|
||||
|
@ -20,6 +21,7 @@ public class SshSettings implements ISshSettings {
|
|||
protected String fPassword;
|
||||
protected String fPort;
|
||||
protected String fTimeout;
|
||||
protected String fKeepalive;
|
||||
public String getHost() {
|
||||
return fHost;
|
||||
}
|
||||
|
@ -41,6 +43,7 @@ public class SshSettings implements ISshSettings {
|
|||
fUser = store.get("User");//$NON-NLS-1$
|
||||
fPort = store.get("Port");//$NON-NLS-1$
|
||||
fTimeout = store.get("Timeout");//$NON-NLS-1$
|
||||
fKeepalive = store.get("Keepalive");//$NON-NLS-1$
|
||||
}
|
||||
|
||||
|
||||
|
@ -49,6 +52,7 @@ public class SshSettings implements ISshSettings {
|
|||
store.put("User", fUser);//$NON-NLS-1$
|
||||
store.put("Port", fPort);//$NON-NLS-1$
|
||||
store.put("Timeout", fTimeout);//$NON-NLS-1$
|
||||
store.put("Keepalive", fKeepalive);//$NON-NLS-1$
|
||||
}
|
||||
|
||||
|
||||
|
@ -66,6 +70,21 @@ public class SshSettings implements ISshSettings {
|
|||
public void setTimeout(String timeout) {
|
||||
fTimeout = timeout;
|
||||
}
|
||||
|
||||
public int getKeepalive() {
|
||||
try {
|
||||
return Integer.parseInt(fKeepalive);
|
||||
} catch (NumberFormatException numberFormatException) {
|
||||
return 300;
|
||||
}
|
||||
}
|
||||
public String getKeepaliveString() {
|
||||
return fKeepalive;
|
||||
}
|
||||
|
||||
public void setKeepalive(String keepalive) {
|
||||
fKeepalive = keepalive;
|
||||
}
|
||||
|
||||
public String getUser() {
|
||||
return fUser;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -8,6 +8,7 @@
|
|||
* Contributors:
|
||||
* Michael Scharf (Wind River) - initial API and implementation
|
||||
* Martin Oberhuber (Wind River) - fixed copyright headers and beautified
|
||||
* Johnson Ma (Wind River) - [218880] Add UI setting for ssh keepalives
|
||||
*******************************************************************************/
|
||||
package org.eclipse.tm.internal.terminal.ssh;
|
||||
|
||||
|
@ -23,6 +24,7 @@ public class SshSettingsPage implements ISettingsPage {
|
|||
private Text fHostText;
|
||||
private Text fUser;
|
||||
private Text fTimeout;
|
||||
private Text fKeepalive;
|
||||
private final SshSettings fTerminalSettings;
|
||||
private Text fPort;
|
||||
private Text fPassword;
|
||||
|
@ -36,12 +38,14 @@ public class SshSettingsPage implements ISettingsPage {
|
|||
fTerminalSettings.setPassword(fPassword.getText());
|
||||
fTerminalSettings.setPort(fPort.getText());
|
||||
fTerminalSettings.setTimeout(fTimeout.getText());
|
||||
fTerminalSettings.setKeepalive(fKeepalive.getText());
|
||||
}
|
||||
|
||||
public void loadSettings() {
|
||||
if(fTerminalSettings!=null) {
|
||||
fHostText.setText(get(fTerminalSettings.getHost(),""));//$NON-NLS-1$
|
||||
fTimeout.setText(get(fTerminalSettings.getTimeoutString(),"0"));//$NON-NLS-1$
|
||||
fKeepalive.setText(get(fTerminalSettings.getKeepaliveString(),"300"));//$NON-NLS-1$
|
||||
fUser.setText(get(fTerminalSettings.getUser(),""));//$NON-NLS-1$
|
||||
fPort.setText(get(fTerminalSettings.getPortString(),"22"));//$NON-NLS-1$
|
||||
fPassword.setText(get(fTerminalSettings.getPassword(),""));//$NON-NLS-1$
|
||||
|
@ -67,6 +71,8 @@ public class SshSettingsPage implements ISettingsPage {
|
|||
fUser = createTextField(composite, SshMessages.USER);
|
||||
fPassword = createTextField(composite, SshMessages.PASSWORD,SWT.PASSWORD);
|
||||
fTimeout = createTextField(composite, SshMessages.TIMEOUT);
|
||||
fKeepalive = createTextField(composite, SshMessages.KEEPALIVE);
|
||||
fKeepalive.setToolTipText(SshMessages.KEEPALIVE_Tooltip);
|
||||
fPort = createTextField(composite, SshMessages.PORT);
|
||||
loadSettings();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue