diff --git a/doc/en/weechat_user.en.adoc b/doc/en/weechat_user.en.adoc index 59aacc98e..1c77b23e3 100644 --- a/doc/en/weechat_user.en.adoc +++ b/doc/en/weechat_user.en.adoc @@ -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 diff --git a/src/plugins/relay/relay-command.c b/src/plugins/relay/relay-command.c index 86db92456..cd1fc26d9 100644 --- a/src/plugins/relay/relay-command.c +++ b/src/plugins/relay/relay-command.c @@ -396,7 +396,7 @@ relay_command_init () "relay", N_("relay control"), N_("list|listfull|listrelay" - " || add " + " || add |" " || del|start|restart|stop " " || 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" diff --git a/src/plugins/relay/relay-config.c b/src/plugins/relay/relay-config.c index dfcad8d6c..904537216 100644 --- a/src/plugins/relay/relay-config.c +++ b/src/plugins/relay/relay-config.c @@ -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, diff --git a/src/plugins/relay/relay-server.c b/src/plugins/relay/relay-server.c index 5e91d7bd6..03e3d0e82 100644 --- a/src/plugins/relay/relay-server.c +++ b/src/plugins/relay/relay-server.c @@ -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); } /*