1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-29 14:26:39 +02:00

api: add constants for IPv6 and allow force of IPv6 in function hook_connect (issue #2164)

This commit is contained in:
Sébastien Helleu
2024-07-27 10:01:02 +02:00
parent ab2bcbac4e
commit e051af0376
11 changed files with 153 additions and 67 deletions
+1
View File
@@ -8,6 +8,7 @@
- **breaking:** core, plugins: force "short_name" in buffers to non-empty value (name by default), remove buffer property "short_name_is_set"
- **breaking:** alias: display an error with `/alias add` or `/alias addcompletion` when the alias already exists, add options `addreplace` and `addreplacecompletion` in command `/alias` ([#2095](https://github.com/weechat/weechat/issues/2095))
- **breaking:** irc: rename parameter `-re` to `-raw` in command `/list` ([#2124](https://github.com/weechat/weechat/issues/2124))
- **breaking:** api: add constants for IPv6 and allow force of IPv6 in function hook_connect ([#2164](https://github.com/weechat/weechat/issues/2164))
- core: add option `addreplace` in commands `/bar` and `/proxy` ([#2095](https://github.com/weechat/weechat/issues/2095))
- irc: add option `addreplace` in commands `/ignore`, `/notify` and `/server` ([#2095](https://github.com/weechat/weechat/issues/2095))
- relay: add option `addreplace` in commands `/relay` and `/remote` ([#2095](https://github.com/weechat/weechat/issues/2095))
+21 -13
View File
@@ -11126,7 +11126,7 @@ hook2 = weechat.hook_url("http://localhost:8080/", options, 20000, "my_url_cb",
==== hook_connect
_Updated in 1.5, 2.0._
_Updated in 1.5, 2.0, 4.4.0._
Hook a connection (background connection to a remote host).
@@ -11161,7 +11161,10 @@ Arguments:
without proxy)
* _address_: name or IP address to connect to
* _port_: port number
* _ipv6_: 1 to use IPv6 (with fallback to IPv4), 0 to use only IPv4
* _ipv6_:
** `WEECHAT_HOOK_CONNECT_IPV6_DISABLE` ^(1)^: disable IPv6 (use only IPv4)
** `WEECHAT_HOOK_CONNECT_IPV6_AUTO` ^(1)^: use IPv6 with fallback to IPv4
** `WEECHAT_HOOK_CONNECT_IPV6_FORCE` ^(1)^: force IPv6 (do not use IPv4) _(WeeChat ≥ 4.4.0)_
* _retry_: retry count, used to fallback to IPv4 hosts if IPv6 hosts connect
but then fail to accept the client
* _gnutls_sess_: GnuTLS session (optional)
@@ -11181,7 +11184,7 @@ Arguments:
return value:
** _const void *pointer_: pointer
** _void *data_: pointer
** _int status_: connection status:
** _int status_: connection status ^(2)^:
*** _WEECHAT_HOOK_CONNECT_OK_: connection OK
*** _WEECHAT_HOOK_CONNECT_ADDRESS_NOT_FOUND_: address not found
*** _WEECHAT_HOOK_CONNECT_IP_ADDRESS_NOT_FOUND_: IP address not found
@@ -11193,8 +11196,8 @@ Arguments:
*** _WEECHAT_HOOK_CONNECT_MEMORY_ERROR_: insufficient memory
*** _WEECHAT_HOOK_CONNECT_TIMEOUT_: timeout
*** _WEECHAT_HOOK_CONNECT_SOCKET_ERROR_: unable to create socket
** _gnutls_rc_: return value of _gnutls_handshake()_
** _sock_: socket used to connect
** _gnutls_rc_: return value of _gnutls_handshake()_ ^(2)^
** _sock_: socket used to connect ^(2)^
** _const char *error_: return value of _gnutls_strerror(gnutls_rc)_
** _const char *ip_address_: IP address found
** return value:
@@ -11205,16 +11208,19 @@ Arguments:
if not NULL, it must have been allocated with malloc (or similar function)
and it is automatically freed when the hook is deleted
Return value:
* pointer to new hook, NULL if error occurred
[IMPORTANT]
In scripts, with WeeChat ≥ 2.0, the callback arguments _status_, _gnutls_rc_
[NOTE]
^(1)^ Constants for parameter _ipv6_ are available since WeeChat 4.4.0. +
For older releases, allowed values are `1` (use IPv6 with fallback to IPv4) and
`0` (disable IPv6, use only IPv4). +
^(2)^ In scripts, with WeeChat ≥ 2.0, the callback arguments _status_, _gnutls_rc_
and _sock_ are integers (with WeeChat ≤ 1.9, they were strings). +
To be compatible with all versions, it is recommended to convert the argument
to integer before using it, for example in Python: `int(sock)`.
Return value:
* pointer to new hook, NULL if error occurred
C example:
[source,c]
@@ -11264,7 +11270,8 @@ my_connect_cb (const void *pointer, void *data, int status, int gnutls_rc,
struct t_hook *my_connect_hook = weechat_hook_connect (NULL,
"my.server.org", 1234,
1, 0,
WEECHAT_HOOK_CONNECT_IPV6_AUTO,
0,
NULL, NULL, 0, /* GnuTLS */
NULL,
&my_connect_cb, NULL, NULL);
@@ -11304,7 +11311,8 @@ def my_connect_cb(data: str, status: int, gnutls_rc: int, sock: int, error: str,
# ...
return weechat.WEECHAT_RC_OK
hook = weechat.hook_connect("", "my.server.org", 1234, 1, 0, "",
hook = weechat.hook_connect("", "my.server.org", 1234,
weechat.WEECHAT_HOOK_CONNECT_IPV6_AUTO, 0, "",
"my_connect_cb", "")
----
+22 -14
View File
@@ -11338,7 +11338,7 @@ hook2 = weechat.hook_url("http://localhost:8080/", options, 20000, "my_url_cb",
==== hook_connect
_Mis à jour dans la 1.5, 2.0._
_Mis à jour dans la 1.5, 2.0, 4.4.0._
Accrocher une connexion (connexion à une machine distante en tâche de fond).
@@ -11373,8 +11373,10 @@ Paramètres :
une connexion sans proxy)
* _address_ : nom ou adresse IP de la machine à laquelle se connecter
* _port_ : numéro de port
* _ipv6_ : 1 pour utiliser IPv6 (avec repli sur IPv4), 0 pour utiliser seulement
IPv4
* _ipv6_:
** `WEECHAT_HOOK_CONNECT_IPV6_DISABLE` ^(1)^: désactiver IPv6 (utiliser seulement IPv4)
** `WEECHAT_HOOK_CONNECT_IPV6_AUTO` ^(1)^: utiliser IPv6 avec repli sur IPv4
** `WEECHAT_HOOK_CONNECT_IPV6_FORCE` ^(1)^: forcer IPv6 (ne pas utiliser IPv4) _(WeeChat ≥ 4.4.0)_
* _retry_ : numéro de nouvelle tentative, utilisé pour se rabattre sur les
adresses IPv4 si la connexion IPv6 échoue
* _gnutls_sess_ : session GnuTLS (optionnel)
@@ -11396,7 +11398,7 @@ Paramètres :
paramètres et valeur de retour :
** _const void *pointer_ : pointeur
** _void *data_ : pointeur
** _int status_ : statut de connexion :
** _int status_ : statut de connexion ^(2)^:
*** _WEECHAT_HOOK_CONNECT_OK_ : connexion ok
*** _WEECHAT_HOOK_CONNECT_ADDRESS_NOT_FOUND_ : adresse non trouvée
*** _WEECHAT_HOOK_CONNECT_IP_ADDRESS_NOT_FOUND_ : adresse IP non trouvée
@@ -11409,8 +11411,8 @@ Paramètres :
*** _WEECHAT_HOOK_CONNECT_MEMORY_ERROR_ : mémoire insuffisante
*** _WEECHAT_HOOK_CONNECT_TIMEOUT_ : temps maximum dépassé
*** _WEECHAT_HOOK_CONNECT_SOCKET_ERROR_ : erreur de création socket
** _gnutls_rc_ : valeur retour de _gnutls_handshake()_
** _sock_ : socket utilisé pour la connexion
** _gnutls_rc_ : valeur retour de _gnutls_handshake()_ ^(2)^
** _sock_ : socket utilisé pour la connexion ^(2)^
** _const char *error_ : valeur retour de _gnutls_strerror(gnutls_rc)_
** _const char *ip_address_ : adresse IP trouvée
** valeur de retour :
@@ -11423,17 +11425,21 @@ Paramètres :
fonction similaire) et est automatiquement libéré (par free) lorsque le
"hook" est supprimé
Valeur de retour :
* pointeur vers le nouveau "hook", NULL en cas d'erreur
[IMPORTANT]
Dans les scripts, avec WeeChat ≥ 2.0, les paramètres de la fonction de rappel
[NOTE]
^(1)^ Les constantes pour le paramètre _ipv6_ sont disponibles à partir de
WeeChat 4.4.0. +
Pour les versions plus anciennes, les valeurs autorisées sont `1` (utiliser IPv6
avec repli sur IPv4) et `0` (désactiver IPv6, utiliser seulement IPv4). +
^(2)^ Dans les scripts, avec WeeChat ≥ 2.0, les paramètres de la fonction de rappel
_status_, _gnutls_rc_ et _sock_ sont des entiers (avec WeeChat ≤ 1.9, ils étaient
des chaînes). +
Pour être compatible avec toutes les versions, il est recommandé de convertir
le paramètre avant de l'utiliser, par exemple en Python: `int(sock)`.
Valeur de retour :
* pointeur vers le nouveau "hook", NULL en cas d'erreur
Exemple en C :
[source,c]
@@ -11483,7 +11489,8 @@ my_connect_cb (const void *pointer, void *data, int status, int gnutls_rc,
struct t_hook *my_connect_hook = weechat_hook_connect (NULL,
"my.server.org", 1234,
1, 0,
WEECHAT_HOOK_CONNECT_IPV6_AUTO,
0,
NULL, NULL, 0, /* GnuTLS */
NULL,
&my_connect_cb, NULL, NULL);
@@ -11523,7 +11530,8 @@ def my_connect_cb(data: str, status: int, gnutls_rc: int, sock: int, error: str,
# ...
return weechat.WEECHAT_RC_OK
hook = weechat.hook_connect("", "my.server.org", 1234, 1, 0, "",
hook = weechat.hook_connect("", "my.server.org", 1234,
weechat.WEECHAT_HOOK_CONNECT_IPV6_AUTO, 0, "",
"my_connect_cb", "")
----
+24 -13
View File
@@ -11543,7 +11543,7 @@ hook2 = weechat.hook_url("http://localhost:8080/", options, 20000, "my_url_cb",
==== hook_connect
// TRANSLATION MISSING
_Updated in 1.5, 2.0._
_Updated in 1.5, 2.0, 4.4.0._
Hook su una connessione (connessione in secondo piano ad un host remoto).
@@ -11579,7 +11579,13 @@ Argomenti:
* _address_: nome o indirizzo IP al quale connettersi
* _port_: numero della porta
// TRANSLATION MISSING
* _ipv6_: 1 to use IPv6 (with fallback to IPv4), 0 to use only IPv4
* _ipv6_:
// TRANSLATION MISSING
** `WEECHAT_HOOK_CONNECT_IPV6_DISABLE` ^(1)^: disable IPv6 (use only IPv4)
// TRANSLATION MISSING
** `WEECHAT_HOOK_CONNECT_IPV6_AUTO` ^(1)^: use IPv6 with fallback to IPv4
// TRANSLATION MISSING
** `WEECHAT_HOOK_CONNECT_IPV6_FORCE` ^(1)^: force IPv6 (do not use IPv4) _(WeeChat ≥ 4.4.0)_
// TRANSLATION MISSING
* _retry_: retry count, used to fallback to IPv4 hosts if IPv6 hosts connect
but then fail to accept the client
@@ -11602,7 +11608,7 @@ Argomenti:
successo oppure no, argomenti e valore restituito:
** _const void *pointer_: puntatore
** _void *data_: puntatore
** _int status_: stato della connessione:
** _int status_: stato della connessione ^(2)^:
*** _WEECHAT_HOOK_CONNECT_OK_: connessione avvenuta con successo
*** _WEECHAT_HOOK_CONNECT_ADDRESS_NOT_FOUND_: indirizzo non trovato
*** _WEECHAT_HOOK_CONNECT_IP_ADDRESS_NOT_FOUND_: indirizzo IP non trovato
@@ -11614,8 +11620,8 @@ Argomenti:
*** _WEECHAT_HOOK_CONNECT_MEMORY_ERROR_: memoria insufficiente
*** _WEECHAT_HOOK_CONNECT_TIMEOUT_: timeout
*** _WEECHAT_HOOK_CONNECT_SOCKET_ERROR_: errore nella creazione socket
** _gnutls_rc_: valore del risultato di _gnutls_handshake()_
** _sock_: socket utilizzato per la connessione
** _gnutls_rc_: valore del risultato di _gnutls_handshake()_ ^(2)^
** _sock_: socket utilizzato per la connessione ^(2)^
** _const char *error_: valore del risultato di _gnutls_strerror(gnutls_rc)_
** _const char *ip_address_: indirizzo IP trovato
** valore restituito:
@@ -11627,17 +11633,20 @@ Argomenti:
if not NULL, it must have been allocated with malloc (or similar function)
and it is automatically freed when the hook is deleted
Valore restituito:
* puntatore al nuovo hook, NULL in caso di errore
// TRANSLATION MISSING
[IMPORTANT]
In scripts, with WeeChat ≥ 2.0, the callback arguments _status_, _gnutls_rc_
[NOTE]
^(1)^ Constants for parameter _ipv6_ are available since WeeChat 4.4.0. +
For older releases, allowed values are `1` (use IPv6 with fallback to IPv4) and
`0` (disable IPv6, use only IPv4). +
^(2)^ In scripts, with WeeChat ≥ 2.0, the callback arguments _status_, _gnutls_rc_
and _sock_ are integers (with WeeChat ≤ 1.9, they were strings). +
To be compatible with all versions, it is recommended to convert the argument
to integer before using it, for example in Python: `int(sock)`.
Valore restituito:
* puntatore al nuovo hook, NULL in caso di errore
Esempio in C:
[source,c]
@@ -11687,7 +11696,8 @@ my_connect_cb (const void *pointer, void *data, int status, int gnutls_rc,
struct t_hook *my_connect_hook = weechat_hook_connect (NULL,
"my.server.org", 1234,
1, 0,
WEECHAT_HOOK_CONNECT_IPV6_AUTO,
0,
NULL, NULL, 0, /* GnuTLS */
NULL,
&my_connect_cb, NULL, NULL);
@@ -11727,7 +11737,8 @@ def my_connect_cb(data: str, status: int, gnutls_rc: int, sock: int, error: str,
# ...
return weechat.WEECHAT_RC_OK
hook = weechat.hook_connect("", "my.server.org", 1234, 1, 0, "",
hook = weechat.hook_connect("", "my.server.org", 1234,
weechat.WEECHAT_HOOK_CONNECT_IPV6_AUTO, 0, "",
"my_connect_cb", "")
----
+26 -13
View File
@@ -11273,7 +11273,8 @@ hook2 = weechat.hook_url("http://localhost:8080/", options, 20000, "my_url_cb",
==== hook_connect
_WeeChat バージョン 1.5 と 2.0 で更新。_
// TRANSLATION MISSING
_Updated in 1.5, 2.0, 4.4.0._
接続をフックする (リモートホストへのバックグラウンド接続)。
@@ -11308,7 +11309,13 @@ struct t_hook *weechat_hook_connect (const char *proxy,
(任意、プロキシを使わない場合は NULL)
* _address_: 接続先のドメイン名または IP アドレス
* _port_: ポート番号
* _ipv6_: (IPv4 フォールバックを有効にして) IPv6 を使う場合は 1、IPv4 のみを使う場合は 0
* _ipv6_:
// TRANSLATION MISSING
** `WEECHAT_HOOK_CONNECT_IPV6_DISABLE` ^(1)^: disable IPv6 (use only IPv4)
// TRANSLATION MISSING
** `WEECHAT_HOOK_CONNECT_IPV6_AUTO` ^(1)^: use IPv6 with fallback to IPv4
// TRANSLATION MISSING
** `WEECHAT_HOOK_CONNECT_IPV6_FORCE` ^(1)^: force IPv6 (do not use IPv4) _(WeeChat ≥ 4.4.0)_
* _retry_: 再試行回数、IPv6 ホストに接続したもののクライアントの受け入れに失敗した際に
IPv4 ホストへフォールバックする際に使う
* _gnutls_sess_: GnuTLS セッション (任意)
@@ -11328,7 +11335,7 @@ struct t_hook *weechat_hook_connect (const char *proxy,
接続に成功および失敗した際に呼び出すコールバック関数、引数と戻り値:
** _const void *pointer_: ポインタ
** _void *data_: ポインタ
** _int status_: 接続状態:
** _int status_: 接続状態 ^(2)^:
*** _WEECHAT_HOOK_CONNECT_OK_: 接続成功
*** _WEECHAT_HOOK_CONNECT_ADDRESS_NOT_FOUND_: アドレスが見つかりません
*** _WEECHAT_HOOK_CONNECT_IP_ADDRESS_NOT_FOUND_: IP アドレスが見つかりません
@@ -11340,8 +11347,8 @@ struct t_hook *weechat_hook_connect (const char *proxy,
*** _WEECHAT_HOOK_CONNECT_MEMORY_ERROR_: メモリ不足
*** _WEECHAT_HOOK_CONNECT_TIMEOUT_: タイムアウト
*** _WEECHAT_HOOK_CONNECT_SOCKET_ERROR_: ソケットの作成に失敗
** _gnutls_rc_: _gnutls_handshake()_ の戻り値
** _sock_: 接続に使うソケット
** _gnutls_rc_: _gnutls_handshake()_ の戻り値 ^(2)^
** _sock_: 接続に使うソケット ^(2)^
** _const char *error_: _gnutls_strerror(gnutls_rc)_ の戻り値
** _const char *ip_address_: 見つかった IP アドレス
** 戻り値:
@@ -11352,16 +11359,20 @@ struct t_hook *weechat_hook_connect (const char *proxy,
このポインタが NULL でない場合、このポインタは malloc (または類似の関数)
によって割り当てられたものでなければいけません。さらに、このポインタはここで作成したフックが削除された時点で自動的に開放されます
戻り値:
* 新しいフックへのポインタ、エラーが起きた場合は NULL
[IMPORTANT]
スクリプトにおけるコールバック引数 _status_、_gnutls_rc_、_sock_ は
// TRANSLATION MISSING
[NOTE]
^(1)^ Constants for parameter _ipv6_ are available since WeeChat 4.4.0. +
For older releases, allowed values are `1` (use IPv6 with fallback to IPv4) and
`0` (disable IPv6, use only IPv4). +
^(2)^ スクリプトにおけるコールバック引数 _status_、_gnutls_rc_、_sock_ は
WeeChat バージョン 2.0 以上では整数、バージョン 1.9 以下では文字列です。 +
すべてのバージョンで互換性を保つには、使用前にコールバック引数 _status_、_gnutls_rc_、_sock_
を整数へ変換することを推奨します (Python の場合 `int(sock)` のように変換してください)。
戻り値:
* 新しいフックへのポインタ、エラーが起きた場合は NULL
C 言語での使用例:
[source,c]
@@ -11411,7 +11422,8 @@ my_connect_cb (const void *pointer, void *data, int status, int gnutls_rc,
struct t_hook *my_connect_hook = weechat_hook_connect (NULL,
"my.server.org", 1234,
1, 0,
WEECHAT_HOOK_CONNECT_IPV6_AUTO,
0,
NULL, NULL, 0, /* GnuTLS */
NULL,
&my_connect_cb, NULL, NULL);
@@ -11451,7 +11463,8 @@ def my_connect_cb(data: str, status: int, gnutls_rc: int, sock: int, error: str,
# ...
return weechat.WEECHAT_RC_OK
hook = weechat.hook_connect("", "my.server.org", 1234, 1, 0, "",
hook = weechat.hook_connect("", "my.server.org", 1234,
weechat.WEECHAT_HOOK_CONNECT_IPV6_AUTO, 0, "",
"my_connect_cb", "")
----
+23 -11
View File
@@ -10843,7 +10843,7 @@ hook2 = weechat.hook_url("http://localhost:8080/", options, 20000, "my_url_cb",
==== hook_connect
_Ажурирано у верзијама 1.5, 2.0._
_Ажурирано у верзијама 1.5, 2.0, 4.4.0._
Качи се на везу (везу у позадини са удаљеним хостом).
@@ -10877,7 +10877,13 @@ struct t_hook *weechat_hook_connect (const char *proxy,
* _proxy_: име проксија који се користи за везу (није обавезно, NULL значи да је веза без проксија)
* _address_: име или IP адреса са којом се повезује
* _port_: број порта
* _ipv6_: 1 да се користи IPv6 (или IPv4 у случају да не може), 0 да се користи само IPv4
* _ipv6_:
// TRANSLATION MISSING
** `WEECHAT_HOOK_CONNECT_IPV6_DISABLE` ^(1)^: disable IPv6 (use only IPv4)
// TRANSLATION MISSING
** `WEECHAT_HOOK_CONNECT_IPV6_AUTO` ^(1)^: use IPv6 with fallback to IPv4
// TRANSLATION MISSING
** `WEECHAT_HOOK_CONNECT_IPV6_FORCE` ^(1)^: force IPv6 (do not use IPv4) _(WeeChat ≥ 4.4.0)_
* _retry_: број поновних покушаја, користи се за прелаз на IPv4 хостове ако се IPv6 хостови успостављају везу али онда не прихватају клијента
* _gnutls_sess_: GnuTLS сесија (није обавезна)
* _gnutls_cb_: GnuTLS функција повратног позива (није обавезна)
@@ -10893,7 +10899,7 @@ struct t_hook *weechat_hook_connect (const char *proxy,
* _callback_: функција која се позива када је веза OK или не успе да се успостави, аргументи и повратна вредност су:
** _const void *pointer_: показивач
** _void *data_: показивач
** _int status_: статус везе:
** _int status_: статус везе ^(2)^:
*** _WEECHAT_HOOK_CONNECT_OK_: веза је OK
*** _WEECHAT_HOOK_CONNECT_ADDRESS_NOT_FOUND_: адреса није пронађена
*** _WEECHAT_HOOK_CONNECT_IP_ADDRESS_NOT_FOUND_: IP адреса није пронађена
@@ -10905,8 +10911,8 @@ struct t_hook *weechat_hook_connect (const char *proxy,
*** _WEECHAT_HOOK_CONNECT_MEMORY_ERROR_: нема довољно слободне меморије
*** _WEECHAT_HOOK_CONNECT_TIMEOUT_: тајмаут
*** _WEECHAT_HOOK_CONNECT_SOCKET_ERROR_: сокет није могао да се креира
** _gnutls_rc_: повратна вредност функције _gnutls_handshake()_
** _sock_: сокет који се употребљен за везу
** _gnutls_rc_: повратна вредност функције _gnutls_handshake()_ ^(2)^
** _sock_: сокет који се употребљен за везу ^(2)^
** _const char *error_: повратна вредност _gnutls_strerror(gnutls_rc)_
** _const char *ip_address_: IP адреса није нађена
** повратна вредност:
@@ -10915,14 +10921,18 @@ struct t_hook *weechat_hook_connect (const char *proxy,
* _callback_pointer_: показивач који се прослеђује функцији повратног позива када је позове програм WeeChat
* _callback_data_: показивач који се прослеђује функцији повратног позива када је позове програм WeeChat; ако није NULL, алоцирала га је malloc (или нека слична функција) и аутоматски се ослобађа када се кука обрише
// TRANSLATION MISSING
[NOTE]
^(1)^ Constants for parameter _ipv6_ are available since WeeChat 4.4.0. +
For older releases, allowed values are `1` (use IPv6 with fallback to IPv4) and
`0` (disable IPv6, use only IPv4). +
^(2)^ У скриптама и програмом WeeChat ≥ 2.0, аргументи функције повратног позива _status_, _gnutls_rc_ и _sock_ су цели бројеви (у програму WeeChat ≤ 1.9, били су стрингови). +
Да би се одржала компатибилност са свим верзијама, препоручује се да аргумент пре употребе конвертујете у цео број, на пример у језику Python: `int(sock)`.
Повратна вредност:
* показивач на нову куку, NULL у случају грешке
[IMPORTANT]
У скриптама и програмом WeeChat ≥ 2.0, аргументи функције повратног позива _status_, _gnutls_rc_ и _sock_ су цели бројеви (у програму WeeChat ≤ 1.9, били су стрингови). +
Да би се одржала компатибилност са свим верзијама, препоручује се да аргумент пре употребе конвертујете у цео број, на пример у језику Python: `int(sock)`.
C пример:
[source,c]
@@ -10972,7 +10982,8 @@ my_connect_cb (const void *pointer, void *data, int status, int gnutls_rc,
struct t_hook *my_connect_hook = weechat_hook_connect (NULL,
"my.server.org", 1234,
1, 0,
WEECHAT_HOOK_CONNECT_IPV6_AUTO,
0,
NULL, NULL, 0, /* GnuTLS */
NULL,
&my_connect_cb, NULL, NULL);
@@ -11012,7 +11023,8 @@ def my_connect_cb(data: str, status: int, gnutls_rc: int, sock: int, error: str,
# ...
return weechat.WEECHAT_RC_OK
hook = weechat.hook_connect("", "my.server.org", 1234, 1, 0, "",
hook = weechat.hook_connect("", "my.server.org", 1234,
weechat.WEECHAT_HOOK_CONNECT_IPV6_AUTO, 0, "",
"my_connect_cb", "")
----
+19 -1
View File
@@ -1002,7 +1002,25 @@ network_connect_child (struct t_hook *hook_connect)
}
else
{
hints.ai_family = HOOK_CONNECT(hook_connect, ipv6) ? AF_UNSPEC : AF_INET;
switch (HOOK_CONNECT(hook_connect, ipv6))
{
case WEECHAT_HOOK_CONNECT_IPV6_DISABLE:
/* force IPv4 */
hints.ai_family = AF_INET;
break;
case WEECHAT_HOOK_CONNECT_IPV6_AUTO:
/* auto: IPv6 / IPv4 */
hints.ai_family = AF_UNSPEC;
break;
case WEECHAT_HOOK_CONNECT_IPV6_FORCE:
/* force IPv6 */
hints.ai_family = AF_INET6;
break;
default:
/* auto by default */
hints.ai_family = AF_UNSPEC;
break;
}
snprintf (port, sizeof (port), "%d", HOOK_CONNECT(hook_connect, port));
rc = getaddrinfo (HOOK_CONNECT(hook_connect, address), port, &hints, &res_remote);
}
+3
View File
@@ -63,6 +63,9 @@ struct t_weechat_script_constant weechat_script_constants[] = {
WEECHAT_SCRIPT_CONST_STR(WEECHAT_HOTLIST_HIGHLIGHT),
WEECHAT_SCRIPT_CONST_INT(WEECHAT_HOOK_PROCESS_RUNNING),
WEECHAT_SCRIPT_CONST_INT(WEECHAT_HOOK_PROCESS_ERROR),
WEECHAT_SCRIPT_CONST_INT(WEECHAT_HOOK_CONNECT_IPV6_DISABLE),
WEECHAT_SCRIPT_CONST_INT(WEECHAT_HOOK_CONNECT_IPV6_AUTO),
WEECHAT_SCRIPT_CONST_INT(WEECHAT_HOOK_CONNECT_IPV6_FORCE),
WEECHAT_SCRIPT_CONST_INT(WEECHAT_HOOK_CONNECT_OK),
WEECHAT_SCRIPT_CONST_INT(WEECHAT_HOOK_CONNECT_ADDRESS_NOT_FOUND),
WEECHAT_SCRIPT_CONST_INT(WEECHAT_HOOK_CONNECT_IP_ADDRESS_NOT_FOUND),
+5 -1
View File
@@ -31,6 +31,9 @@ WEECHAT_HOTLIST_PRIVATE: str = "2"
WEECHAT_HOTLIST_HIGHLIGHT: str = "3"
WEECHAT_HOOK_PROCESS_RUNNING: int = -1
WEECHAT_HOOK_PROCESS_ERROR: int = -2
WEECHAT_HOOK_CONNECT_IPV6_DISABLE: int = 0
WEECHAT_HOOK_CONNECT_IPV6_AUTO: int = 1
WEECHAT_HOOK_CONNECT_IPV6_FORCE: int = 2
WEECHAT_HOOK_CONNECT_OK: int = 0
WEECHAT_HOOK_CONNECT_ADDRESS_NOT_FOUND: int = 1
WEECHAT_HOOK_CONNECT_IP_ADDRESS_NOT_FOUND: int = 2
@@ -1498,7 +1501,8 @@ def hook_connect(proxy: str, address: str, port: int, ipv6: int, retry: int, loc
# ...
return weechat.WEECHAT_RC_OK
hook = weechat.hook_connect("", "my.server.org", 1234, 1, 0, "",
hook = weechat.hook_connect("", "my.server.org", 1234,
weechat.WEECHAT_HOOK_CONNECT_IPV6_AUTO, 0, "",
"my_connect_cb", "")
"""
...
+6 -1
View File
@@ -74,7 +74,7 @@ struct t_weelist_item;
* please change the date with current one; for a second change at same
* date, increment the 01, otherwise please keep 01.
*/
#define WEECHAT_PLUGIN_API_VERSION "20240627-01"
#define WEECHAT_PLUGIN_API_VERSION "20240727-01"
/* macros for defining plugin infos */
#define WEECHAT_PLUGIN_NAME(__name) \
@@ -179,6 +179,11 @@ enum t_weechat_hdata
#define WEECHAT_HOOK_PROCESS_ERROR -2
#define WEECHAT_HOOK_PROCESS_CHILD -3
/* IPv6 for connect hook */
#define WEECHAT_HOOK_CONNECT_IPV6_DISABLE 0
#define WEECHAT_HOOK_CONNECT_IPV6_AUTO 1
#define WEECHAT_HOOK_CONNECT_IPV6_FORCE 2
/* connect status for connection hooked */
#define WEECHAT_HOOK_CONNECT_OK 0
#define WEECHAT_HOOK_CONNECT_ADDRESS_NOT_FOUND 1
+3
View File
@@ -70,6 +70,9 @@ def test_constants():
check(weechat.WEECHAT_HOTLIST_HIGHLIGHT == '3')
check(weechat.WEECHAT_HOOK_PROCESS_RUNNING == -1)
check(weechat.WEECHAT_HOOK_PROCESS_ERROR == -2)
check(weechat.WEECHAT_HOOK_CONNECT_IPV6_DISABLE == 0)
check(weechat.WEECHAT_HOOK_CONNECT_IPV6_AUTO == 1)
check(weechat.WEECHAT_HOOK_CONNECT_IPV6_FORCE == 2)
check(weechat.WEECHAT_HOOK_CONNECT_OK == 0)
check(weechat.WEECHAT_HOOK_CONNECT_ADDRESS_NOT_FOUND == 1)
check(weechat.WEECHAT_HOOK_CONNECT_IP_ADDRESS_NOT_FOUND == 2)