WeeChat DevCenter

Tag - relay

Entries feed

Sunday, May 19 2024

API relay and remote connection

A brand new relay called "api" has been devleopped since 6 months : it's an HTTP REST API, which should in long term replace completey the "weechat" protocol.

The "api" relay provides the following key features:

  • easy client implementation: HTTP REST API, JSON input/output, use of ANSI color codes
  • automatic compression of responses (deflate, gzip, zstd and permessage-deflate for websocket)
  • data synchronization: real-time sync with websocket or polling with HTTP requests
  • no internal structures exposed: no use of pointers & complex structures like hdata
  • WeeChat itself can connect to another WeeChat using this protocol (also known as relay "remote")

Documentation: Relay API.

The new /remote command lets you connect to the "api" relay of another running WeeChat (it must expose the same API version).

To connect to a remote WeeChat, just add a relay on the remote (for TLS, which is recommended, replace api by tls.api):

/set relay.network.password "secr3t"
/relay add api 9000

On the client, supposing it's running on the same machine:

/remote add test http://localhost:9000 -password=secr3t
/remote connect test

Then all buffers of remote WeeChat are opened locally by relay and any text or command sent on these buffers are sent and executed on the remote WeeChat.

Input is also synchronized (from remote to local WeeChat only), so that remote buffers like /fset can be used locally, including keys like Alt+Enter to set input with a command to execute.
Only the local buffer mouse actions are not yet supported (ie you can not scroll the fset buffer with mouse).

Friday, January 7 2022

Zstandard compression in relay plugin

Zstandard compression has been added in weechat protocol of relay plugin (see important notes in the release notes).

It offers better and faster compression (on WeeChat side) and faster decompression (client side).

Example of a small message (53KB), default compression (20):

   WeeChat: obj: 2964/53611 bytes (zstd: 95%, 0,12ms)
   Client: decompressed (zstd): 53606 bytes, ratio: 95%, parsed in 0.67ms)
   WeeChat: obj: 3752/53611 bytes (zlib: 94%, 0,23ms), id: quiet
   Client: decompressed (zlib): 53606 bytes, ratio: 94%, parsed in 2.10ms)

Example of a big message (2.3MB), default compression (20):

   WeeChat: obj: 133280/2376095 bytes (zstd: 95%, 2,97ms), id: quiet
   Client: decompressed (zstd): 2376090 bytes, ratio: 95%, parsed in 15.03ms)
   WeeChat: obj: 345255/2376095 bytes (zlib: 86%, 12,72ms), id: quiet
   Client: decompressed (zlib): 2376090 bytes, ratio: 86%, parsed in 21.20ms)

So with the same compression level:

  • zstd is up to 4x faster on compression than zlib (WeeChat side)
  • zstd is up to 3x faster on decompression than zlib (client side)
  • compressed packets are up to 2.6x smaller with zstd than zlib.

Monday, January 14 2019

Support of TOTP

TOTP (Time-based One-Time Password) support has been added in WeeChat, which can now generate and check TOTP validity.

A TOTP is generated with:

  • the secret (encoded in base 32),
  • the time (by default 0, which is the current time),
  • the number of digits (4 to 10 digits are supported, 6 is the default and recommended value).

Relay plugin

The TOTP can be used as second authentication factor in the relay plugin, with two new options:

  • relay.network.totp_secret: the TOTP secret, encoded in base 32
  • relay.network.totp_window: the allowed window: number of TOTP allowed before and after the current time window.

For example to set the secret using secured data (just replace "xxxxx" by your secret in base 32):

/secure set relay_totp_secret xxxxx
/set relay.network.totp_secret "${sec.data.relay_totp_secret}"

Then your relay client must support and send the TOTP value, in addition to the password, in the "init" command:

init password=secretpassword,totp=123456

If the password is valid and that TOTP is valid for the current time, the authentication is successful.

Infos / eval

You can also generate or validate TOTP with two new infos in WeeChat:

  • totp_generate: generate a TOTP
  • totp_validate: validate a TOTP

For example to show the value of TOTP for the secret "secretbase32", current time, with 6 digits:

/eval -n ${info:totp_generate,secretbase32,0,6}

Documentation

You can read more about TOTP in the docs:

Sunday, February 10 2013

WebSocket in relay plugin

Websocket has been added in relay plugin, for IRC and WeeChat protocols.

It is an experimental and partial implementation of RFC 6455: fragmentation and control frames are not yet supported.

The relay plugin automatically detects WebSocket handshake and if everything is OK (origin allowed and required headers received), an answer to handshake is sent and then socket is ready to send/receive WebSocket frames.

Text and binary data are supported, so IRC (text/text) and WeeChat (text/binary) protocols are supported.

Screenshot (click for full size):

relay_websocket.png

Tuesday, February 5 2013

Test script for relay protocol

A test script called testproto.py has been added in QWeeChat to test the relay protocol with WeeChat. This script runs in terminal and does not require Qt.

Script is located in path src/qweechat/weechat/testproto.py of QWeeChat repository.

Screenshot (click for full size):

testproto.png

Monday, December 24 2012

Backlog for irc protocol in relay

Backlog has been added for irc protocol in relay plugin.

The relay plugin now supports server capability "server-time", to include the messages time as tag (not in the message itself).

5 new options have been added:

  • relay.irc.backlog_max_minutes
  • relay.irc.backlog_max_number
  • relay.irc.backlog_since_last_disconnect
  • relay.irc.backlog_tags
  • relay.irc.backlog_time_format

Enjoy, and merry Christmas!

Friday, July 27 2012

SSL in Relay plugin

SSL support has been added in Relay plugin, for irc and weechat protocols.

A new option has been added to set the certificate and private key to use:

  • relay.network.ssl_cert_key: path to file with certificate and private key (default: ~/.weechat/ssl/relay.pem)

The file can be created with following commands:

$ mkdir -p ~/.weechat/ssl
$ cd ~/.weechat/ssl
$ openssl req -nodes -newkey rsa:2048 -keyout relay.pem -x509 -days 365 -out relay.pem

In WeeChat :

/relay sslcertkey

And add relays with SSL, for example:

/relay add ssl.irc.freenode 8001
/relay add ssl.weechat 9001

And now WeeChat will serve clients on these ports using SSL, enjoy!

Sunday, December 25 2011

QWeeChat - Python/Qt GUI

Christmas gift: "QWeeChat", the first remote interface for WeeChat. It is written in Python, using Qt toolkit.

This is an alpha version of this interface, only some features are implemented, but it's usable as-is.

The source code is available on download page, and requires latest development version of WeeChat.
New versions will follow, as well as interfaces for other systems like mobile devices (first should be Android).

A screenshot of QWeeChat in action (click for full size):

Urlserver

Merry Christmas and happy new year 2012 with WeeChat and QWeeChat!