A simple proof-of-concept rmate server implemented in Go.
Handles rmate TCP connections and uses gui editor with tmp files.
This is a Go translation of the original Rust implementation.
Usage: rmate-server [OPTIONS]
Options:
-e, --editor binary Sets the executable path for the editor CLI binary (default "/usr/bin/neovide")
-v, --neovide Flag for Neovide
-b, --bind string Sets a custom rmate server address (default "127.0.0.1:52698")
-o, --once End the server when editor closes
-h, --help Print help
ED_BIN- Sets the executable path for the gui editor CLI binaryED_NEOVIDE- Flag for NeovideRMATE_BIND- Sets a custom rmate server addressRMATE_ONCE- End the server when editor closes
Outline of the program structure and protocol handling as follows:
- Bind a TCP server, default is 127.0.0.1:52698 and listen for connections
- On each connection send a server identification
- Receive rmate commands of "open" or "." (end of commands)
- Receive command header of key-value pairs
- Copy body data to a temporary file
- Open the temporary file in editor
- Watch the temporary file for changes, then send the file contents to the connection
- On editor close or remote connection close remove the temporary files
An example protocol flow is
$ sudo tcpflow -i lo0 -c port 52698
SERVER-CLIENT: RMate-Server 0
CLIENT-SERVER:
open
display-name: myremote:myfile.txt
real-path: /tmp/myfile.txt
data-on-save: yes
re-activate: yes
token: myfile.txt
(OPTIONAL) new: yes
(OPTIONAL) selection: 5
(OPTIONAL) file-type: text/plain
data: 26
Some random file contents
.
SERVER-CLIENT:
save
token: myfile.txt
data: 30
Di 16. Jul 00:11:08 CEST 2024
Modified random file contents
close
To build the project, run:
go buildTo run the server, simply execute the binary:
./rmate-server- Go 1.19 or higher
- GUI editor with CLI support
Licensed under
- MIT license (LICENSE or http://opensource.org/licenses/MIT)
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, shall be licensed as above, without any additional terms or conditions.