Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New relay "api": HTTP REST API #2066

Closed
flashcode opened this issue Feb 1, 2024 · 3 comments
Closed

New relay "api": HTTP REST API #2066

flashcode opened this issue Feb 1, 2024 · 3 comments
Assignees
Labels
feature New feature request
Milestone

Comments

@flashcode
Copy link
Member

flashcode commented Feb 1, 2024

Feature description

Add a new relay protocol called "api", with the following goals:

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

Specification: https://specs.weechat.org/specs/2023-005-relay-http-rest-api.html

@flashcode flashcode added the feature New feature request label Feb 1, 2024
@flashcode flashcode added this to the 4.3.0 milestone Feb 1, 2024
@flashcode flashcode self-assigned this Feb 1, 2024
flashcode added a commit that referenced this issue Feb 1, 2024
@flashcode flashcode added the in progress Someone is working on this issue label Feb 2, 2024
flashcode added a commit that referenced this issue Feb 2, 2024
…l builds (issue #2066)

This is because in these versions the libcjson-dev package doesn't provide
pkg-config file.
flashcode added a commit that referenced this issue Apr 7, 2024
flashcode added a commit that referenced this issue Apr 7, 2024
Connection to remote:

- handshake: offer support for all supported hash algorithms
- network connect with a socket
- upgrade to websocket and authenticate with remote (password/TOTP)
- check websocket response
- get list of buffers (not used yet)

Note: connection to remote with TLS or a proxy is not yet supported.
flashcode added a commit that referenced this issue Apr 7, 2024
flashcode added a commit that referenced this issue Apr 7, 2024
This can be used to send raw JSON data encapsulated in a websocket frame to the
remote.

Example: /remote send test {"request":"GET /api/version"}
flashcode added a commit that referenced this issue Apr 7, 2024
flashcode added a commit that referenced this issue Apr 7, 2024
flashcode added a commit that referenced this issue Apr 7, 2024
flashcode added a commit that referenced this issue Apr 7, 2024
This allows buffers to get any user input, including commands, that are sent to
the buffer callback instead of being executed on the buffer.
flashcode added a commit that referenced this issue Apr 7, 2024
…otocols (issue #2066)

This is to prevent infinite loop when connected to a remote which is the
weechat instance itself.
flashcode added a commit that referenced this issue Apr 7, 2024
…instead of NULL (issue #2066)

This fixes the websocket connection to remote that is not initiated after the
successful handshake with the remote relay/api.
flashcode added a commit that referenced this issue May 1, 2024
…ssue #2066)

The signal "buffer_line_added" is now sent for every line added or modified on
a buffer with free content.
flashcode added a commit that referenced this issue May 1, 2024
)

If buffer->input_get_any_user_data is set to 1, any command executed via a
buffer local key is considered as user input and then sent to the buffer
callback, instead of being executed directly.

This is used on relay remote buffers, to execute the command on the remote
instead of locally.
@nilscc
Copy link

nilscc commented May 4, 2024

Would be nice if the API would support CORS, such that you can use it with OpenAPI directly.

https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#preflighted_requests

@bqv
Copy link

bqv commented May 5, 2024

Old protocols will remain, right?

@flashcode
Copy link
Member Author

@bqv: short answer: yes, for now.

Long answer:

IRC protocol will remain as it allows any IRC client to connect, like a bouncer does.

The goal with API protocol is to deprecate and replace the "weechat" protocol.
The API protocol has major benefits: standard HTTP API using JSON, safe to use (no pointer or internal structures exposed), colors converted, and connection to another WeeChat is possible.
For these reasons, at some point, the "weechat" protocol could be completely removed.
But this will take time (I mean years) as some major external clients are using it today.
For the future, all efforts will be focused on the API protocol, the weechat protocol should not evolve much further.

@flashcode flashcode added in progress Someone is working on this issue and removed in progress Someone is working on this issue labels May 12, 2024
@flashcode flashcode removed the in progress Someone is working on this issue label May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature request
Projects
None yet
Development

No branches or pull requests

3 participants