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

relay: evaluate path of unix socket relay

This commit is contained in:
Sébastien Helleu
2019-05-12 21:53:23 +02:00
parent b228ccdfc3
commit 585eb337e8
4 changed files with 28 additions and 23 deletions
+10 -10
View File
@@ -3194,26 +3194,26 @@ websocket = new WebSocket("ws://server.com:9000/weechat");
The port (9000 in example) is the port defined in Relay plugin.
The URI must always end with "/weechat" (for _irc_ and _weechat_ protocols).
[[relay_unixsocket]]
[[relay_unix_socket]]
==== UNIX domain sockets
Using the protocol option "unix" with the "/relay add" command, you can
listen using any protocol on a UNIX domain socket at a given path. For exmaple:
Using the protocol option "unix" with the "/relay add" command, you can listen
using any protocol on a UNIX domain socket at a given path. For example:
----
/relay add unix.weechat /tmp/weesock
/relay add unix.weechat %h/relay_socket
----
will allow clients to connect using the WeeChat protocol to /tmp/weesock. This
is particularly useful to allow SSH forwarding for relay clients, when other
ports cannot be opened. Using OpenSSH:
This will allow clients to connect using the WeeChat protocol to
_~/.weechat/relay_socket_. This is particularly useful to allow SSH forwarding
for relay clients, when other ports cannot be opened. Using OpenSSH:
----
$ ssh -L9000:/tmp/weesock foo_host
$ ssh -L9000:/home/xxx/.weechat/relay_socket foo_host
----
will then allow for local relay clients to connect on port 9000 to a WeeChat
instance running on "foo_host".
This will then allow for local relay clients to connect on port 9000 to a
WeeChat instance running on "foo_host".
[[relay_commands]]
==== Commands
+5 -2
View File
@@ -396,7 +396,7 @@ relay_command_init ()
"relay",
N_("relay control"),
N_("list|listfull|listrelay"
" || add <name> <port>"
" || add <name> <port>|<path>"
" || del|start|restart|stop <name>"
" || raw"
" || sslcertkey"),
@@ -411,6 +411,9 @@ relay_command_init ()
" stop: close the server socket (clients remain connected)\n"
" name: relay name (see format below)\n"
" port: port used for relay\n"
" path: path used for relay (for UNIX domain socket only); "
"\"%h\" at beginning of string is replaced by WeeChat home "
"(\"~/.weechat\" by default), content is evaluated (see /help eval)\n"
" raw: open buffer with raw Relay data\n"
" sslcertkey: set SSL certificate/key using path in option "
"relay.network.ssl_cert_key\n"
@@ -453,7 +456,7 @@ relay_command_init ()
" weechat protocol with SSL, using IPv4 + IPv6:\n"
" /relay add ipv4.ipv6.ssl.weechat 9001\n"
" weechat protocol over UNIX domain socket:\n"
" /relay add unix.weechat /tmp/weesock"),
" /relay add unix.weechat %h/relay_socket"),
"list %(relay_relays)"
" || listfull %(relay_relays)"
" || listrelay"
+6 -2
View File
@@ -764,7 +764,10 @@ relay_config_create_option_port_path (const void *pointer, void *data,
{
weechat_config_new_option (
config_file, section,
option_name, "string", NULL,
option_name, "string",
_("path to a socket file; \"%h\" at beginning of string "
"is replaced by WeeChat home (\"~/.weechat\" by default), "
"content is evaluated (see /help eval)"),
NULL, 0, 0, "", value, 0,
&relay_config_check_path_cb, NULL, NULL,
&relay_config_change_path_cb, NULL, NULL,
@@ -774,7 +777,8 @@ relay_config_create_option_port_path (const void *pointer, void *data,
{
weechat_config_new_option (
config_file, section,
option_name, "integer", NULL,
option_name, "integer",
_("port for relay"),
NULL, 0, 65535, "", value, 0,
&relay_config_check_port_cb, NULL, NULL,
&relay_config_change_port_cb, NULL, NULL,
+7 -9
View File
@@ -711,7 +711,8 @@ relay_server_new (const char *protocol_string, enum t_relay_protocol protocol,
new_server->protocol_args =
(protocol_args) ? strdup (protocol_args) : NULL;
new_server->port = port;
new_server->path = strdup (path);
new_server->path = weechat_string_eval_path_home (path,
NULL, NULL, NULL);
new_server->ipv4 = ipv4;
new_server->ipv6 = ipv6;
new_server->ssl = ssl;
@@ -748,14 +749,11 @@ relay_server_new (const char *protocol_string, enum t_relay_protocol protocol,
void
relay_server_update_path (struct t_relay_server *server, const char *path)
{
if (strcmp (path, server->path) != 0)
{
relay_server_close_socket (server);
free (server->path);
server->path = strdup (path);
server->port = -1;
relay_server_create_socket (server);
}
relay_server_close_socket (server);
free (server->path);
server->path = weechat_string_eval_path_home (path, NULL, NULL, NULL);
server->port = -1;
relay_server_create_socket (server);
}
/*