summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2010-02-15 11:51:44 +0100
committerSebastien Helleu <flashcode@flashtux.org>2010-02-15 11:51:44 +0100
commit341551f2f2db91ee8c017e1dc65adb6dd0b188aa (patch)
treee066ba259fe7fade21468dd2f480fc6723ad13b9
parent34272b7e4dbc6bf826b50c5e83fea255fc3bea8a (diff)
downloadweechat-341551f2f2db91ee8c017e1dc65adb6dd0b188aa.zip
Add SASL authentication in IRC plugin (task #8829), add function "string_encode_base64" in plugin API, fix bug with base64 encoding
New options for IRC servers: - sasl_mechanism (only "plain" for now) - sasl_username - sasl_password
-rw-r--r--ChangeLog4
-rw-r--r--doc/en/autogen/user/irc_options.txt15
-rw-r--r--doc/en/weechat_plugin_api.en.txt27
-rw-r--r--doc/fr/autogen/user/irc_options.txt15
-rw-r--r--doc/fr/weechat_plugin_api.fr.txt28
-rw-r--r--doc/it/autogen/user/irc_options.txt15
-rw-r--r--po/cs.po31
-rw-r--r--po/de.po31
-rw-r--r--po/es.po42
-rw-r--r--po/fr.po33
-rw-r--r--po/hu.po42
-rw-r--r--po/it.po31
-rw-r--r--po/pl.po31
-rw-r--r--po/ru.po42
-rw-r--r--po/weechat.pot31
-rw-r--r--src/core/wee-network.c63
-rw-r--r--src/core/wee-string.c62
-rw-r--r--src/core/wee-string.h1
-rw-r--r--src/plugins/irc/irc-command.c11
-rw-r--r--src/plugins/irc/irc-config.c36
-rw-r--r--src/plugins/irc/irc-display.c46
-rw-r--r--src/plugins/irc/irc-protocol.c226
-rw-r--r--src/plugins/irc/irc-server.c154
-rw-r--r--src/plugins/irc/irc-server.h17
-rw-r--r--src/plugins/plugin.c1
-rw-r--r--src/plugins/weechat-plugin.h5
26 files changed, 925 insertions, 115 deletions
diff --git a/ChangeLog b/ChangeLog
index f9eee484b..08cb42daa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,7 @@
WeeChat ChangeLog
=================
FlashCode <flashcode@flashtux.org>
-v0.3.2-dev, 2010-02-12
+v0.3.2-dev, 2010-02-15
Version 0.3.2 (under dev!)
@@ -20,9 +20,11 @@ Version 0.3.2 (under dev!)
input (bug #28754)
* api: add "version_number" for function info_get to get WeeChat version as
number
+* api: add function "string_encode_base64", fix bug with base64 encoding
* api: add missing infos in functions buffer_get_integer / buffer_get_string
and in buffer infolist
* api: add description of arguments for functions hook_info and hook_infolist
+* irc: add SASL authentication (task #8829)
* irc: fix crash with SSL connection if option ssl_cert is set (bug #28752)
* irc: fix bug with SSL connection (fails sometimes when ssl_verify is on)
(bug #28741)
diff --git a/doc/en/autogen/user/irc_options.txt b/doc/en/autogen/user/irc_options.txt
index 5dcfdcc7f..2b578c097 100644
--- a/doc/en/autogen/user/irc_options.txt
+++ b/doc/en/autogen/user/irc_options.txt
@@ -308,6 +308,21 @@
** type: string
** values: any string (default value: "")
+* *irc.server_default.sasl_mechanism*
+** description: mechanism for SASL authentication
+** type: integer
+** values: plain (default value: plain)
+
+* *irc.server_default.sasl_password*
+** description: password for SASL authentication
+** type: string
+** values: any string (default value: "")
+
+* *irc.server_default.sasl_username*
+** description: username for SASL authentication
+** type: string
+** values: any string (default value: "")
+
* *irc.server_default.ssl*
** description: use SSL for server communication
** type: boolean
diff --git a/doc/en/weechat_plugin_api.en.txt b/doc/en/weechat_plugin_api.en.txt
index df447f3d8..6c5d3b518 100644
--- a/doc/en/weechat_plugin_api.en.txt
+++ b/doc/en/weechat_plugin_api.en.txt
@@ -1108,6 +1108,33 @@ str = weechat.string_remove_color(string, replacement)
str = weechat.string_remove_color(my_string, "?")
----------------------------------------
+weechat_string_encode_base64
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Encode a string in base64.
+
+Prototype:
+
+[source,C]
+----------------------------------------
+void weechat_string_encode_base64 (const char *from, int length, char *to);
+----------------------------------------
+
+Arguments:
+
+* 'from': string to encode
+* 'length': length of string to encode (for example `strlen(from)`)
+* 'to': pointer to string to store result (must be long enough)
+
+Example:
+
+[source,C]
+----------------------------------------
+char *string = "abcdefgh", result[128];
+weechat_string_encode_base64 (string, strlen (string), result);
+/* result == "YWJjZGVmZ2g=" */
+----------------------------------------
+
[[utf-8]]
UTF-8
~~~~~
diff --git a/doc/fr/autogen/user/irc_options.txt b/doc/fr/autogen/user/irc_options.txt
index fb65aa7cf..a43459358 100644
--- a/doc/fr/autogen/user/irc_options.txt
+++ b/doc/fr/autogen/user/irc_options.txt
@@ -308,6 +308,21 @@
** type: chaîne
** valeurs: toute chaîne (valeur par défaut: "")
+* *irc.server_default.sasl_mechanism*
+** description: mécanisme pour l'authentification SASL
+** type: entier
+** valeurs: plain (valeur par défaut: plain)
+
+* *irc.server_default.sasl_password*
+** description: mot de passe pour l'authentification SASL
+** type: chaîne
+** valeurs: toute chaîne (valeur par défaut: "")
+
+* *irc.server_default.sasl_username*
+** description: nom d'utilisateur pour l'authentification SASL
+** type: chaîne
+** valeurs: toute chaîne (valeur par défaut: "")
+
* *irc.server_default.ssl*
** description: utiliser SSL pour la communication avec le serveur
** type: booléen
diff --git a/doc/fr/weechat_plugin_api.fr.txt b/doc/fr/weechat_plugin_api.fr.txt
index e5e47c402..755f8bf45 100644
--- a/doc/fr/weechat_plugin_api.fr.txt
+++ b/doc/fr/weechat_plugin_api.fr.txt
@@ -1122,6 +1122,34 @@ str = weechat.string_remove_color(string, replacement)
str = weechat.string_remove_color(ma_chaine, "?")
----------------------------------------
+weechat_string_encode_base64
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Encode une chaîne en base64.
+
+Prototype :
+
+[source,C]
+----------------------------------------
+void weechat_string_encode_base64 (const char *from, int length, char *to);
+----------------------------------------
+
+Paramètres :
+
+* 'from': chaîne à encoder
+* 'length': longueur de chaîne à encoder (par exemple `strlen(from)`)
+* 'to': pointeur vers la chaîne pour stocker le résultat (doit être suffisamment
+ long)
+
+Exemple :
+
+[source,C]
+----------------------------------------
+char *string = "abcdefgh", result[128];
+weechat_string_encode_base64 (string, strlen (string), result);
+/* result == "YWJjZGVmZ2g=" */
+----------------------------------------
+
[[utf-8]]
UTF-8
~~~~~
diff --git a/doc/it/autogen/user/irc_options.txt b/doc/it/autogen/user/irc_options.txt
index 22e0547a2..5cc326e69 100644
--- a/doc/it/autogen/user/irc_options.txt
+++ b/doc/it/autogen/user/irc_options.txt
@@ -308,6 +308,21 @@
** tipo: stringa
** valori: qualsiasi stringa (valore predefinito: "")
+* *irc.server_default.sasl_mechanism*
+** descrizione: mechanism for SASL authentication
+** tipo: intero
+** valori: plain (valore predefinito: plain)
+
+* *irc.server_default.sasl_password*
+** descrizione: password for SASL authentication
+** tipo: stringa
+** valori: qualsiasi stringa (valore predefinito: "")
+
+* *irc.server_default.sasl_username*
+** descrizione: username for SASL authentication
+** tipo: stringa
+** valori: qualsiasi stringa (valore predefinito: "")
+
* *irc.server_default.ssl*
** descrizione: utilizza SSL per le comunicazioni col server
** tipo: bool
diff --git a/po/cs.po b/po/cs.po
index 87782665e..1288e1daf 100644
--- a/po/cs.po
+++ b/po/cs.po
@@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.2-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2010-02-12 16:45+0100\n"
+"POT-Creation-Date: 2010-02-15 11:45+0100\n"
"PO-Revision-Date: 2010-01-23 11:56+0100\n"
"Last-Translator: Jiri Golembiovsky <golemj@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -4027,6 +4027,15 @@ msgstr ""
msgid "password for server"
msgstr "heslo pro server"
+msgid "mechanism for SASL authentication"
+msgstr ""
+
+msgid "username for SASL authentication"
+msgstr ""
+
+msgid "password for SASL authentication"
+msgstr ""
+
msgid "automatically connect to server when WeeChat is starting"
msgstr "automaticky připojit k serveru, když je WeeChat spouštěn"
@@ -4421,6 +4430,22 @@ msgid "%s%s: this buffer is not a channel!"
msgstr "%s%s: tenhle buffer není kanál!"
#, c-format
+msgid "%s%s: client capability, server supports: %s"
+msgstr ""
+
+#, c-format
+msgid "%s%s: client capability, requesting: sasl"
+msgstr ""
+
+#, c-format
+msgid "%s%s: client capability: sasl not supported"
+msgstr ""
+
+#, c-format
+msgid "%s%s: client capability, enabled: %s"
+msgstr ""
+
+#, c-format
msgid "%sYou have been invited to %s%s%s by %s%s%s"
msgstr "%sByl jsi pozván na %s%s%s od %s%s%s"
@@ -4743,6 +4768,10 @@ msgid "%s: disconnecting from server..."
msgstr "%s: odpojuji se od serveru..."
#, c-format
+msgid "%s%s: sasl authentication timeout"
+msgstr ""
+
+#, c-format
msgid "%s: lag is high, disconnecting from server..."
msgstr "%s: zpoždění je veliké, odpojuji se od serveru..."
diff --git a/po/de.po b/po/de.po
index 33cfdeec1..169dbb7ba 100644
--- a/po/de.po
+++ b/po/de.po
@@ -10,7 +10,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.2-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2010-02-12 16:45+0100\n"
+"POT-Creation-Date: 2010-02-15 11:45+0100\n"
"PO-Revision-Date: 2010-02-09 16:11+0100\n"
"Last-Translator: Nils G <weechatter@arcor.de>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -4211,6 +4211,15 @@ msgstr "Überprüfe ob die SSL-Verbindung vertrauenswürdig ist."
msgid "password for server"
msgstr "Passwort für den Server"
+msgid "mechanism for SASL authentication"
+msgstr ""
+
+msgid "username for SASL authentication"
+msgstr ""
+
+msgid "password for SASL authentication"
+msgstr ""
+
msgid "automatically connect to server when WeeChat is starting"
msgstr "Automatisch mit dem Server verbinden, wenn WeeChat gestartet wird"
@@ -4622,6 +4631,22 @@ msgid "%s%s: this buffer is not a channel!"
msgstr "%s%s: Dieser Buffer ist kein Channel!"
#, c-format
+msgid "%s%s: client capability, server supports: %s"
+msgstr ""
+
+#, c-format
+msgid "%s%s: client capability, requesting: sasl"
+msgstr ""
+
+#, c-format
+msgid "%s%s: client capability: sasl not supported"
+msgstr ""
+
+#, c-format
+msgid "%s%s: client capability, enabled: %s"
+msgstr ""
+
+#, c-format
msgid "%sYou have been invited to %s%s%s by %s%s%s"
msgstr "%sDu bist in den Channel %s%s%s von %s%s%s eingeladen worden"
@@ -4939,6 +4964,10 @@ msgid "%s: disconnecting from server..."
msgstr "%s: Trennung vom Server..."
#, c-format
+msgid "%s%s: sasl authentication timeout"
+msgstr ""
+
+#, c-format
msgid "%s: lag is high, disconnecting from server..."
msgstr "%s: Lag ist zu hoch, die Verbindung wird getrennt..."
diff --git a/po/es.po b/po/es.po
index f7238ff08..045f2a3e7 100644
--- a/po/es.po
+++ b/po/es.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.2-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2010-02-12 16:45+0100\n"
+"POT-Creation-Date: 2010-02-15 11:45+0100\n"
"PO-Revision-Date: 2010-01-23 11:56+0100\n"
"Last-Translator: Elián Hanisch <lambdae2@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -4110,6 +4110,18 @@ msgstr "verificar que la conexión SSL es confiable completamente"
msgid "password for server"
msgstr "contraseña del servidor"
+#, fuzzy
+msgid "mechanism for SASL authentication"
+msgstr "usar SSL para la comunicación del servidor"
+
+#, fuzzy
+msgid "username for SASL authentication"
+msgstr "usar SSL para la comunicación del servidor"
+
+#, fuzzy
+msgid "password for SASL authentication"
+msgstr "usar SSL para la comunicación del servidor"
+
msgid "automatically connect to server when WeeChat is starting"
msgstr "conectarse automáticamente al servidor cuando WeeChat se inicia"
@@ -4513,6 +4525,22 @@ msgid "%s%s: this buffer is not a channel!"
msgstr "%s%s: ¡este buffer no es un canal!"
#, c-format
+msgid "%s%s: client capability, server supports: %s"
+msgstr ""
+
+#, c-format
+msgid "%s%s: client capability, requesting: sasl"
+msgstr ""
+
+#, c-format
+msgid "%s%s: client capability: sasl not supported"
+msgstr ""
+
+#, c-format
+msgid "%s%s: client capability, enabled: %s"
+msgstr ""
+
+#, c-format
msgid "%sYou have been invited to %s%s%s by %s%s%s"
msgstr "%sUsted ha sido invitado a %s%s%s por %s%s%s"
@@ -4828,6 +4856,10 @@ msgstr "(conexión cerrara por un par)"
msgid "%s: disconnecting from server..."
msgstr "%s: desconectado del servidor..."
+#, fuzzy, c-format
+msgid "%s%s: sasl authentication timeout"
+msgstr "No es posible escribir un fichero de log para un búfer\n"
+
#, c-format
msgid "%s: lag is high, disconnecting from server..."
msgstr "%s: el retraso es alto, desconectando del servidor..."
@@ -6503,10 +6535,6 @@ msgstr "entero"
#~ msgstr "usar el protocolo IPv6 para la comunicación del servidor"
#, fuzzy
-#~ msgid "use SASL for authentication"
-#~ msgstr "usar SSL para la comunicación del servidor"
-
-#, fuzzy
#~ msgid "password"
#~ msgstr "contraseña de usuario"
@@ -6764,10 +6792,6 @@ msgstr "entero"
#~ "compilado con soporte GNUtls\n"
#, fuzzy
-#~ msgid "%s%s: authentication failed"
-#~ msgstr "No es posible escribir un fichero de log para un búfer\n"
-
-#, fuzzy
#~ msgid "list of Jabber ignore"
#~ msgstr "puerto para el servidor IRC"
diff --git a/po/fr.po b/po/fr.po
index 73277ce8f..3f6606684 100644
--- a/po/fr.po
+++ b/po/fr.po
@@ -6,8 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.2-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2010-02-12 16:45+0100\n"
-"PO-Revision-Date: 2010-02-12 16:29+0100\n"
+"POT-Creation-Date: 2010-02-15 11:45+0100\n"
+"PO-Revision-Date: 2010-02-15 10:01+0100\n"
"Last-Translator: FlashCode <flashcode@flashtux.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
"MIME-Version: 1.0\n"
@@ -4160,6 +4160,15 @@ msgstr "vérifier que la connexion ssl est entièrement de confiance"
msgid "password for server"
msgstr "mot de passe pour le serveur"
+msgid "mechanism for SASL authentication"
+msgstr "mécanisme pour l'authentification SASL"
+
+msgid "username for SASL authentication"
+msgstr "nom d'utilisateur pour l'authentification SASL"
+
+msgid "password for SASL authentication"
+msgstr "mot de passe pour l'authentification SASL"
+
msgid "automatically connect to server when WeeChat is starting"
msgstr "connexion automatique au serveur quand WeeChat démarre"
@@ -4559,6 +4568,22 @@ msgid "%s%s: this buffer is not a channel!"
msgstr "%s%s: ce tampon n'est pas un canal !"
#, c-format
+msgid "%s%s: client capability, server supports: %s"
+msgstr "%s%s: client capability, le serveur supporte: %s"
+
+#, c-format
+msgid "%s%s: client capability, requesting: sasl"
+msgstr "%s%s: client capability, demande: sasl"
+
+#, c-format
+msgid "%s%s: client capability: sasl not supported"
+msgstr "%s%s: client capability: sasl non supporté"
+
+#, c-format
+msgid "%s%s: client capability, enabled: %s"
+msgstr "%s%s: client capability, activé: %s"
+
+#, c-format
msgid "%sYou have been invited to %s%s%s by %s%s%s"
msgstr "%sVous avez été invité sur %s%s%s par %s%s%s"
@@ -4877,6 +4902,10 @@ msgid "%s: disconnecting from server..."
msgstr "%s: déconnexion du serveur..."
#, c-format
+msgid "%s%s: sasl authentication timeout"
+msgstr "%s%s: délai d'authentification sasl dépassé"
+
+#, c-format
msgid "%s: lag is high, disconnecting from server..."
msgstr "%s: le lag est élevé, déconnexion du serveur..."
diff --git a/po/hu.po b/po/hu.po
index 28dda85a7..fff8970ea 100644
--- a/po/hu.po
+++ b/po/hu.po
@@ -12,7 +12,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.2-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2010-02-12 16:45+0100\n"
+"POT-Creation-Date: 2010-02-15 11:45+0100\n"
"PO-Revision-Date: 2010-01-23 11:57+0100\n"
"Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -3960,6 +3960,18 @@ msgstr ""
msgid "password for server"
msgstr "jelszó az IRC szerveren"
+#, fuzzy
+msgid "mechanism for SASL authentication"
+msgstr "SSL használata a a kapcsolathoz"
+
+#, fuzzy
+msgid "username for SASL authentication"
+msgstr "SSL használata a a kapcsolathoz"
+
+#, fuzzy
+msgid "password for SASL authentication"
+msgstr "SSL használata a a kapcsolathoz"
+
msgid "automatically connect to server when WeeChat is starting"
msgstr "automatikus csatlakozás a szerverhez a WeeChat indulásakor"
@@ -4362,6 +4374,22 @@ msgstr "%s nincs csatlakozva szerverhez!\n"
msgid "%s%s: this buffer is not a channel!"
msgstr "Ez az ablak nem egy szoba!\n"
+#, c-format
+msgid "%s%s: client capability, server supports: %s"
+msgstr ""
+
+#, c-format
+msgid "%s%s: client capability, requesting: sasl"
+msgstr ""
+
+#, c-format
+msgid "%s%s: client capability: sasl not supported"
+msgstr ""
+
+#, c-format
+msgid "%s%s: client capability, enabled: %s"
+msgstr ""
+
#, fuzzy, c-format
msgid "%sYou have been invited to %s%s%s by %s%s%s"
msgstr "Meghívást kapott a %s%s%s szobába %s%s felhasználótól\n"
@@ -4672,6 +4700,10 @@ msgid "%s: disconnecting from server..."
msgstr "Lekapcsolódott a szerverről!\n"
#, fuzzy, c-format
+msgid "%s%s: sasl authentication timeout"
+msgstr "Nem sikerült a(z) \"%s\" naplófájlt írni\n"
+
+#, fuzzy, c-format
msgid "%s: lag is high, disconnecting from server..."
msgstr "%s túl nagy a késés(lag), lecsatlakozás a szerverről...\n"
@@ -6343,10 +6375,6 @@ msgstr "perc"
#~ msgstr "IPv6 protokoll használata a kapcsolathoz"
#, fuzzy
-#~ msgid "use SASL for authentication"
-#~ msgstr "SSL használata a a kapcsolathoz"
-
-#, fuzzy
#~ msgid "password"
#~ msgstr "felhasználó jelszó"
@@ -6611,10 +6639,6 @@ msgstr "perc"
#~ "támogatás nélkül lett fordítva\n"
#, fuzzy
-#~ msgid "%s%s: authentication failed"
-#~ msgstr "Nem sikerült a(z) \"%s\" naplófájlt írni\n"
-
-#, fuzzy
#~ msgid "list of Jabber ignore"
#~ msgstr "IRC szerver portja"
diff --git a/po/it.po b/po/it.po
index 7ba5b0143..c0082d70e 100644
--- a/po/it.po
+++ b/po/it.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Weechat 0.3.2-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2010-02-12 16:45+0100\n"
+"POT-Creation-Date: 2010-02-15 11:45+0100\n"
"PO-Revision-Date: 2010-01-23 11:57+0100\n"
"Last-Translator: Marco Paolone <marcopaolone@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -4112,6 +4112,15 @@ msgstr "verifica che la connessione ssl sia totalmente fidata"
msgid "password for server"
msgstr "password per il server"
+msgid "mechanism for SASL authentication"
+msgstr ""
+
+msgid "username for SASL authentication"
+msgstr ""
+
+msgid "password for SASL authentication"
+msgstr ""
+
msgid "automatically connect to server when WeeChat is starting"
msgstr "connette automaticamente ai server all'avvio di WeeChat"
@@ -4514,6 +4523,22 @@ msgid "%s%s: this buffer is not a channel!"
msgstr "%s%s: questo buffer non è un canale!"
#, c-format
+msgid "%s%s: client capability, server supports: %s"
+msgstr ""
+
+#, c-format
+msgid "%s%s: client capability, requesting: sasl"
+msgstr ""
+
+#, c-format
+msgid "%s%s: client capability: sasl not supported"
+msgstr ""
+
+#, c-format
+msgid "%s%s: client capability, enabled: %s"
+msgstr ""
+
+#, c-format
msgid "%sYou have been invited to %s%s%s by %s%s%s"
msgstr "%sSei stato invitato su %s%s%s da %s%s%s"
@@ -4830,6 +4855,10 @@ msgid "%s: disconnecting from server..."
msgstr "%s: disconnessione dal server..."
#, c-format
+msgid "%s%s: sasl authentication timeout"
+msgstr ""
+
+#, c-format
msgid "%s: lag is high, disconnecting from server..."
msgstr "%s: ritardo eccessivo, disconnessione dal server..."
diff --git a/po/pl.po b/po/pl.po
index 469a3a64e..ff9499fb7 100644
--- a/po/pl.po
+++ b/po/pl.po
@@ -9,7 +9,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.0-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2010-02-12 16:45+0100\n"
+"POT-Creation-Date: 2010-02-15 11:45+0100\n"
"PO-Revision-Date: 2010-02-09 15:52+0100\n"
"Last-Translator: Krzysztof Koroscik <soltys@szluug.org>\n"
"Language-Team: Polish\n"
@@ -4111,6 +4111,15 @@ msgstr "sprawdź czy połączenie ssl jest w pełni zaufane"
msgid "password for server"
msgstr "hasło dla serwera"
+msgid "mechanism for SASL authentication"
+msgstr ""
+
+msgid "username for SASL authentication"
+msgstr ""
+
+msgid "password for SASL authentication"
+msgstr ""
+
msgid "automatically connect to server when WeeChat is starting"
msgstr "automatycznie połącz się z serwerem przy uruchamianiu WeeChat"
@@ -4510,6 +4519,22 @@ msgid "%s%s: this buffer is not a channel!"
msgstr "%s%s: to nie jest bufor kanału"
#, c-format
+msgid "%s%s: client capability, server supports: %s"
+msgstr ""
+
+#, c-format
+msgid "%s%s: client capability, requesting: sasl"
+msgstr ""
+
+#, c-format
+msgid "%s%s: client capability: sasl not supported"
+msgstr ""
+
+#, c-format
+msgid "%s%s: client capability, enabled: %s"
+msgstr ""
+
+#, c-format
msgid "%sYou have been invited to %s%s%s by %s%s%s"
msgstr "%sZostałeś zaproszony na %s%s%s przez %s%s%s"
@@ -4826,6 +4851,10 @@ msgid "%s: disconnecting from server..."
msgstr "%s: rozłączam z serwerem"
#, c-format
+msgid "%s%s: sasl authentication timeout"
+msgstr ""
+
+#, c-format
msgid "%s: lag is high, disconnecting from server..."
msgstr "%s: za duze opóźnienie, rozłączam z serwerem..."
diff --git a/po/ru.po b/po/ru.po
index b86542e6a..c4367f642 100644
--- a/po/ru.po
+++ b/po/ru.po
@@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.2-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2010-02-12 16:45+0100\n"
+"POT-Creation-Date: 2010-02-15 11:45+0100\n"
"PO-Revision-Date: 2010-01-23 11:57+0100\n"
"Last-Translator: Pavel Shevchuk <stlwrt@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -3961,6 +3961,18 @@ msgstr ""
msgid "password for server"
msgstr "пароль, используемый при подключении к IRC серверу"
+#, fuzzy
+msgid "mechanism for SASL authentication"
+msgstr "использовать SSL при связи с сервером"
+
+#, fuzzy
+msgid "username for SASL authentication"
+msgstr "использовать SSL при связи с сервером"
+
+#, fuzzy
+msgid "password for SASL authentication"
+msgstr "использовать SSL при связи с сервером"
+
msgid "automatically connect to server when WeeChat is starting"
msgstr "подключаться к серверу автоматически при запуске WeeChat"
@@ -4364,6 +4376,22 @@ msgstr "%s вы не подключены к серверу\n"
msgid "%s%s: this buffer is not a channel!"
msgstr "Это окно не является каналом!\n"
+#, c-format
+msgid "%s%s: client capability, server supports: %s"
+msgstr ""
+
+#, c-format
+msgid "%s%s: client capability, requesting: sasl"
+msgstr ""
+
+#, c-format
+msgid "%s%s: client capability: sasl not supported"
+msgstr ""
+
+#, c-format
+msgid "%s%s: client capability, enabled: %s"
+msgstr ""
+
#, fuzzy, c-format
msgid "%sYou have been invited to %s%s%s by %s%s%s"
msgstr "Вас пригласил на %s%s%s пользователь %s%s\n"
@@ -4680,6 +4708,10 @@ msgid "%s: disconnecting from server..."
msgstr "Отключен от сервера!\n"
#, fuzzy, c-format
+msgid "%s%s: sasl authentication timeout"
+msgstr "Не могу записать лог-файл \"%s\"\n"
+
+#, fuzzy, c-format
msgid "%s: lag is high, disconnecting from server..."
msgstr "%s задержка слишком высокая, отключаюсь от сервера...\n"
@@ -6336,10 +6368,6 @@ msgstr "минута"
#~ msgstr "использовать IPv6 при связи с сервером"
#, fuzzy
-#~ msgid "use SASL for authentication"
-#~ msgstr "использовать SSL при связи с сервером"
-
-#, fuzzy
#~ msgid "password"
#~ msgstr "пользователь пароль"
@@ -6599,10 +6627,6 @@ msgstr "минута"
#~ "без поддержки GNUtls\n"
#, fuzzy
-#~ msgid "%s%s: authentication failed"
-#~ msgstr "Не могу записать лог-файл \"%s\"\n"
-
-#, fuzzy
#~ msgid "list of Jabber ignore"
#~ msgstr "порт IRC сервера"
diff --git a/po/weechat.pot b/po/weechat.pot
index 5dd45b872..b1d199a21 100644
--- a/po/weechat.pot
+++ b/po/weechat.pot
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2010-02-12 16:45+0100\n"
+"POT-Creation-Date: 2010-02-15 11:45+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -3378,6 +3378,15 @@ msgstr ""
msgid "password for server"
msgstr ""
+msgid "mechanism for SASL authentication"
+msgstr ""
+
+msgid "username for SASL authentication"
+msgstr ""
+
+msgid "password for SASL authentication"
+msgstr ""
+
msgid "automatically connect to server when WeeChat is starting"
msgstr ""
@@ -3722,6 +3731,22 @@ msgid "%s%s: this buffer is not a channel!"
msgstr ""
#, c-format
+msgid "%s%s: client capability, server supports: %s"
+msgstr ""
+
+#, c-format
+msgid "%s%s: client capability, requesting: sasl"
+msgstr ""
+
+#, c-format
+msgid "%s%s: client capability: sasl not supported"
+msgstr ""
+
+#, c-format
+msgid "%s%s: client capability, enabled: %s"
+msgstr ""
+
+#, c-format
msgid "%sYou have been invited to %s%s%s by %s%s%s"
msgstr ""
@@ -4020,6 +4045,10 @@ msgid "%s: disconnecting from server..."
msgstr ""
#, c-format
+msgid "%s%s: sasl authentication timeout"
+msgstr ""
+
+#, c-format
msgid "%s: lag is high, disconnecting from server..."
msgstr ""
diff --git a/src/core/wee-network.c b/src/core/wee-network.c
index 60cf65521..6971c49dd 100644
--- a/src/core/wee-network.c
+++ b/src/core/wee-network.c
@@ -100,67 +100,6 @@ network_end ()
}
/*
- * network_convbase64_8x3_to_6x4 : convert 3 bytes of 8 bits in 4 bytes of 6 bits
- */
-
-void
-network_convbase64_8x3_to_6x4 (const char *from, char *to)
-{
- unsigned char base64_table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "abcdefghijklmnopqrstuvwxyz0123456789+/";
-
- to[0] = base64_table [ (from[0] & 0xfc) >> 2 ];
- to[1] = base64_table [ ((from[0] & 0x03) << 4) + ((from[1] & 0xf0) >> 4) ];
- to[2] = base64_table [ ((from[1] & 0x0f) << 2) + ((from[2] & 0xc0) >> 6) ];
- to[3] = base64_table [ from[2] & 0x3f ];
-}
-
-/*
- * network_base64encode: encode a string in base64
- */
-
-void
-network_base64encode (const char *from, char *to)
-{
- const char *f;
- char *t;
- int from_len;
-
- from_len = strlen (from);
-
- f = from;
- t = to;
-
- while (from_len >= 3)
- {
- network_convbase64_8x3_to_6x4 (f, t);
- f += 3 * sizeof (*f);
- t += 4 * sizeof (*t);
- from_len -= 3;
- }
-
- if (from_len > 0)
- {
- char rest[3] = { 0, 0, 0 };
- switch (from_len)
- {
- case 1 :
- rest[0] = f[0];
- network_convbase64_8x3_to_6x4 (rest, t);
- t[2] = t[3] = '=';
- break;
- case 2 :
- rest[0] = f[0];
- rest[1] = f[1];
- network_convbase64_8x3_to_6x4 (rest, t);
- t[3] = '=';
- break;
- }
- t[4] = 0;
- }
-}
-
-/*
* network_pass_httpproxy: establish connection/authentification to an
* http proxy
* return 1 if connection is ok
@@ -182,7 +121,7 @@ network_pass_httpproxy (struct t_proxy *proxy, int sock, const char *address,
CONFIG_STRING(proxy->options[PROXY_OPTION_USERNAME]),
(CONFIG_STRING(proxy->options[PROXY_OPTION_PASSWORD])) ?
CONFIG_STRING(proxy->options[PROXY_OPTION_PASSWORD]) : "");
- network_base64encode (authbuf, authbuf_base64);
+ string_encode_base64 (authbuf, strlen (authbuf), authbuf_base64);
n = snprintf (buffer, sizeof (buffer),
"CONNECT %s:%d HTTP/1.0\r\nProxy-Authorization: Basic %s\r\n\r\n",
address, port, authbuf_base64);
diff --git a/src/core/wee-string.c b/src/core/wee-string.c
index c13d63294..52162a55e 100644
--- a/src/core/wee-string.c
+++ b/src/core/wee-string.c
@@ -1271,3 +1271,65 @@ string_format_size (unsigned long size)
return strdup (str_size);
}
+
+/*
+ * string_convbase64_8x3_to_6x4 : convert 3 bytes of 8 bits in 4 bytes of 6 bits
+ */
+
+void
+string_convbase64_8x3_to_6x4 (const char *from, char *to)
+{
+ unsigned char base64_table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "abcdefghijklmnopqrstuvwxyz0123456789+/";
+
+ to[0] = base64_table [ (from[0] & 0xfc) >> 2 ];
+ to[1] = base64_table [ ((from[0] & 0x03) << 4) + ((from[1] & 0xf0) >> 4) ];
+ to[2] = base64_table [ ((from[1] & 0x0f) << 2) + ((from[2] & 0xc0) >> 6) ];
+ to[3] = base64_table [ from[2] & 0x3f ];
+}
+
+/*
+ * string_encode_base64: encode a string in base64
+ * length is number of bytes in "from" to convert
+ * (commonly strlen(from))
+ */
+
+void
+string_encode_base64 (const char *from, int length, char *to)
+{
+ const char *ptr_from;
+ char *ptr_to;
+
+ ptr_from = from;
+ ptr_to = to;
+
+ while (length >= 3)
+ {
+ string_convbase64_8x3_to_6x4 (ptr_from, ptr_to);
+ ptr_from += 3 * sizeof (*ptr_from);
+ ptr_to += 4 * sizeof (*ptr_to);
+ length -= 3;
+ }
+
+ if (length > 0)
+ {
+ char rest[3] = { 0, 0, 0 };
+ switch (length)
+ {
+ case 1 :
+ rest[0] = ptr_from[0];
+ string_convbase64_8x3_to_6x4 (rest, ptr_to);
+ ptr_to[2] = ptr_to[3] = '=';
+ break;
+ case 2 :
+ rest[0] = ptr_from[0];
+ rest[1] = ptr_from[1];
+ string_convbase64_8x3_to_6x4 (rest, ptr_to);
+ ptr_to[3] = '=';
+ break;
+ }
+ ptr_to[4] = 0;
+ }
+ else
+ ptr_to[0] = '\0';
+}
diff --git a/src/core/wee-string.h b/src/core/wee-string.h
index dda4bd1d9..ea77bb0f5 100644
--- a/src/core/wee-string.h
+++ b/src/core/wee-string.h
@@ -56,5 +56,6 @@ extern char *string_iconv_from_internal (const char *charset,
const char *string);
extern void string_iconv_fprintf (FILE *file, const char *data, ...);
extern char *string_format_size (unsigned long size);
+extern void string_encode_base64 (const char *from, int length, char *to);
#endif /* wee-string.h */
diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c
index d95e231f8..5f907ced2 100644
--- a/src/plugins/irc/irc-command.c
+++ b/src/plugins/irc/irc-command.c
@@ -1247,7 +1247,7 @@ irc_command_disconnect_one_server (struct t_irc_server *server)
return 0;
if ((!server->is_connected) && (!server->hook_connect)
- && (server->reconnect_start == 0))
+ && (!server->hook_fd) && (server->reconnect_start == 0))
{
weechat_printf (server->buffer,
_("%s%s: not connected to server \"%s\"!"),
@@ -1296,6 +1296,7 @@ irc_command_disconnect (void *data, struct t_gui_buffer *buffer, int argc,
ptr_server = ptr_server->next_server)
{
if ((ptr_server->is_connected) || (ptr_server->hook_connect)
+ || (ptr_server->hook_fd)
|| (ptr_server->reconnect_start != 0))
{
if (!irc_command_disconnect_one_server (ptr_server))
@@ -2853,7 +2854,7 @@ irc_command_quote (void *data, struct t_gui_buffer *buffer, int argc,
/*
* irc_command_reconnect_one_server: reconnect to a server
- * return 0 if error, 1 if ok
+ * return 0 if error, 1 if ok
*/
int
@@ -2862,7 +2863,8 @@ irc_command_reconnect_one_server (struct t_irc_server *server, int no_join)
if (!server)
return 0;
- if ((!server->is_connected) && (!server->hook_connect))
+ if ((!server->is_connected) && (!server->hook_connect)
+ && (!server->hook_fd))
{
weechat_printf (server->buffer,
_("%s%s: not connected to server \"%s\"!"),
@@ -2918,7 +2920,8 @@ irc_command_reconnect (void *data, struct t_gui_buffer *buffer, int argc,
ptr_server = ptr_server->next_server)
{
nb_reconnect++;
- if ((ptr_server->is_connected) || (ptr_server->hook_connect))
+ if ((ptr_server->is_connected) || (ptr_server->hook_connect)
+ || (ptr_server->hook_fd))
{
if (!irc_command_reconnect_one_server (ptr_server, no_join))
reconnect_ok = 0;
diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c
index ef35b67fc..aa3c4b160 100644
--- a/src/plugins/irc/irc-config.c
+++ b/src/plugins/irc/irc-config.c
@@ -964,6 +964,42 @@ irc_config_server_new_option (struct t_config_file *config_file,
callback_change, callback_change_data,
NULL, NULL);
break;
+ case IRC_SERVER_OPTION_SASL_MECHANISM:
+ new_option = weechat_config_new_option (
+ config_file, section,
+ option_name, "integer",
+ N_("mechanism for SASL authentication"),
+ "plain" /*"plain|dh-blowfish"*/, 0, 0,
+ default_value, value,
+ null_value_allowed,
+ NULL, NULL,
+ callback_change, callback_change_data,
+ NULL, NULL);
+ break;
+ case IRC_SERVER_OPTION_SASL_USERNAME:
+ new_option = weechat_config_new_option (
+ config_file, section,
+ option_name, "string",
+ N_("username for SASL authentication"),
+ NULL, 0, 0,
+ default_value, value,
+ null_value_allowed,
+ NULL, NULL,
+ callback_change, callback_change_data,
+ NULL, NULL);
+ break;
+ case IRC_SERVER_OPTION_SASL_PASSWORD:
+ new_option = weechat_config_new_option (
+ config_file, section,
+ option_name, "string",
+ N_("password for SASL authentication"),
+ NULL, 0, 0,
+ default_value, value,
+ null_value_allowed,
+ NULL, NULL,
+ callback_change, callback_change_data,
+ NULL, NULL);
+ break;
case IRC_SERVER_OPTION_AUTOCONNECT:
new_option = weechat_config_new_option (
config_file, section,
diff --git a/src/plugins/irc/irc-display.c b/src/plugins/irc/irc-display.c
index a42116a53..1476491f9 100644
--- a/src/plugins/irc/irc-display.c
+++ b/src/plugins/irc/irc-display.c
@@ -172,7 +172,7 @@ irc_display_server (struct t_irc_server *server, int with_detail)
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT,
(server->temp_server) ? _(" (temporary)") : "");
-
+ /* addresses */
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_ADDRESSES]))
weechat_printf (NULL, " addresses. . . . . . : ('%s')",
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_ADDRESSES));
@@ -180,6 +180,7 @@ irc_display_server (struct t_irc_server *server, int with_detail)
weechat_printf (NULL, " addresses. . . . . . : %s'%s'",
IRC_COLOR_CHAT_VALUE,
weechat_config_string (server->options[IRC_SERVER_OPTION_ADDRESSES]));
+ /* proxy */
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_PROXY]))
weechat_printf (NULL, " proxy. . . . . . . . : ('%s')",
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_PROXY));
@@ -187,6 +188,7 @@ irc_display_server (struct t_irc_server *server, int with_detail)
weechat_printf (NULL, " proxy. . . . . . . . : %s'%s'",
IRC_COLOR_CHAT_VALUE,
weechat_config_string (server->options[IRC_SERVER_OPTION_PROXY]));
+ /* ipv6 */
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_IPV6]))
weechat_printf (NULL, " ipv6 . . . . . . . . : (%s)",
(IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_IPV6)) ?
@@ -196,6 +198,7 @@ irc_display_server (struct t_irc_server *server, int with_detail)
IRC_COLOR_CHAT_VALUE,
weechat_config_boolean (server->options[IRC_SERVER_OPTION_IPV6]) ?
_("on") : _("off"));
+ /* ssl */
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_SSL]))
weechat_printf (NULL, " ssl. . . . . . . . . : (%s)",
(IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_SSL)) ?
@@ -205,7 +208,7 @@ irc_display_server (struct t_irc_server *server, int with_detail)
IRC_COLOR_CHAT_VALUE,
weechat_config_boolean (server->options[IRC_SERVER_OPTION_SSL]) ?
_("on") : _("off"));
-
+ /* ssl_cert */
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_SSL_CERT]))
weechat_printf (NULL, " ssl_cert . . . . . . : ('%s')",
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_SSL_CERT));
@@ -213,6 +216,7 @@ irc_display_server (struct t_irc_server *server, int with_detail)
weechat_printf (NULL, " ssl_cert . . . . . . : %s'%s'",
IRC_COLOR_CHAT_VALUE,
weechat_config_string (server->options[IRC_SERVER_OPTION_SSL_CERT]));
+ /* ssl_dhkey_size */
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_SSL_DHKEY_SIZE]))
weechat_printf (NULL, " ssl_dhkey_size . . . : (%d)",
IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_SSL_DHKEY_SIZE));
@@ -220,6 +224,7 @@ irc_display_server (struct t_irc_server *server, int with_detail)
weechat_printf (NULL, " ssl_dhkey_size . . . : %s%d",
IRC_COLOR_CHAT_VALUE,
weechat_config_integer (server->options[IRC_SERVER_OPTION_SSL_DHKEY_SIZE]));
+ /* ssl_verify */
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_SSL_VERIFY]))
weechat_printf (NULL, " ssl_verify . . . . . : (%s)",
(IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_SSL_VERIFY)) ?
@@ -229,6 +234,7 @@ irc_display_server (struct t_irc_server *server, int with_detail)
IRC_COLOR_CHAT_VALUE,
weechat_config_boolean (server->options[IRC_SERVER_OPTION_SSL_VERIFY]) ?
_("on") : _("off"));
+ /* password */
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_PASSWORD]))
weechat_printf (NULL, " password . . . . . . : %s",
_("(hidden)"));
@@ -236,6 +242,31 @@ irc_display_server (struct t_irc_server *server, int with_detail)
weechat_printf (NULL, " password . . . . . . : %s%s",
IRC_COLOR_CHAT_VALUE,
_("(hidden)"));
+ /* sasl_mechanism */
+ if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_SASL_MECHANISM]))
+ weechat_printf (NULL, " sasl_mechanism . . . : ('%s')",
+ irc_sasl_mechanism_string[IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_SASL_MECHANISM)]);
+ else
+ weechat_printf (NULL, " sasl_mechanism . . . : %s'%s'",
+ IRC_COLOR_CHAT_VALUE,
+ irc_sasl_mechanism_string[weechat_config_integer (server->options[IRC_SERVER_OPTION_SASL_MECHANISM])]);
+ /* sasl_username */
+ if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_SASL_USERNAME]))
+ weechat_printf (NULL, " sasl_username. . . . : ('%s')",
+ IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_SASL_USERNAME));
+ else
+ weechat_printf (NULL, " sasl_username. . . . : %s'%s'",
+ IRC_COLOR_CHAT_VALUE,
+ weechat_config_string (server->options[IRC_SERVER_OPTION_SASL_USERNAME]));
+ /* sasl_password */
+ if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_SASL_PASSWORD]))
+ weechat_printf (NULL, " sasl_password. . . . : %s",
+ _("(hidden)"));
+ else
+ weechat_printf (NULL, " sasl_password. . . . : %s%s",
+ IRC_COLOR_CHAT_VALUE,
+ _("(hidden)"));
+ /* autoconnect */
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_AUTOCONNECT]))
weechat_printf (NULL, " autoconnect. . . . . : (%s)",
(IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_AUTOCONNECT)) ?
@@ -245,6 +276,7 @@ irc_display_server (struct t_irc_server *server, int with_detail)
IRC_COLOR_CHAT_VALUE,
weechat_config_boolean (server->options[IRC_SERVER_OPTION_AUTOCONNECT]) ?
_("on") : _("off"));
+ /* autoreconnect */
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_AUTORECONNECT]))
weechat_printf (NULL, " autoreconnect. . . . : (%s)",
(IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_AUTORECONNECT)) ?
@@ -254,6 +286,7 @@ irc_display_server (struct t_irc_server *server, int with_detail)
IRC_COLOR_CHAT_VALUE,
weechat_config_boolean (server->options[IRC_SERVER_OPTION_AUTORECONNECT]) ?
_("on") : _("off"));
+ /* autoreconnect_delay */
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_AUTORECONNECT_DELAY]))
weechat_printf (NULL, " autoreconnect_delay. : (%d %s)",
IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_AUTORECONNECT_DELAY),
@@ -263,6 +296,7 @@ irc_display_server (struct t_irc_server *server, int with_detail)
IRC_COLOR_CHAT_VALUE,
weechat_config_integer (server->options[IRC_SERVER_OPTION_AUTORECONNECT_DELAY]),
NG_("second", "seconds", weechat_config_integer (server->options[IRC_SERVER_OPTION_AUTORECONNECT_DELAY])));
+ /* nicks */
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_NICKS]))
weechat_printf (NULL, " nicks. . . . . . . . : ('%s')",
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_NICKS));
@@ -270,6 +304,7 @@ irc_display_server (struct t_irc_server *server, int with_detail)
weechat_printf (NULL, " nicks. . . . . . . . : %s'%s'",
IRC_COLOR_CHAT_VALUE,
weechat_config_string (server->options[IRC_SERVER_OPTION_NICKS]));
+ /* username */
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_USERNAME]))
weechat_printf (NULL, " username . . . . . . : ('%s')",
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_USERNAME));
@@ -277,6 +312,7 @@ irc_display_server (struct t_irc_server *server, int with_detail)
weechat_printf (NULL, " username . . . . . . : %s'%s'",
IRC_COLOR_CHAT_VALUE,
weechat_config_string (server->options[IRC_SERVER_OPTION_USERNAME]));
+ /* realname */
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_REALNAME]))
weechat_printf (NULL, " realname . . . . . . : ('%s')",
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_REALNAME));
@@ -284,6 +320,7 @@ irc_display_server (struct t_irc_server *server, int with_detail)
weechat_printf (NULL, " realname . . . . . . : %s'%s'",
IRC_COLOR_CHAT_VALUE,
weechat_config_string (server->options[IRC_SERVER_OPTION_REALNAME]));
+ /* local_hostname */
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_LOCAL_HOSTNAME]))
weechat_printf (NULL, " local_hostname . . . : ('%s')",
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_LOCAL_HOSTNAME));
@@ -291,6 +328,7 @@ irc_display_server (struct t_irc_server *server, int with_detail)
weechat_printf (NULL, " local_hostname . . . : %s'%s'",
IRC_COLOR_CHAT_VALUE,
weechat_config_string (server->options[IRC_SERVER_OPTION_LOCAL_HOSTNAME]));
+ /* command */
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_COMMAND]))
{
string = strdup (IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_COMMAND));
@@ -312,6 +350,7 @@ irc_display_server (struct t_irc_server *server, int with_detail)
if (string)
free (string);
}
+ /* command_delay */
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_COMMAND_DELAY]))
weechat_printf (NULL, " command_delay. . . . : (%d %s)",
IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_COMMAND_DELAY),
@@ -321,6 +360,7 @@ irc_display_server (struct t_irc_server *server, int with_detail)
IRC_COLOR_CHAT_VALUE,
weechat_config_integer (server->options[IRC_SERVER_OPTION_COMMAND_DELAY]),
NG_("second", "seconds", weechat_config_integer (server->options[IRC_SERVER_OPTION_COMMAND_DELAY])));
+ /* autojoin */
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_AUTOJOIN]))
weechat_printf (NULL, " autojoin . . . . . . : ('%s')",
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_AUTOJOIN));
@@ -328,6 +368,7 @@ irc_display_server (struct t_irc_server *server, int with_detail)
weechat_printf (NULL, " autojoin . . . . . . : %s'%s'",
IRC_COLOR_CHAT_VALUE,
weechat_config_string (server->options[IRC_SERVER_OPTION_AUTOJOIN]));
+ /* autorejoin */
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_AUTOREJOIN]))
weechat_printf (NULL, " autorejoin . . . . . : (%s)",
(IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_AUTOREJOIN)) ?
@@ -337,6 +378,7 @@ irc_display_server (struct t_irc_server *server, int with_detail)
IRC_COLOR_CHAT_VALUE,
weechat_config_boolean (server->options[IRC_SERVER_OPTION_AUTOREJOIN]) ?
_("on") : _("off"));
+ /* autorejoin_delay */
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_AUTOREJOIN_DELAY]))
weechat_printf (NULL, " autorejoin_delay . . : (%d %s)",
IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_AUTOREJOIN_DELAY),
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c
index 83c09109d..8a556c3e8 100644
--- a/src/plugins/irc/irc-protocol.c
+++ b/src/plugins/irc/irc-protocol.c
@@ -216,6 +216,158 @@ irc_protocol_replace_vars (struct t_irc_server *server,
}
/*
+ * irc_protocol_cmd_authenticate: 'authenticate' message received
+ */
+
+int
+irc_protocol_cmd_authenticate (struct t_irc_server *server, const char *command,
+ int argc, char **argv, char **argv_eol)
+{
+ const char *sasl_username, *sasl_password;
+ char *string, *string_base64;
+ int length_username, length;
+
+ /* AUTHENTICATE message looks like:
+ AUTHENTICATE +
+ */
+
+ IRC_PROTOCOL_MIN_ARGS(2);
+
+ /* make C compiler happy */
+ (void) command;
+ (void) argv_eol;
+
+ if (strcmp (argv[1], "+") == 0)
+ {
+ sasl_username = IRC_SERVER_OPTION_STRING(server,
+ IRC_SERVER_OPTION_SASL_USERNAME);
+ sasl_password = IRC_SERVER_OPTION_STRING(server,
+ IRC_SERVER_OPTION_SASL_PASSWORD);
+ if (sasl_username && sasl_username[0]
+ && sasl_password && sasl_password[0])
+ {
+ length_username = strlen (sasl_username);
+ length = ((length_username + 1) * 2) + strlen (sasl_password) + 1;
+ string = malloc (length);
+ if (string)
+ {
+ snprintf (string, length, "%s|%s|%s",
+ sasl_username, sasl_username, sasl_password);
+ string[length_username] = '\0';
+ string[(length_username * 2) + 1] = '\0';
+ string_base64 = malloc (length * 2);
+ if (string_base64)
+ {
+ weechat_string_encode_base64 (string, length - 1, string_base64);
+ irc_server_sendf (server, 0, "AUTHENTICATE %s", string_base64);
+ free (string_base64);
+ }
+ free (string);
+ }
+ }
+ }
+
+ return WEECHAT_RC_OK;
+}
+
+/*
+ * irc_protocol_cmd_cap: 'cap' message received (client capability)
+ */
+
+int
+irc_protocol_cmd_cap (struct t_irc_server *server, const char *command,
+ int argc, char **argv, char **argv_eol)
+{
+ char *ptr_caps, **items;
+ int num_items, sasl, i;
+
+ /* CAP message looks like:
+ :server CAP * LS :identify-msg multi-prefix sasl
+ :server CAP * ACK :sasl
+ */
+
+ IRC_PROTOCOL_MIN_ARGS(4);
+
+ /* make C compiler happy */
+ (void) command;
+
+ if (strcmp (argv[3], "LS") == 0)
+ {
+ if (argc > 4)
+ {
+ ptr_caps = (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4];
+ weechat_printf (server->buffer,
+ _("%s%s: client capability, server supports: %s"),
+ weechat_prefix ("network"),
+ IRC_PLUGIN_NAME,
+ ptr_caps);
+ sasl = 0;
+ items = weechat_string_split (ptr_caps, " ", 0, 0, &num_items);
+ if (items)
+ {
+ for (i = 0; i < num_items; i++)
+ {
+ if (strcmp (items[i], "sasl") == 0)
+ {
+ sasl = 1;
+ break;
+ }
+ }
+ weechat_string_free_split (items);
+ }
+ if (sasl)
+ {
+ weechat_printf (server->buffer,
+ _("%s%s: client capability, requesting: sasl"),
+ weechat_prefix ("network"),
+ IRC_PLUGIN_NAME);
+ irc_server_sendf (server, 0, "CAP REQ :sasl");
+ }
+ else
+ {
+ weechat_printf (server->buffer,
+ _("%s%s: client capability: sasl not supported"),
+ weechat_prefix ("network"),
+ IRC_PLUGIN_NAME);
+ irc_server_sendf (server, 0, "CAP END");
+ }
+ }
+ }
+ else if (strcmp (argv[3], "ACK") == 0)
+ {
+ if (argc > 4)
+ {
+ ptr_caps = (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4];
+ weechat_printf (server->buffer,
+ _("%s%s: client capability, enabled: %s"),
+ weechat_prefix ("network"),
+ IRC_PLUGIN_NAME,
+ ptr_caps);
+ if (strcmp (ptr_caps, "sasl") == 0)
+ {
+ switch (IRC_SERVER_OPTION_INTEGER(server,
+ IRC_SERVER_OPTION_SASL_USERNAME))
+ {
+ case IRC_SASL_MECHANISM_PLAIN:
+ irc_server_sendf (server, 0, "AUTHENTICATE PLAIN");
+ break;
+ default:
+ irc_server_sendf (server, 0, "AUTHENTICATE PLAIN");
+ break;
+ }
+ if (server->hook_timer_sasl)
+ weechat_unhook (server->hook_timer_sasl);
+ server->hook_timer_sasl = weechat_hook_timer (5 * 1000, 0, 1,
+ &irc_server_timer_sasl_cb,
+ server);
+ }
+ }
+ }
+
+ return WEECHAT_RC_OK;
+}
+
+/*
* irc_protocol_cmd_error: error received from server
*/
@@ -3558,6 +3710,35 @@ irc_protocol_cmd_438 (struct t_irc_server *server, const char *command,
}
/*
+ * irc_protocol_cmd_900: '900' command (logged in as (SASL))
+ */
+
+int
+irc_protocol_cmd_900 (struct t_irc_server *server, const char *command,
+ int argc, char **argv, char **argv_eol)
+{
+ /* 900 message looks like:
+ :server 900 mynick nick!user@host mynick :You are now logged in as mynick
+ */
+
+ IRC_PROTOCOL_MIN_ARGS(6);
+
+ weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, argv[3],
+ command, NULL,
+ NULL),
+ irc_protocol_tags (command, "irc_numeric"),
+ "%s%s %s(%s%s%s)",
+ weechat_prefix ("network"),
+ (argv_eol[5][0] == ':') ? argv_eol[5] + 1 : argv_eol[5],
+ IRC_COLOR_CHAT_DELIMITERS,
+ IRC_COLOR_CHAT_HOST,
+ argv[3],
+ IRC_COLOR_CHAT_DELIMITERS);
+
+ return WEECHAT_RC_OK;
+}
+
+/*
* irc_protocol_cmd_901: '901' command received (you are now logged in)
*/
@@ -3588,6 +3769,44 @@ irc_protocol_cmd_901 (struct t_irc_server *server, const char *command,
}
/*
+ * irc_protocol_cmd_903: '903' command received (SASL authentication successful)
+ */
+
+int
+irc_protocol_cmd_903 (struct t_irc_server *server, const char *command,
+ int argc, char **argv, char **argv_eol)
+{
+ /* 903 message looks like:
+ :server 903 nick :SASL authentication successful
+ */
+
+ irc_protocol_cmd_numeric (server, command, argc, argv, argv_eol);
+
+ irc_server_sendf (server, 0, "CAP END");
+
+ return WEECHAT_RC_OK;
+}
+
+/*
+ * irc_protocol_cmd_904: '904' command received (SASL authentication failed)
+ */
+
+int
+irc_protocol_cmd_904 (struct t_irc_server *server, const char *command,
+ int argc, char **argv, char **argv_eol)
+{
+ /* 904 message looks like:
+ :server 904 nick :SASL authentication failed
+ */
+
+ irc_protocol_cmd_numeric (server, command, argc, argv, argv_eol);
+
+ irc_server_sendf (server, 0, "CAP END");
+
+ return WEECHAT_RC_OK;
+}
+
+/*
* irc_protocol_is_numeric_command: return 1 if given string is 100% numeric
*/
@@ -3621,7 +3840,9 @@ irc_protocol_recv_command (struct t_irc_server *server, const char *entire_line,
const char *cmd_name;
char **argv, **argv_eol;
struct t_irc_protocol_msg irc_protocol_messages[] =
- { { "error", /* error received from IRC server */ 1, &irc_protocol_cmd_error },
+ { { "authenticate", /* authenticate */ 1, &irc_protocol_cmd_authenticate },
+ { "cap", /* client capability */ 1, &irc_protocol_cmd_cap },
+ { "error", /* error received from IRC server */ 1, &irc_protocol_cmd_error },
{ "invite", /* invite a nick on a channel */ 1, &irc_protocol_cmd_invite },
{ "join", /* join a channel */ 1, &irc_protocol_cmd_join },
{ "kick", /* forcibly remove a user from a channel */ 1, &irc_protocol_cmd_kick },
@@ -3741,7 +3962,10 @@ irc_protocol_recv_command (struct t_irc_server *server, const char *entire_line,
{ "501", /* unknown mode flag */ 1, &irc_protocol_cmd_error },
{ "502", /* can't change mode for other users */ 1, &irc_protocol_cmd_error },
{ "671", /* whois (secure connection) */ 1, &irc_protocol_cmd_whois_nick_msg },
+ { "900", /* logged in as (SASL) */ 1, &irc_protocol_cmd_900 },
{ "901", /* you are now logged in */ 1, &irc_protocol_cmd_901 },
+ { "903", /* SASL authentication successful */ 1, &irc_protocol_cmd_903 },
+ { "904", /* SASL authentication failed */ 1, &irc_protocol_cmd_904 },
{ "973", /* whois (secure connection) */ 1, &irc_protocol_cmd_server_mode_reason },
{ "974", /* whois (secure connection) */ 1, &irc_protocol_cmd_server_mode_reason },
{ "975", /* whois (secure connection) */ 1, &irc_protocol_cmd_server_mode_reason },
diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c
index 0c1b8da7d..e59fc5c3b 100644
--- a/src/plugins/irc/irc-server.c
+++ b/src/plugins/irc/irc-server.c
@@ -58,19 +58,26 @@ struct t_irc_message *irc_recv_msgq = NULL;
struct t_irc_message *irc_msgq_last_msg = NULL;
char *irc_server_option_string[IRC_SERVER_NUM_OPTIONS] =
-{ "addresses", "proxy", "ipv6", "ssl", "ssl_cert", "ssl_dhkey_size",
- "ssl_verify", "password", "autoconnect", "autoreconnect",
- "autoreconnect_delay", "nicks", "username", "realname", "local_hostname",
+{ "addresses", "proxy", "ipv6",
+ "ssl", "ssl_cert", "ssl_dhkey_size", "ssl_verify",
+ "password", "sasl_mechanism", "sasl_username", "sasl_password",
+ "autoconnect", "autoreconnect", "autoreconnect_delay",
+ "nicks", "username", "realname", "local_hostname",
"command", "command_delay", "autojoin", "autorejoin", "autorejoin_delay",
};
char *irc_server_option_default[IRC_SERVER_NUM_OPTIONS] =
-{ "", "", "off", "off", "", "2048",
- "on", "", "off", "on",
- "30", "", "", "", "",
+{ "", "", "off",
+ "off", "", "2048", "on",
+ "", "plain", "", "",
+ "off", "on", "30",
+ "", "", "", "",
"", "0", "", "off", "30",
};
+char *irc_sasl_mechanism_string[IRC_NUM_SASL_MECHANISMS] =
+{ "plain", /*"dh-blowfish"*/ };
+
void irc_server_reconnect (struct t_irc_server *server);
void irc_server_check_away ();
@@ -129,6 +136,26 @@ irc_server_search_option (const char *option_name)
}
/*
+ * irc_server_sasl_enabled: return 1 if SASL is enabled on server
+ * 0 if SASL is NOT enabled on server
+ */
+
+int
+irc_server_sasl_enabled (struct t_irc_server *server)
+{
+ const char *sasl_username, *sasl_password;
+
+ sasl_username = IRC_SERVER_OPTION_STRING(server,
+ IRC_SERVER_OPTION_SASL_USERNAME);
+ sasl_password = IRC_SERVER_OPTION_STRING(server,
+ IRC_SERVER_OPTION_SASL_PASSWORD);
+
+ /* SASL is enabled if username AND password are set */
+ return (sasl_username && sasl_username[0]
+ && sasl_password && sasl_password[0]) ? 1 : 0;
+}
+
+/*
* irc_server_get_name_without_port: get name of server without port
* (ends before first '/' if found)
*/
@@ -295,6 +322,7 @@ irc_server_alloc (const char *name)
new_server->sock = -1;
new_server->hook_connect = NULL;
new_server->hook_fd = NULL;
+ new_server->hook_timer_sasl = NULL;
new_server->is_connected = 0;
new_server->ssl_connected = 0;
new_server->unterminated_message = NULL;
@@ -684,10 +712,16 @@ irc_server_free_data (struct t_irc_server *server)
free (server->ports_array);
if (server->current_ip)
free (server->current_ip);
- if (server->nicks_array)
- weechat_string_free_split (server->nicks_array);
+ if (server->hook_connect)
+ weechat_unhook (server->hook_connect);
+ if (server->hook_fd)
+ weechat_unhook (server->hook_fd);
+ if (server->hook_timer_sasl)
+ weechat_unhook (server->hook_timer_sasl);
if (server->unterminated_message)
free (server->unterminated_message);
+ if (server->nicks_array)
+ weechat_string_free_split (server->nicks_array);
if (server->nick)
free (server->nick);
if (server->nick_modes)
@@ -696,6 +730,11 @@ irc_server_free_data (struct t_irc_server *server)
free (server->prefix);
if (server->away_message)
free (server->away_message);
+ if (server->cmd_list_regexp)
+ {
+ regfree (server->cmd_list_regexp);
+ free (server->cmd_list_regexp);
+ }
for (i = 0; i < IRC_SERVER_NUM_OUTQUEUES_PRIO; i++)
{
irc_server_outqueue_free_all (server, i);
@@ -1694,6 +1733,41 @@ irc_server_recv_cb (void *arg_server, int fd)
}
/*
+ * irc_server_timer_sasl_cb: callback for SASL authentication timer
+ * it is called if there is a timeout with SASL
+ * authentication
+ * (if SASL authentication is ok or failed, then
+ * hook timer is removed before this callback is
+ * called)
+ */
+
+int
+irc_server_timer_sasl_cb (void *arg_server, int remaining_calls)
+{
+ struct t_irc_server *server;
+
+ /* make C compiler happy */
+ (void) remaining_calls;
+
+ server = (struct t_irc_server *)arg_server;
+
+ if (!server)
+ return WEECHAT_RC_ERROR;
+
+ server->hook_timer_sasl = NULL;
+
+ if (!server->is_connected)
+ {
+ weechat_printf (server->buffer,
+ _("%s%s: sasl authentication timeout"),
+ weechat_prefix ("error"), IRC_PLUGIN_NAME);
+ irc_server_sendf (server, 0, "CAP END");
+ }
+
+ return WEECHAT_RC_OK;
+}
+
+/*
* irc_server_timer_cb: timer called each second to perform some operations
* on servers
*/
@@ -1795,6 +1869,12 @@ void
irc_server_close_connection (struct t_irc_server *server)
{
int i;
+
+ if (server->hook_timer_sasl)
+ {
+ weechat_unhook (server->hook_timer_sasl);
+ server->hook_timer_sasl = NULL;
+ }
if (server->hook_fd)
{
@@ -1883,7 +1963,7 @@ void
irc_server_login (struct t_irc_server *server)
{
const char *password, *username, *realname;
-
+
password = IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_PASSWORD);
username = IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_USERNAME);
realname = IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_REALNAME);
@@ -1898,6 +1978,11 @@ irc_server_login (struct t_irc_server *server)
server->nicks_array[0] : "weechat");
}
+ if (irc_server_sasl_enabled (server))
+ {
+ irc_server_sendf (server, 0, "CAP LS");
+ }
+
irc_server_sendf (server, 0,
"NICK %s\n"
"USER %s %s %s :%s",
@@ -3276,6 +3361,15 @@ irc_server_add_to_infolist (struct t_infolist *infolist,
if (!weechat_infolist_new_var_string (ptr_item, "password",
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_PASSWORD)))
return 0;
+ if (!weechat_infolist_new_var_integer (ptr_item, "sasl_mechanism",
+ IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_SASL_MECHANISM)))
+ return 0;
+ if (!weechat_infolist_new_var_string (ptr_item, "sasl_username",
+ IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_SASL_USERNAME)))
+ return 0;
+ if (!weechat_infolist_new_var_string (ptr_item, "sasl_password",
+ IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_SASL_PASSWORD)))
+ return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "autoconnect",
IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_AUTOCONNECT)))
return 0;
@@ -3374,19 +3468,21 @@ irc_server_print_log ()
{
weechat_log_printf ("");
weechat_log_printf ("[server %s (addr:0x%lx)]", ptr_server->name, ptr_server);
-
+ /* addresses */
if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_ADDRESSES]))
weechat_log_printf (" addresses. . . . . . : null ('%s')",
IRC_SERVER_OPTION_STRING(ptr_server, IRC_SERVER_OPTION_ADDRESSES));
else
weechat_log_printf (" addresses. . . . . . : '%s'",
weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_ADDRESSES]));
+ /* proxy */
if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_PROXY]))
weechat_log_printf (" proxy. . . . . . . . : null ('%s')",
IRC_SERVER_OPTION_STRING(ptr_server, IRC_SERVER_OPTION_PROXY));
else
weechat_log_printf (" proxy. . . . . . . . : '%s'",
weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_PROXY]));
+ /* ipv6 */
if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_IPV6]))
weechat_log_printf (" ipv6 . . . . . . . . : null (%s)",
(IRC_SERVER_OPTION_BOOLEAN(ptr_server, IRC_SERVER_OPTION_IPV6)) ?
@@ -3395,6 +3491,7 @@ irc_server_print_log ()
weechat_log_printf (" ipv6 . . . . . . . . : %s",
weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_IPV6]) ?
"on" : "off");
+ /* ssl */
if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_SSL]))
weechat_log_printf (" ssl. . . . . . . . . : null (%s)",
(IRC_SERVER_OPTION_BOOLEAN(ptr_server, IRC_SERVER_OPTION_SSL)) ?
@@ -3403,18 +3500,21 @@ irc_server_print_log ()
weechat_log_printf (" ssl. . . . . . . . . : %s",
weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_SSL]) ?
"on" : "off");
+ /* ssl_cert */
if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_SSL_CERT]))
weechat_log_printf (" ssl_cert . . . . . . : null ('%s')",
IRC_SERVER_OPTION_STRING(ptr_server, IRC_SERVER_OPTION_SSL_CERT));
else
weechat_log_printf (" ssl_cert . . . . . . : '%s'",
weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_SSL_CERT]));
+ /* ssl_dhkey_size */
if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_SSL_DHKEY_SIZE]))
weechat_log_printf (" ssl_dhkey_size . . . : null ('%d')",
IRC_SERVER_OPTION_INTEGER(ptr_server, IRC_SERVER_OPTION_SSL_DHKEY_SIZE));
else
weechat_log_printf (" ssl_dhkey_size . . . : '%d'",
weechat_config_integer (ptr_server->options[IRC_SERVER_OPTION_SSL_DHKEY_SIZE]));
+ /* ssl_verify */
if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_SSL_VERIFY]))
weechat_log_printf (" ssl_verify . . . . . : null (%s)",
(IRC_SERVER_OPTION_BOOLEAN(ptr_server, IRC_SERVER_OPTION_SSL_VERIFY)) ?
@@ -3423,10 +3523,31 @@ irc_server_print_log ()
weechat_log_printf (" ssl_verify . . . . . : %s",
weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_SSL_VERIFY]) ?
"on" : "off");
+ /* password */
if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_PASSWORD]))
weechat_log_printf (" password . . . . . . : null");
else
weechat_log_printf (" password . . . . . . : (hidden)");
+ /* sasl_mechanism */
+ if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_SASL_MECHANISM]))
+ weechat_log_printf (" sasl_mechanism . . . : null ('%s')",
+ irc_sasl_mechanism_string[IRC_SERVER_OPTION_INTEGER(ptr_server, IRC_SERVER_OPTION_SASL_MECHANISM)]);
+ else
+ weechat_log_printf (" sasl_mechanism . . . : '%s'",
+ irc_sasl_mechanism_string[weechat_config_integer (ptr_server->options[IRC_SERVER_OPTION_SASL_MECHANISM])]);
+ /* sasl_username */
+ if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_SASL_USERNAME]))
+ weechat_log_printf (" sasl_username. . . . : null ('%s')",
+ IRC_SERVER_OPTION_STRING(ptr_server, IRC_SERVER_OPTION_SASL_USERNAME));
+ else
+ weechat_log_printf (" sasl_username. . . . : '%s'",
+ weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_USERNAME]));
+ /* sasl_password */
+ if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_SASL_PASSWORD]))
+ weechat_log_printf (" sasl_password. . . . : null");
+ else
+ weechat_log_printf (" sasl_password. . . . : (hidden)");
+ /* autoconnect */
if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_AUTOCONNECT]))
weechat_log_printf (" autoconnect. . . . . : null (%s)",
(IRC_SERVER_OPTION_BOOLEAN(ptr_server, IRC_SERVER_OPTION_AUTOCONNECT)) ?
@@ -3435,6 +3556,7 @@ irc_server_print_log ()
weechat_log_printf (" autoconnect. . . . . : %s",
weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_AUTOCONNECT]) ?
"on" : "off");
+ /* autoreconnect */
if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_AUTORECONNECT]))
weechat_log_printf (" autoreconnect. . . . : null (%s)",
(IRC_SERVER_OPTION_BOOLEAN(ptr_server, IRC_SERVER_OPTION_AUTORECONNECT)) ?
@@ -3443,52 +3565,61 @@ irc_server_print_log ()
weechat_log_printf (" autoreconnect. . . . : %s",
weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_AUTORECONNECT]) ?
"on" : "off");
+ /* autoreconnect_delay */
if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_AUTORECONNECT_DELAY]))
weechat_log_printf (" autoreconnect_delay. : null (%d)",
IRC_SERVER_OPTION_INTEGER(ptr_server, IRC_SERVER_OPTION_AUTORECONNECT_DELAY));
else
weechat_log_printf (" autoreconnect_delay. : %d",
weechat_config_integer (ptr_server->options[IRC_SERVER_OPTION_AUTORECONNECT_DELAY]));
+ /* nicks */
if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_NICKS]))
weechat_log_printf (" nicks. . . . . . . . : null ('%s')",
IRC_SERVER_OPTION_STRING(ptr_server, IRC_SERVER_OPTION_NICKS));
else
weechat_log_printf (" nicks. . . . . . . . : '%s'",
weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_NICKS]));
+ /* username */
if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_USERNAME]))
weechat_log_printf (" username . . . . . . : null ('%s')",
IRC_SERVER_OPTION_STRING(ptr_server, IRC_SERVER_OPTION_USERNAME));
else
weechat_log_printf (" username . . . . . . : '%s'",
weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_USERNAME]));
+ /* realname */
if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_REALNAME]))
weechat_log_printf (" realname . . . . . . : null ('%s')",
IRC_SERVER_OPTION_STRING(ptr_server, IRC_SERVER_OPTION_REALNAME));
else
weechat_log_printf (" realname . . . . . . : '%s'",
weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_REALNAME]));
+ /* local_hostname */
if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_LOCAL_HOSTNAME]))
weechat_log_printf (" local_hostname . . . : null ('%s')",
IRC_SERVER_OPTION_STRING(ptr_server, IRC_SERVER_OPTION_LOCAL_HOSTNAME));
else
weechat_log_printf (" local_hostname . . . : '%s'",
weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_LOCAL_HOSTNAME]));
+ /* command */
if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_COMMAND]))
weechat_log_printf (" command. . . . . . . : null");
else
weechat_log_printf (" command. . . . . . . : (hidden)");
+ /* command_delay */
if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_COMMAND_DELAY]))
weechat_log_printf (" command_delay. . . . : null (%d)",
IRC_SERVER_OPTION_INTEGER(ptr_server, IRC_SERVER_OPTION_COMMAND_DELAY));
else
weechat_log_printf (" command_delay. . . . : %d",
weechat_config_integer (ptr_server->options[IRC_SERVER_OPTION_COMMAND_DELAY]));
+ /* autojoin */
if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_AUTOJOIN]))
weechat_log_printf (" autojoin . . . . . . : null ('%s')",
IRC_SERVER_OPTION_STRING(ptr_server, IRC_SERVER_OPTION_AUTOJOIN));
else
weechat_log_printf (" autojoin . . . . . . : '%s'",
weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_AUTOJOIN]));
+ /* autorejoin */
if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_AUTOREJOIN]))
weechat_log_printf (" autorejoin . . . . . : null (%s)",
(IRC_SERVER_OPTION_BOOLEAN(ptr_server, IRC_SERVER_OPTION_AUTOREJOIN)) ?
@@ -3497,12 +3628,14 @@ irc_server_print_log ()
weechat_log_printf (" autorejoin . . . . . : %s",
weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_AUTOREJOIN]) ?
"on" : "off");
+ /* autorejoin_delay */
if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_AUTOREJOIN_DELAY]))
weechat_log_printf (" autorejoin_delay . . : null (%d)",
IRC_SERVER_OPTION_INTEGER(ptr_server, IRC_SERVER_OPTION_AUTOREJOIN_DELAY));
else
weechat_log_printf (" autorejoin_delay . . : %d",
weechat_config_integer (ptr_server->options[IRC_SERVER_OPTION_AUTOREJOIN_DELAY]));
+ /* other server variables */
weechat_log_printf (" temp_server. . . . . : %d", ptr_server->temp_server);
weechat_log_printf (" reloading_from_config: %d", ptr_server->reloaded_from_config);
weechat_log_printf (" reloaded_from_config : %d", ptr_server->reloaded_from_config);
@@ -3514,6 +3647,7 @@ irc_server_print_log ()
weechat_log_printf (" sock . . . . . . . . : %d", ptr_server->sock);
weechat_log_printf (" hook_connect . . . . : 0x%lx", ptr_server->hook_connect);
weechat_log_printf (" hook_fd. . . . . . . : 0x%lx", ptr_server->hook_fd);
+ weechat_log_printf (" hook_timer_sasl. . . : 0x%lx", ptr_server->hook_timer_sasl);
weechat_log_printf (" is_connected . . . . : %d", ptr_server->is_connected);
weechat_log_printf (" ssl_connected. . . . : %d", ptr_server->ssl_connected);
#ifdef HAVE_GNUTLS
diff --git a/src/plugins/irc/irc-server.h b/src/plugins/irc/irc-server.h
index 385f596e2..560fa0346 100644
--- a/src/plugins/irc/irc-server.h
+++ b/src/plugins/irc/irc-server.h
@@ -41,6 +41,9 @@ enum t_irc_server_option
IRC_SERVER_OPTION_SSL_DHKEY_SIZE, /* Diffie Hellman key size */
IRC_SERVER_OPTION_SSL_VERIFY, /* check if the connection is trusted */
IRC_SERVER_OPTION_PASSWORD, /* password for server */
+ IRC_SERVER_OPTION_SASL_MECHANISM,/* mechanism for SASL authentication */
+ IRC_SERVER_OPTION_SASL_USERNAME, /* username for SASL authentication */
+ IRC_SERVER_OPTION_SASL_PASSWORD, /* password for SASL authentication */
IRC_SERVER_OPTION_AUTOCONNECT, /* autoconnect to server at startup */
IRC_SERVER_OPTION_AUTORECONNECT, /* autoreconnect when disconnected */
IRC_SERVER_OPTION_AUTORECONNECT_DELAY, /* delay before trying again reco */
@@ -87,6 +90,16 @@ enum t_irc_server_option
#define IRC_SERVER_OUTQUEUE_PRIO_LOW 2
#define IRC_SERVER_NUM_OUTQUEUES_PRIO 2
+/* SASL authentication mechanisms */
+
+enum t_irc_sasl_mechanism
+{
+ IRC_SASL_MECHANISM_PLAIN = 0,
+ /* TODO: IRC_SASL_MECHANISM_DH_BLOWFISH, */
+ /* number of SASL mechanisms */
+ IRC_NUM_SASL_MECHANISMS,
+};
+
/* output queue of messages to server (for sending slowly to server) */
struct t_irc_outqueue
@@ -117,6 +130,7 @@ struct t_irc_server
int sock; /* socket for server (IPv4 or IPv6) */
struct t_hook *hook_connect; /* connection hook */
struct t_hook *hook_fd; /* hook for server socket */
+ struct t_hook *hook_timer_sasl; /* timer for SASL authentication */
int is_connected; /* 1 if WeeChat is connected to server */
int ssl_connected; /* = 1 if connected with SSL */
#ifdef HAVE_GNUTLS
@@ -171,9 +185,11 @@ extern const int gnutls_prot_prio[];
extern struct t_irc_message *irc_recv_msgq, *irc_msgq_last_msg;
extern char *irc_server_option_string[];
extern char *irc_server_option_default[];
+extern char *irc_sasl_mechanism_string[];
extern int irc_server_valid (struct t_irc_server *server);
extern int irc_server_search_option (const char *option_name);
+extern int irc_server_sasl_enabled (struct t_irc_server *server);
extern char *irc_server_get_name_without_port (const char *name);
extern void irc_server_set_addresses (struct t_irc_server *server,
const char *addresses);
@@ -199,6 +215,7 @@ extern int irc_server_connect (struct t_irc_server *server);
extern void irc_server_auto_connect ();
extern void irc_server_autojoin_channels ();
extern int irc_server_recv_cb (void *arg_server, int fd);
+extern int irc_server_timer_sasl_cb (void *arg_server, int remaining_calls);
extern int irc_server_timer_cb (void *data, int remaining_calls);
extern int irc_server_timer_check_away_cb (void *data, int remaining_calls);
extern void irc_server_outqueue_free_all (struct t_irc_server *server,
diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c
index 21a9437ec..4b4258471 100644
--- a/src/plugins/plugin.c
+++ b/src/plugins/plugin.c
@@ -384,6 +384,7 @@ plugin_load (const char *filename)
new_plugin->string_free_split_command = &string_free_split_command;
new_plugin->string_format_size = &string_format_size;
new_plugin->string_remove_color = &gui_color_decode;
+ new_plugin->string_encode_base64 = &string_encode_base64;
new_plugin->utf8_has_8bits = &utf8_has_8bits;
new_plugin->utf8_is_valid = &utf8_is_valid;
diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h
index 5f6a0e4e3..467e9afaa 100644
--- a/src/plugins/weechat-plugin.h
+++ b/src/plugins/weechat-plugin.h
@@ -34,7 +34,7 @@ struct t_weelist;
struct timeval;
/* API version (used to check that plugin has same API and can be loaded) */
-#define WEECHAT_PLUGIN_API_VERSION "20100212-01"
+#define WEECHAT_PLUGIN_API_VERSION "20100215-01"
/* macros for defining plugin infos */
#define WEECHAT_PLUGIN_NAME(__name) \
@@ -170,6 +170,7 @@ struct t_weechat_plugin
void (*string_free_split_command) (char **split_command);
char *(*string_format_size) (unsigned long size);
char *(*string_remove_color) (const char *string, const char *replacement);
+ void (*string_encode_base64) (const char *from, int length, char *to);
/* UTF-8 strings */
int (*utf8_has_8bits) (const char *string);
@@ -717,6 +718,8 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
weechat_plugin->string_format_size(__size)
#define weechat_string_remove_color(__string, __replacement) \
weechat_plugin->string_remove_color(__string, __replacement)
+#define weechat_string_encode_base64(__from, __length, __to) \
+ weechat_plugin->string_encode_base64(__from, __length, __to)
/* UTF-8 strings */
#define weechat_utf8_has_8bits(__string) \