diff options
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/command.c | 8 | ||||
-rw-r--r-- | src/common/weechat.c | 15 | ||||
-rw-r--r-- | src/common/weechat.h | 2 | ||||
-rw-r--r-- | src/common/weeconfig.c | 10 |
4 files changed, 29 insertions, 6 deletions
diff --git a/src/common/command.c b/src/common/command.c index fa8d4bdcd..6297f28e4 100644 --- a/src/common/command.c +++ b/src/common/command.c @@ -84,13 +84,14 @@ t_weechat_command weechat_commands[] = 0, 2, weechat_cmd_python, NULL }, { "server", N_("list, add or remove servers"), N_("[servername] | " - "[servername hostname port [-auto | -noauto] [-pwd password] [-nicks nick1 " + "[servername hostname port [-auto | -noauto] [-ssl] [-pwd password] [-nicks nick1 " "[nick2 [nick3]]] [-username username] [-realname realname] " "[-command command] [-autojoin channel[,channel]] ] | " "[del servername]"), N_("servername: server name, for internal & display use\n" "hostname: name or IP address of server\n" "port: port for server (integer)\n" + "ssl: use SSL protocol\n" "password: password for server\n" "nick1: first nick for server\n" "nick2: alternate nick for server\n" @@ -1764,6 +1765,8 @@ weechat_cmd_server (int argc, char **argv) server.autoconnect = 1; if (strcasecmp (argv[i], "-noauto") == 0) server.autoconnect = 0; + if (strcasecmp (argv[i], "-ssl") == 0) + server.ssl = 1; if (strcasecmp (argv[i], "-pwd") == 0) { if (i == (argc - 1)) @@ -1851,7 +1854,8 @@ weechat_cmd_server (int argc, char **argv) new_server = server_new (server.name, server.autoconnect, server.autoreconnect, server.autoreconnect_delay, - 0, server.address, server.port, server.password, + 0, server.address, server.port, server.ssl, + server.password, server.nick1, server.nick2, server.nick3, server.username, server.realname, server.command, 1, server.autojoin, 1, NULL); diff --git a/src/common/weechat.c b/src/common/weechat.c index 3b20f3d5a..b208d56ea 100644 --- a/src/common/weechat.c +++ b/src/common/weechat.c @@ -47,6 +47,7 @@ #include <sys/stat.h> #include <time.h> #include <signal.h> +#include <gnutls/gnutls.h> #ifdef HAVE_ICONV #include <iconv.h> @@ -70,9 +71,11 @@ int sigsegv = 0; /* SIGSEGV received? char *weechat_home = NULL; /* WeeChat home dir. (example: /home/toto/.weechat) */ FILE *weechat_log_file = NULL; /* WeeChat log file (~/.weechat/weechat.log) */ -char *local_charset = NULL; /* local charset, for example: ISO-8859-1 */ +char *local_charset = NULL; /* local charset, for example: ISO-8859-1 */ -int server_cmd_line; /* at least one server on WeeChat command line */ +int server_cmd_line; /* at least one server on WeeChat command line */ + +gnutls_anon_client_credentials gnutls_anoncred; /* gnutls client credentials */ /* @@ -368,7 +371,7 @@ wee_parse_args (int argc, char *argv[]) if (!server_new (server_tmp.name, server_tmp.autoconnect, server_tmp.autoreconnect, server_tmp.autoreconnect_delay, - 1, server_tmp.address, server_tmp.port, + 1, server_tmp.address, server_tmp.port, 0, server_tmp.password, server_tmp.nick1, server_tmp.nick2, server_tmp.nick3, NULL, NULL, NULL, 0, server_tmp.autojoin, 1, NULL)) @@ -516,6 +519,10 @@ wee_init_vars () /* init received messages queue */ recv_msgq = NULL; msgq_last_msg = NULL; + + /* init gnutls */ + gnutls_global_init (); + gnutls_anon_allocate_client_credentials (&gnutls_anoncred); } /* @@ -609,6 +616,8 @@ wee_shutdown (int return_code) if (local_charset) free (local_charset); alias_free_all (); + gnutls_anon_free_client_credentials (gnutls_anoncred); + gnutls_global_deinit(); exit (return_code); } diff --git a/src/common/weechat.h b/src/common/weechat.h index 6b40fe965..77ff134ba 100644 --- a/src/common/weechat.h +++ b/src/common/weechat.h @@ -27,6 +27,7 @@ #include <stdio.h> #include <sys/time.h> +#include <gnutls/gnutls.h> #if defined(ENABLE_NLS) && !defined(_) #include <locale.h> @@ -107,6 +108,7 @@ extern int quit_weechat; extern char *weechat_home; extern char *local_charset; +extern gnutls_anon_client_credentials gnutls_anoncred; extern void wee_log_printf (char *, ...); extern void wee_dump (int); diff --git a/src/common/weeconfig.c b/src/common/weeconfig.c index c51f29332..eb94abe1d 100644 --- a/src/common/weeconfig.c +++ b/src/common/weeconfig.c @@ -650,6 +650,10 @@ t_config_option weechat_options_server[] = N_("port for connecting to server"), OPTION_TYPE_INT, 0, 65535, 6667, NULL, NULL, &(cfg_server.port), NULL, NULL }, + { "server_ssl", N_("use SSL for server communication"), + N_("use SSL for server communication"), + OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE, + NULL, NULL, &(cfg_server.ssl), NULL, NULL }, { "server_password", N_("server password"), N_("password for IRC server"), OPTION_TYPE_STRING, 0, 0, 0, @@ -920,6 +924,8 @@ config_get_server_option_ptr (t_irc_server *server, char *option_name) return (void *)(&server->address); if (strcasecmp (option_name, "server_port") == 0) return (void *)(&server->port); + if (strcasecmp (option_name, "server_ssl") == 0) + return (void *)(&server->ssl); if (strcasecmp (option_name, "server_password") == 0) return (void *)(&server->password); if (strcasecmp (option_name, "server_nick1") == 0) @@ -1095,7 +1101,7 @@ config_allocate_server (char *filename, int line_number) if (!server_new (cfg_server.name, cfg_server.autoconnect, cfg_server.autoreconnect, cfg_server.autoreconnect_delay, 0, cfg_server.address, cfg_server.port, - cfg_server.password, cfg_server.nick1, cfg_server.nick2, + cfg_server.ssl, cfg_server.password, cfg_server.nick1, cfg_server.nick2, cfg_server.nick3, cfg_server.username, cfg_server.realname, cfg_server.command, cfg_server.command_delay, cfg_server.autojoin, cfg_server.autorejoin, cfg_server.notify_levels)) @@ -1672,6 +1678,8 @@ config_write (char *config_name) ptr_server->autoreconnect_delay); fprintf (file, "server_address=%s\n", ptr_server->address); fprintf (file, "server_port=%d\n", ptr_server->port); + fprintf (file, "server_ssl=%s\n", + (ptr_server->ssl) ? "on" : "off"); fprintf (file, "server_password=%s\n", (ptr_server->password) ? ptr_server->password : ""); fprintf (file, "server_nick1=%s\n", ptr_server->nick1); |