From 6640a0891fb51b74c8377745ee1e5585f741a0be Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 18 Oct 2015 03:06:23 +0100 Subject: [PATCH] Force tls on all connections, add tls policy account property --- src/command/command.c | 81 ++++++++++++++++++++++++-- src/command/commands.c | 26 ++++++++- src/config/account.c | 10 +++- src/config/account.h | 4 +- src/config/accounts.c | 28 ++++++++- src/config/accounts.h | 3 +- src/event/client_events.c | 4 +- src/event/client_events.h | 2 +- src/ui/console.c | 3 + src/xmpp/connection.c | 32 +++++++--- src/xmpp/xmpp.h | 2 +- tests/functionaltests/proftest.c | 2 +- tests/functionaltests/test_connect.c | 2 +- tests/unittests/config/stub_accounts.c | 1 + tests/unittests/test_cmd_account.c | 14 ++--- tests/unittests/test_cmd_connect.c | 6 +- tests/unittests/test_cmd_join.c | 8 +-- tests/unittests/test_cmd_otr.c | 2 +- tests/unittests/xmpp/stub_xmpp.c | 2 +- 19 files changed, 190 insertions(+), 42 deletions(-) diff --git a/src/command/command.c b/src/command/command.c index 1b8def1a..ec8696fe 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -168,12 +168,12 @@ static struct cmd_t command_defs[] = }, { "/connect", - cmd_connect, parse_args, 0, 5, NULL, + cmd_connect, parse_args, 0, 7, NULL, CMD_TAGS( CMD_TAG_CONNECTION) CMD_SYN( "/connect []", - "/connect [server ] [port ]") + "/connect [server ] [port ] [tls force|allow|disable]") CMD_DESC( "Login to a chat service. " "If no account is specified, the default is used if one is configured. " @@ -181,12 +181,16 @@ static struct cmd_t command_defs[] = CMD_ARGS( { "", "The local account you wish to connect with, or a JID if connecting for the first time." }, { "server ", "Supply a server if it is different to the domain part of your JID." }, - { "port ", "The port to use if different to the default (5222, or 5223 for SSL)." }) + { "port ", "The port to use if different to the default (5222, or 5223 for SSL)." }, + { "tls force", "Force TLS connection, and fail if one cannot be established, this is default behaviour." }, + { "tls allow", "Use TLS for the connection if it is available." }, + { "tls disable", "Disable TLS for the connection." }) CMD_EXAMPLES( "/connect", "/connect myuser@gmail.com", "/connect myuser@mycompany.com server talk.google.com", "/connect bob@someplace port 5678", + "/connect me@localhost.test.org server 127.0.0.1 tls disable", "/connect me@chatty server chatty.com port 5443") }, @@ -1491,6 +1495,7 @@ static struct cmd_t command_defs[] = "/account set otr ", "/account set pgpkeyid ", "/account set startscript