mirror of
https://github.com/irssi/irssi.git
synced 2024-10-27 05:20:20 -04:00
Merge pull request #1134 from horgh/horgh/tls-reconnect
Use correct TLS settings when reconnecting
This commit is contained in:
commit
156d02c5cf
@ -151,10 +151,6 @@ static int server_reconnect_timeout(void)
|
|||||||
|
|
||||||
static void sserver_connect(SERVER_SETUP_REC *rec, SERVER_CONNECT_REC *conn)
|
static void sserver_connect(SERVER_SETUP_REC *rec, SERVER_CONNECT_REC *conn)
|
||||||
{
|
{
|
||||||
conn->family = rec->family;
|
|
||||||
conn->address = g_strdup(rec->address);
|
|
||||||
if (conn->port == 0) conn->port = rec->port;
|
|
||||||
|
|
||||||
server_setup_fill_reconn(conn, rec);
|
server_setup_fill_reconn(conn, rec);
|
||||||
server_reconnect_add(conn, rec->last_connect+reconnect_time);
|
server_reconnect_add(conn, rec->last_connect+reconnect_time);
|
||||||
server_connect_unref(conn);
|
server_connect_unref(conn);
|
||||||
@ -181,10 +177,20 @@ server_connect_copy_skeleton(SERVER_CONNECT_REC *src, int connect_info)
|
|||||||
dest->tag = g_strdup(src->tag);
|
dest->tag = g_strdup(src->tag);
|
||||||
|
|
||||||
if (connect_info) {
|
if (connect_info) {
|
||||||
dest->family = src->family;
|
dest->family = src->family;
|
||||||
dest->address = g_strdup(src->address);
|
dest->address = g_strdup(src->address);
|
||||||
dest->port = src->port;
|
dest->port = src->port;
|
||||||
dest->password = g_strdup(src->password);
|
dest->password = g_strdup(src->password);
|
||||||
|
|
||||||
|
dest->use_tls = src->use_tls;
|
||||||
|
dest->tls_cert = g_strdup(src->tls_cert);
|
||||||
|
dest->tls_pkey = g_strdup(src->tls_pkey);
|
||||||
|
dest->tls_verify = src->tls_verify;
|
||||||
|
dest->tls_cafile = g_strdup(src->tls_cafile);
|
||||||
|
dest->tls_capath = g_strdup(src->tls_capath);
|
||||||
|
dest->tls_ciphers = g_strdup(src->tls_ciphers);
|
||||||
|
dest->tls_pinned_cert = g_strdup(src->tls_pinned_cert);
|
||||||
|
dest->tls_pinned_pubkey = g_strdup(src->tls_pinned_pubkey);
|
||||||
}
|
}
|
||||||
|
|
||||||
dest->chatnet = g_strdup(src->chatnet);
|
dest->chatnet = g_strdup(src->chatnet);
|
||||||
@ -207,16 +213,6 @@ server_connect_copy_skeleton(SERVER_CONNECT_REC *src, int connect_info)
|
|||||||
dest->no_autosendcmd = src->no_autosendcmd;
|
dest->no_autosendcmd = src->no_autosendcmd;
|
||||||
dest->unix_socket = src->unix_socket;
|
dest->unix_socket = src->unix_socket;
|
||||||
|
|
||||||
dest->use_tls = src->use_tls;
|
|
||||||
dest->tls_cert = g_strdup(src->tls_cert);
|
|
||||||
dest->tls_pkey = g_strdup(src->tls_pkey);
|
|
||||||
dest->tls_verify = src->tls_verify;
|
|
||||||
dest->tls_cafile = g_strdup(src->tls_cafile);
|
|
||||||
dest->tls_capath = g_strdup(src->tls_capath);
|
|
||||||
dest->tls_ciphers = g_strdup(src->tls_ciphers);
|
|
||||||
dest->tls_pinned_cert = g_strdup(src->tls_pinned_cert);
|
|
||||||
dest->tls_pinned_pubkey = g_strdup(src->tls_pinned_pubkey);
|
|
||||||
|
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,7 +289,7 @@ static void sig_reconnect(SERVER_REC *server)
|
|||||||
(!rec->last_connect || !rec->last_failed ||
|
(!rec->last_connect || !rec->last_failed ||
|
||||||
rec->last_connect < now-FAILED_RECONNECT_WAIT)) {
|
rec->last_connect < now-FAILED_RECONNECT_WAIT)) {
|
||||||
if (rec == sserver)
|
if (rec == sserver)
|
||||||
conn->port = server->connrec->port;
|
conn->port = server->connrec->port;
|
||||||
sserver_connect(rec, conn);
|
sserver_connect(rec, conn);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -108,6 +108,35 @@ void server_setup_fill_reconn(SERVER_CONNECT_REC *conn,
|
|||||||
if (sserver->password != NULL && conn->password == NULL)
|
if (sserver->password != NULL && conn->password == NULL)
|
||||||
conn->password = g_strdup(sserver->password);
|
conn->password = g_strdup(sserver->password);
|
||||||
|
|
||||||
|
if (sserver->no_proxy)
|
||||||
|
g_free_and_null(conn->proxy);
|
||||||
|
|
||||||
|
if (sserver->family != 0 && conn->family == 0)
|
||||||
|
conn->family = sserver->family;
|
||||||
|
if (sserver->address && !conn->address)
|
||||||
|
conn->address = g_strdup(sserver->address);
|
||||||
|
if (sserver->port > 0 && conn->port <= 0)
|
||||||
|
conn->port = sserver->port;
|
||||||
|
|
||||||
|
conn->use_tls = sserver->use_tls;
|
||||||
|
if (conn->tls_cert == NULL && sserver->tls_cert != NULL && sserver->tls_cert[0] != '\0')
|
||||||
|
conn->tls_cert = g_strdup(sserver->tls_cert);
|
||||||
|
if (conn->tls_pkey == NULL && sserver->tls_pkey != NULL && sserver->tls_pkey[0] != '\0')
|
||||||
|
conn->tls_pkey = g_strdup(sserver->tls_pkey);
|
||||||
|
if (conn->tls_pass == NULL && sserver->tls_pass != NULL && sserver->tls_pass[0] != '\0')
|
||||||
|
conn->tls_pass = g_strdup(sserver->tls_pass);
|
||||||
|
conn->tls_verify = sserver->tls_verify;
|
||||||
|
if (conn->tls_cafile == NULL && sserver->tls_cafile != NULL && sserver->tls_cafile[0] != '\0')
|
||||||
|
conn->tls_cafile = g_strdup(sserver->tls_cafile);
|
||||||
|
if (conn->tls_capath == NULL && sserver->tls_capath != NULL && sserver->tls_capath[0] != '\0')
|
||||||
|
conn->tls_capath = g_strdup(sserver->tls_capath);
|
||||||
|
if (conn->tls_ciphers == NULL && sserver->tls_ciphers != NULL && sserver->tls_ciphers[0] != '\0')
|
||||||
|
conn->tls_ciphers = g_strdup(sserver->tls_ciphers);
|
||||||
|
if (conn->tls_pinned_cert == NULL && sserver->tls_pinned_cert != NULL && sserver->tls_pinned_cert[0] != '\0')
|
||||||
|
conn->tls_pinned_cert = g_strdup(sserver->tls_pinned_cert);
|
||||||
|
if (conn->tls_pinned_pubkey == NULL && sserver->tls_pinned_pubkey != NULL && sserver->tls_pinned_pubkey[0] != '\0')
|
||||||
|
conn->tls_pinned_pubkey = g_strdup(sserver->tls_pinned_pubkey);
|
||||||
|
|
||||||
signal_emit("server setup fill reconn", 2, conn, sserver);
|
signal_emit("server setup fill reconn", 2, conn, sserver);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,33 +188,6 @@ static void server_setup_fill_server(SERVER_CONNECT_REC *conn,
|
|||||||
|
|
||||||
sserver->last_connect = time(NULL);
|
sserver->last_connect = time(NULL);
|
||||||
|
|
||||||
if (sserver->no_proxy)
|
|
||||||
g_free_and_null(conn->proxy);
|
|
||||||
|
|
||||||
if (sserver->family != 0 && conn->family == 0)
|
|
||||||
conn->family = sserver->family;
|
|
||||||
if (sserver->port > 0 && conn->port <= 0)
|
|
||||||
conn->port = sserver->port;
|
|
||||||
|
|
||||||
conn->use_tls = sserver->use_tls;
|
|
||||||
if (conn->tls_cert == NULL && sserver->tls_cert != NULL && sserver->tls_cert[0] != '\0')
|
|
||||||
conn->tls_cert = g_strdup(sserver->tls_cert);
|
|
||||||
if (conn->tls_pkey == NULL && sserver->tls_pkey != NULL && sserver->tls_pkey[0] != '\0')
|
|
||||||
conn->tls_pkey = g_strdup(sserver->tls_pkey);
|
|
||||||
if (conn->tls_pass == NULL && sserver->tls_pass != NULL && sserver->tls_pass[0] != '\0')
|
|
||||||
conn->tls_pass = g_strdup(sserver->tls_pass);
|
|
||||||
conn->tls_verify = sserver->tls_verify;
|
|
||||||
if (conn->tls_cafile == NULL && sserver->tls_cafile != NULL && sserver->tls_cafile[0] != '\0')
|
|
||||||
conn->tls_cafile = g_strdup(sserver->tls_cafile);
|
|
||||||
if (conn->tls_capath == NULL && sserver->tls_capath != NULL && sserver->tls_capath[0] != '\0')
|
|
||||||
conn->tls_capath = g_strdup(sserver->tls_capath);
|
|
||||||
if (conn->tls_ciphers == NULL && sserver->tls_ciphers != NULL && sserver->tls_ciphers[0] != '\0')
|
|
||||||
conn->tls_ciphers = g_strdup(sserver->tls_ciphers);
|
|
||||||
if (conn->tls_pinned_cert == NULL && sserver->tls_pinned_cert != NULL && sserver->tls_pinned_cert[0] != '\0')
|
|
||||||
conn->tls_pinned_cert = g_strdup(sserver->tls_pinned_cert);
|
|
||||||
if (conn->tls_pinned_pubkey == NULL && sserver->tls_pinned_pubkey != NULL && sserver->tls_pinned_pubkey[0] != '\0')
|
|
||||||
conn->tls_pinned_pubkey = g_strdup(sserver->tls_pinned_pubkey);
|
|
||||||
|
|
||||||
server_setup_fill_reconn(conn, sserver);
|
server_setup_fill_reconn(conn, sserver);
|
||||||
|
|
||||||
signal_emit("server setup fill server", 2, conn, sserver);
|
signal_emit("server setup fill server", 2, conn, sserver);
|
||||||
|
Loading…
Reference in New Issue
Block a user