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

[WIP] Client/Server process separation #1125

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

vktr
Copy link
Member

@vktr vktr commented Jan 23, 2021

This will add a PicoTorrent Server process which will be used for all BitTorrent related things, keeping the UI clean from libtorrent and adding a WebSocket and HTTP JSONRPC API to the server process. Ideally with no breaking changes.

The server process will have a HTTP listener where you can connect to either /api/ws to receive WebSocket events, or /api/jsonrpc to post JSONRPC requests. It will also add support for serving static files under / which can be used for serving a SPA for remote management.

The basic idea here is to have a server process which can be run either as part of the client, or stand-alone and connect either a regular PicoTorrent desktop client to it or managed by the web UI. The desktop application will receive events on the WebSocket to keep UI in sync, and issue JSONRPC requests to modify state.

JSONRPC methods to implement:

  • core.getVersion - gets version information for all libraries.
  • config.get - gets the application config, i.e can be anything the application chooses to store.
  • config.set - sets a config value, anything the application wants.
  • session.findMetadata - begins a DHT metadata search for a torrent based on a info hash.
  • session.getSettings - get the libtorrent session settings.
  • session.setSettings - sets the libtorrent session settings.
  • session.pause - pauses the session.
  • session.resume - resumes the session.
  • session.setIPFilter - sets the IP filter configuration.
  • session.getIPFilter - gets the IP filter configuration.
  • session.addTorrent - adds a torrent.
  • torrents.toJSON - takes a base64 encoded torrent file and returns it in JSON format. To be used when previewing a torrent in the UI.
  • torrents.remove - remove one or more torrents based on info hash, optionally removing the files as well.
  • torrents.pause - pause one or more torrents based on info hash.
  • torrents.resume - resume one or more torrents based on info hash, optionally passing the force flag.
  • torrents.move - moves one or more torrents based on info hash, optionally passing a flag to overwrite files in the destination.
  • torrents.prioritizeFiles - prioritizes the files in a torrent.
  • torrents.renameFiles - renames one or more files in a torrent.
  • torrents.prioritizePieces - prioritizes the pieces in a torrent.
  • torrents.addTracker - adds one or more trackers to a torrent
  • torrents.removeTracker - removes one or more trackers from a torrent.

WebSocket events to implement:

  • init - sent when a client connects to the WebSocket. Contains all the initial state needed to keep the UI in sync.
  • torrents.added - a torrent was added.
  • torrents.removed - a torrent was removed.
  • torrents.moved - a torrent was moved.
  • torrents.updated - one or more torrents had their states updated.
  • torrents.error - one or more torrents transitioned into the error state.
  • torrents.paused - a torrent was paused.
  • torrents.resumed - a torrent was resumed.

Events and JSONRPC methods are subject to change.

@make-42
Copy link
Contributor

make-42 commented Jan 23, 2021

🌶️ stuff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants