Unverified Commit 4a8fafcf authored by Antenore Gatta's avatar Antenore Gatta Committed by GitHub

Merge pull request #1556 from FreeRDP/sshwifi

TCP Socket parameters as global options. Closes #1487
parents 5b0450eb 975776b9
......@@ -375,6 +375,26 @@ void remmina_pref_init(void)
else
remmina_pref.sshtunnel_port = DEFAULT_SSHTUNNEL_PORT;
if (g_key_file_has_key(gkeyfile, "remmina_pref", "ssh_tcp_keepidle", NULL))
remmina_pref.ssh_tcp_keepidle = g_key_file_get_integer(gkeyfile, "remmina_pref", "ssh_tcp_keepidle", NULL);
else
remmina_pref.ssh_tcp_keepidle = SSH_SOCKET_TCP_KEEPIDLE;
if (g_key_file_has_key(gkeyfile, "remmina_pref", "ssh_tcp_keepintvl", NULL))
remmina_pref.ssh_tcp_keepintvl = g_key_file_get_integer(gkeyfile, "remmina_pref", "ssh_tcp_keepintvl", NULL);
else
remmina_pref.ssh_tcp_keepintvl = SSH_SOCKET_TCP_KEEPINTVL;
if (g_key_file_has_key(gkeyfile, "remmina_pref", "ssh_tcp_keepcnt", NULL))
remmina_pref.ssh_tcp_keepcnt = g_key_file_get_integer(gkeyfile, "remmina_pref", "ssh_tcp_keepcnt", NULL);
else
remmina_pref.ssh_tcp_keepcnt = SSH_SOCKET_TCP_KEEPCNT;
if (g_key_file_has_key(gkeyfile, "remmina_pref", "ssh_tcp_usrtimeout", NULL))
remmina_pref.ssh_tcp_usrtimeout = g_key_file_get_integer(gkeyfile, "remmina_pref", "ssh_tcp_usrtimeout", NULL);
else
remmina_pref.ssh_tcp_usrtimeout = SSH_SOCKET_TCP_USER_TIMEOUT;
if (g_key_file_has_key(gkeyfile, "remmina_pref", "applet_new_ontop", NULL))
remmina_pref.applet_new_ontop = g_key_file_get_boolean(gkeyfile, "remmina_pref", "applet_new_ontop", NULL);
else
......@@ -747,6 +767,10 @@ void remmina_pref_save(void)
g_key_file_set_string(gkeyfile, "remmina_pref", "expanded_group", remmina_pref.expanded_group);
g_key_file_set_boolean(gkeyfile, "remmina_pref", "toolbar_pin_down", remmina_pref.toolbar_pin_down);
g_key_file_set_integer(gkeyfile, "remmina_pref", "sshtunnel_port", remmina_pref.sshtunnel_port);
g_key_file_set_integer(gkeyfile, "remmina_pref", "ssh_tcp_keepidle", remmina_pref.ssh_tcp_keepidle);
g_key_file_set_integer(gkeyfile, "remmina_pref", "ssh_tcp_keepintvl", remmina_pref.ssh_tcp_keepintvl);
g_key_file_set_integer(gkeyfile, "remmina_pref", "ssh_tcp_keepcnt", remmina_pref.ssh_tcp_keepcnt);
g_key_file_set_integer(gkeyfile, "remmina_pref", "ssh_tcp_usrtimeout", remmina_pref.ssh_tcp_usrtimeout);
g_key_file_set_boolean(gkeyfile, "remmina_pref", "applet_new_ontop", remmina_pref.applet_new_ontop);
g_key_file_set_boolean(gkeyfile, "remmina_pref", "applet_hide_count", remmina_pref.applet_hide_count);
g_key_file_set_boolean(gkeyfile, "remmina_pref", "applet_enable_avahi", remmina_pref.applet_enable_avahi);
......@@ -966,6 +990,30 @@ gint remmina_pref_get_sshtunnel_port(void)
return remmina_pref.sshtunnel_port;
}
gint remmina_pref_get_ssh_tcp_keepidle(void)
{
TRACE_CALL(__func__);
return remmina_pref.ssh_tcp_keepidle;
}
gint remmina_pref_get_ssh_tcp_keepintvl(void)
{
TRACE_CALL(__func__);
return remmina_pref.ssh_tcp_keepintvl;
}
gint remmina_pref_get_ssh_tcp_keepcnt(void)
{
TRACE_CALL(__func__);
return remmina_pref.ssh_tcp_keepcnt;
}
gint remmina_pref_get_ssh_tcp_usrtimeout(void)
{
TRACE_CALL(__func__);
return remmina_pref.ssh_tcp_usrtimeout;
}
void remmina_pref_set_value(const gchar *key, const gchar *value)
{
TRACE_CALL(__func__);
......
......@@ -113,6 +113,10 @@ typedef struct _RemminaPref {
gint ssh_loglevel;
gboolean ssh_parseconfig;
gint sshtunnel_port;
gint ssh_tcp_keepidle;
gint ssh_tcp_keepintvl;
gint ssh_tcp_keepcnt;
gint ssh_tcp_usrtimeout;
/* In RemminaPrefDialog keyboard tab */
guint hostkey;
guint shortcutkey_fullscreen;
......@@ -195,6 +199,10 @@ typedef struct _RemminaPref {
#define DEFAULT_SSHTUNNEL_PORT 4732
#define DEFAULT_SSH_PORT 22
#define DEFAULT_SSH_LOGLEVEL 1
#define SSH_SOCKET_TCP_KEEPIDLE 20
#define SSH_SOCKET_TCP_KEEPINTVL 10
#define SSH_SOCKET_TCP_KEEPCNT 3
#define SSH_SOCKET_TCP_USER_TIMEOUT 60000 // 60 seconds
extern const gchar *default_resolutions;
extern gchar *remmina_pref_file;
......@@ -215,6 +223,10 @@ gint remmina_pref_get_scale_quality(void);
gint remmina_pref_get_ssh_loglevel(void);
gboolean remmina_pref_get_ssh_parseconfig(void);
gint remmina_pref_get_sshtunnel_port(void);
gint remmina_pref_get_ssh_tcp_keepidle(void);
gint remmina_pref_get_ssh_tcp_keepintvl(void);
gint remmina_pref_get_ssh_tcp_keepcnt(void);
gint remmina_pref_get_ssh_tcp_usrtimeout(void);
void remmina_pref_set_value(const gchar *key, const gchar *value);
gchar* remmina_pref_get_value(const gchar *key);
......
......@@ -180,10 +180,22 @@ void remmina_pref_on_dialog_destroy(GtkWidget *widget, gpointer user_data)
remmina_pref.scale_quality = gtk_combo_box_get_active(remmina_pref_dialog->comboboxtext_options_scale_quality);
remmina_pref.screenshot_path = gtk_file_chooser_get_filename(remmina_pref_dialog->filechooserbutton_options_screenshots_path);
remmina_pref.ssh_loglevel = gtk_combo_box_get_active(remmina_pref_dialog->comboboxtext_options_ssh_loglevel);
remmina_pref.ssh_parseconfig = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(remmina_pref_dialog->checkbutton_options_ssh_parseconfig));
remmina_pref.sshtunnel_port = atoi(gtk_entry_get_text(remmina_pref_dialog->entry_options_ssh_port));
if (remmina_pref.sshtunnel_port <= 0)
remmina_pref.sshtunnel_port = DEFAULT_SSHTUNNEL_PORT;
remmina_pref.ssh_tcp_keepidle = atoi(gtk_entry_get_text(remmina_pref_dialog->entry_options_ssh_tcp_keepidle));
if (remmina_pref.ssh_tcp_keepidle <= 0)
remmina_pref.ssh_tcp_keepidle = SSH_SOCKET_TCP_KEEPIDLE;
remmina_pref.ssh_tcp_keepintvl = atoi(gtk_entry_get_text(remmina_pref_dialog->entry_options_ssh_tcp_keepintvl));
if (remmina_pref.ssh_tcp_keepintvl <= 0)
remmina_pref.ssh_tcp_keepintvl = SSH_SOCKET_TCP_KEEPINTVL;
remmina_pref.ssh_tcp_keepcnt = atoi(gtk_entry_get_text(remmina_pref_dialog->entry_options_ssh_tcp_keepcnt));
if (remmina_pref.ssh_tcp_keepcnt <= 0)
remmina_pref.ssh_tcp_keepcnt = SSH_SOCKET_TCP_KEEPCNT;
remmina_pref.ssh_tcp_usrtimeout = atoi(gtk_entry_get_text(remmina_pref_dialog->entry_options_ssh_tcp_usrtimeout));
if (remmina_pref.ssh_tcp_usrtimeout <= 0)
remmina_pref.ssh_tcp_usrtimeout = SSH_SOCKET_TCP_USER_TIMEOUT;
remmina_pref.ssh_parseconfig = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(remmina_pref_dialog->checkbutton_options_ssh_parseconfig));
remmina_pref.auto_scroll_step = atoi(gtk_entry_get_text(remmina_pref_dialog->entry_options_scroll));
if (remmina_pref.auto_scroll_step < 10)
......@@ -361,6 +373,14 @@ static void remmina_pref_dialog_init(void)
g_snprintf(buf, sizeof(buf), "%i", remmina_pref.sshtunnel_port);
gtk_entry_set_text(remmina_pref_dialog->entry_options_ssh_port, buf);
g_snprintf(buf, sizeof(buf), "%i", remmina_pref.ssh_tcp_keepidle);
gtk_entry_set_text(remmina_pref_dialog->entry_options_ssh_tcp_keepidle, buf);
g_snprintf(buf, sizeof(buf), "%i", remmina_pref.ssh_tcp_keepintvl);
gtk_entry_set_text(remmina_pref_dialog->entry_options_ssh_tcp_keepintvl, buf);
g_snprintf(buf, sizeof(buf), "%i", remmina_pref.ssh_tcp_keepcnt);
gtk_entry_set_text(remmina_pref_dialog->entry_options_ssh_tcp_keepcnt, buf);
g_snprintf(buf, sizeof(buf), "%i", remmina_pref.ssh_tcp_usrtimeout);
gtk_entry_set_text(remmina_pref_dialog->entry_options_ssh_tcp_usrtimeout, buf);
g_snprintf(buf, sizeof(buf), "%i", remmina_pref.auto_scroll_step);
gtk_entry_set_text(remmina_pref_dialog->entry_options_scroll, buf);
g_snprintf(buf, sizeof(buf), "%i", remmina_pref.recent_maximum);
......@@ -522,6 +542,10 @@ GtkDialog* remmina_pref_dialog_new(gint default_tab, GtkWindow *parent)
remmina_pref_dialog->comboboxtext_options_ssh_loglevel = GTK_COMBO_BOX(GET_OBJECT("comboboxtext_options_ssh_loglevel"));
remmina_pref_dialog->filechooserbutton_options_screenshots_path = GTK_FILE_CHOOSER(GET_OBJECT("filechooserbutton_options_screenshots_path"));
remmina_pref_dialog->entry_options_ssh_port = GTK_ENTRY(GET_OBJECT("entry_options_ssh_port"));
remmina_pref_dialog->entry_options_ssh_tcp_keepidle = GTK_ENTRY(GET_OBJECT("entry_options_ssh_tcp_keepidle"));
remmina_pref_dialog->entry_options_ssh_tcp_keepintvl = GTK_ENTRY(GET_OBJECT("entry_options_ssh_tcp_keepintvl"));
remmina_pref_dialog->entry_options_ssh_tcp_keepcnt = GTK_ENTRY(GET_OBJECT("entry_options_ssh_tcp_keepcnt"));
remmina_pref_dialog->entry_options_ssh_tcp_usrtimeout = GTK_ENTRY(GET_OBJECT("entry_options_ssh_tcp_usrtimeout"));
remmina_pref_dialog->entry_options_scroll = GTK_ENTRY(GET_OBJECT("entry_options_scroll"));
remmina_pref_dialog->entry_options_recent_items = GTK_ENTRY(GET_OBJECT("entry_options_recent_items"));
remmina_pref_dialog->button_options_recent_items_clear = GTK_BUTTON(GET_OBJECT("button_options_recent_items_clear"));
......
......@@ -65,6 +65,10 @@ typedef struct _RemminaPrefDialog {
GtkFileChooser *filechooserbutton_options_screenshots_path;
GtkCheckButton *checkbutton_options_ssh_parseconfig;
GtkEntry *entry_options_ssh_port;
GtkEntry *entry_options_ssh_tcp_keepidle;
GtkEntry *entry_options_ssh_tcp_keepintvl;
GtkEntry *entry_options_ssh_tcp_keepcnt;
GtkEntry *entry_options_ssh_tcp_usrtimeout;
GtkEntry *entry_options_scroll;
GtkEntry *entry_options_recent_items;
GtkButton *button_options_recent_items_clear;
......
......@@ -94,12 +94,9 @@
#endif
#endif
#define SSH_SOCKET_TCP_KEEPIDLE 20
#define SSH_SOCKET_TCP_KEEPINTVL 10
#define SSH_SOCKET_TCP_KEEPCNT 3
#define SSH_SOCKET_TCP_USER_TIMEOUT 60000 // 60 seconds
#endif
/*-----------------------------------------------------------------------------*
* SSH Base *
*-----------------------------------------------------------------------------*/
......@@ -572,29 +569,39 @@ remmina_ssh_init_session(RemminaSSH *ssh)
optval = 1;
if (setsockopt(sshsock, SOL_SOCKET, SO_KEEPALIVE, &optval, sizeof(optval)) < 0) {
remmina_log_printf("[SSH] TCP KeepAlive not set\n");
}else {
remmina_log_printf("[SSH] TCP KeepAlive enabled\n");
}
#ifdef TCP_KEEPIDLE
optval = SSH_SOCKET_TCP_KEEPIDLE;
optval = remmina_pref.ssh_tcp_keepidle;
if (setsockopt(sshsock, IPPROTO_TCP, TCP_KEEPIDLE, &optval, sizeof(optval)) < 0) {
remmina_log_printf("[SSH] TCP_KEEPIDLE not set\n");
}else {
remmina_log_printf("[SSH] TCP_KEEPIDLE set to %i\n", optval);
}
#endif
#ifdef TCP_KEEPCNT
optval = SSH_SOCKET_TCP_KEEPCNT;
optval = remmina_pref.ssh_tcp_keepcnt;
if (setsockopt(sshsock, IPPROTO_TCP, TCP_KEEPCNT, &optval, sizeof(optval)) < 0) {
remmina_log_printf("[SSH] TCP_KEEPCNT not set\n");
}else {
remmina_log_printf("[SSH] TCP_KEEPCNT set to %i\n", optval);
}
#endif
#ifdef TCP_KEEPINTVL
optval = SSH_SOCKET_TCP_KEEPINTVL;
optval = remmina_pref.ssh_tcp_keepintvl;
if (setsockopt(sshsock, IPPROTO_TCP, TCP_KEEPINTVL, &optval, sizeof(optval)) < 0) {
remmina_log_printf("[SSH] TCP_KEEPINTVL not set\n");
}else {
remmina_log_printf("[SSH] TCP_KEEPINTVL set to %i\n", optval);
}
#endif
#ifdef TCP_USER_TIMEOUT
optval = SSH_SOCKET_TCP_USER_TIMEOUT;
optval = remmina_pref.ssh_tcp_usrtimeout;
if (setsockopt(sshsock, IPPROTO_TCP, TCP_USER_TIMEOUT, &optval, sizeof(optval)) < 0) {
remmina_log_printf("[SSH] TCP_USER_TIMEOUT not set\n");
}else {
remmina_log_printf("[SSH] TCP_USER_TIMEOUT set to %i\n", optval);
}
#endif
}
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.2
<!-- Generated with glade 3.22.0
Remmina Preferences Dialog -
Copyright (C) Antenore Gatta & Giovanni Panozzo 2014-2018
......@@ -1071,6 +1071,7 @@ Author: Antenore Gatta
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="max_length">5</property>
<property name="input_purpose">number</property>
</object>
<packing>
<property name="left_attach">1</property>
......@@ -1090,7 +1091,7 @@ Author: Antenore Gatta
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
<property name="top_attach">6</property>
<property name="width">3</property>
</packing>
</child>
......@@ -1125,6 +1126,118 @@ Author: Antenore Gatta
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label_options_ssh_tcp_keepidle">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label">TCP_KEEPIDLE</property>
<property name="selectable">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label_options_ssh_tcp_keepintvl">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label">TCP_KEEPINTVL</property>
<property name="selectable">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label_options_ssh_tcp_keepcnt">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label">TCP_KEEPCNT</property>
<property name="selectable">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">4</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label_options_ssh_tcp_usrtimeout">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label">TCP_USER_TIMEOUT</property>
<property name="selectable">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">5</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="entry_options_ssh_tcp_keepidle">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip_text" translatable="yes" comments="http://man7.org/linux/man-pages/man7/tcp.7.html">The time (in seconds) the connection needs to remain idle before TCP starts sending keepalive probes.</property>
<property name="hexpand">True</property>
<property name="max_length">5</property>
<property name="input_purpose">number</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="entry_options_ssh_tcp_keepintvl">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip_text" translatable="yes" comments="http://man7.org/linux/man-pages/man7/tcp.7.html">The time (in seconds) between individual keepalive probes.</property>
<property name="hexpand">True</property>
<property name="max_length">5</property>
<property name="input_purpose">number</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">3</property>
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="entry_options_ssh_tcp_keepcnt">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip_text" translatable="yes" comments="http://man7.org/linux/man-pages/man7/tcp.7.html">The maximum number of keepalive probes TCP should send before dropping the connection.</property>
<property name="hexpand">True</property>
<property name="max_length">5</property>
<property name="input_purpose">number</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">4</property>
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="entry_options_ssh_tcp_usrtimeout">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip_text" translatable="yes" comments="http://man7.org/linux/man-pages/man7/tcp.7.html">it specifies the maximum amount of time in milliseconds that transmitted data may remain unacknowledged before TCP will forcibly close the corresponding connection.</property>
<property name="hexpand">True</property>
<property name="max_length">5</property>
<property name="input_purpose">number</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">5</property>
<property name="width">2</property>
</packing>
</child>
</object>
</child>
</object>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment