Skip to content

stsg/rmate-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rmate-server (Go Implementation)

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

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

Environment Variables

  • ED_BIN - Sets the executable path for the gui editor CLI binary
  • ED_NEOVIDE - Flag for Neovide
  • RMATE_BIND - Sets a custom rmate server address
  • RMATE_ONCE - End the server when editor closes

Program structure

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

Protocol example

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

Building

To build the project, run:

go build

Running

To run the server, simply execute the binary:

./rmate-server

Dependencies

  • Go 1.19 or higher
  • GUI editor with CLI support

License

Licensed under

Contribution

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors