Skip to content

cwf is a small tool to quickly share content (e.g. logfiles, commands, ...) with your friends and colleagues.

Notifications You must be signed in to change notification settings

noobcollective/cwf

Repository files navigation

cwf - copy with friends

cwf is a small tool to quickly share content (e.g. logfiles, commands, ...) with your friends and colleagues. It can be run local or on a server, so nobody needs to set things up like port forwarding on their local machine.

⚠️ Warning
As of now we do not recommend sending sensitive data! Although the transport can be handled via HTTPS, the files on the server are just base64 encoded and can be accessed via the given endpoints from any IP.

Demo

cwf_demo

Installation

We provide a homebrew package to install cwf as a binary.
It's totally possible to run the server with the binary.
However if you are planning to run cwf on a server (e.g. VPS) we recommend using our docker image.

MacOS & Linux

brew install noobcollective/tap/cwf

Client

Example Client Config

[mothership]
ip = '127.0.0.1'
port = '8787'
ssl = true

[client]
user_name = 'MyLittleUsername'
user_id = '<id_from_server>'

user_id will be automatically generated when registering user the first time.
Have a look at the registration command.

Client Usage

Send content to server and save it in a single file.

echo "Hello Clipboard!" | cwf testfile

Saved to: testfile

Get content of a saved file from server.

cwf testfile

Hello Clipboard!

Send content to server and save file in a subdirectory.

echo "Hello Clipboard from subdirectory!" | cwf testdir/testfile

Saved to: testdir/testfile

Get content of a saved file in a subdirectory from server.

cwf testdir/testerfile

Hello Clipboard from subdirectory!

Delete single file

cwf -d testerfile

Deleted file: testerfile

Delete single file in subdirectory

cwf -d testdir/testfile

Deleted file: testfile

Delete all files in subdirectory

cwf -d testdir/

Deleted directory: testdir

List files and directories in configured base directory.

cwf -l
Type    Name         Modified
Dir    testdir      2006-01-02 15:04:05
File   testfile.cwf 2006-01-02 15:04:05

List files and directories in a subdirectory.

cwf -l testdir
Type    Name         Modified
File   testfile.cwf 2006-01-02 15:04:05

Register user on server

For a more secure environment, we decided to implement user accounts server side. Therefore you'll need to register your user when using cwf the first time. Be sure there is a user_name set in your config file and it's the same on the server.

cwf -r
Successfully registered! Have fun using CWF!

Server

Example Server Config

The path to your configuration file can be set via the -config flag -> defaults to /etc/cwf/config.toml.

[general]
port = '8787'
ssl = true
files_dir = '/tmp/cwf/'
certs_dir = '/etc/crypts'
cert_file = 'cert.crt'
key_file = 'cert.key'

[[accounts]]
user_name = 'MyLittleUser'
id = '<autogenerated_uuid>'
registered = true

[[accounts]]
user_name = 'AnotherUser'
id = '<autogenerated_uuid>'
registered = false

Docker Image

  • Get the image with:
    docker pull noobcollective/cwf-server
  • Start cwf with docker in HTTP Mode:
    docker run \
        --name cwf-server \
        -p <host_port>:<container_port> \
        -v <volume_name>:<container_filesDir> \
        -d noobcollective/cwf-server -serve
  • Start cwf with docker in HTTPS Mode:
    docker run \
        --name cwf-server \
        -p <host_port>:<container_port> \
        -v <host_config_path>:<container_config_path> \
        -v <volume_name>:<container_filesDir> \
        -v <host_ssl_certs_dir>:<container_ssl_certs_dir> \
        -d noobcollective/cwf-server -serve
  • <container_port>: Configurable via -port argument in cwf -> defaults to 8787.
  • <container_config_path>: Configurable via -config argument in cwf.
  • <volume_name>: Name of the docker volume for persisting data.
  • <container_filesDir>: Configurable via files_dir in config file -> defaults to /tmp/cwf/.

When ssl is set to true in your config, you need to mount the directory where the SSL certificates are located on your host machine
and set the paths of your ssl directory, certificate and key in your config.

  • <host_ssl_certs_dir>: Directory where the SSL certificates are located on your host machine.
  • <container_ssl_certs_dir>: Configurable in your config.

Roadmap:

  • get size of files
  • diffs over snapshots
  • chown directories to specific users
  • only stdout a range (e.g cwf test1 -r 25,30)

Dependencies

  • Added Zap as logging library go.uber.org/zap
  • Added yaml to parse our config file gopkg.in/yaml.v3

TODOs:

  • prefix paths with cwf home (preferable in a config file) - defaults to /tmp/cwf/
  • more secure content (because base64 - wtf)
  • safe error handling (e.g. handle error responses in client)
  • fix path for config file in resulting binary (for now it uses pwd, which is not a good idea, because cwf should lay in <somewhere>/bin)

Feature list - Server

  • copy into cwf
  • stdout of cwf
  • clean file
  • check if file exists
  • create dir if path passed as name
  • list all files after date (more options for sorting?)
    • Currently only listing files in directory in modified order. NO additional sorting is supported
  • adding flag to setup port additionaly reading from config file setting dir/dirDepth/port
    • Implemented with yaml (I thought yaml is toml and toml is yaml) so currently its working with a yaml file but i actually want a toml file

Feature list - Client

  • copy into cwf
  • stdout of cwf
  • clean file - [ ] check if file exists - not needed (cwf <filename> returns if file exists anyway)
  • hashing/enryption
  • list all files after date (more options for sorting?)
  • create dir if path passed as name

Our Blog

https://project-folio.eu

About

cwf is a small tool to quickly share content (e.g. logfiles, commands, ...) with your friends and colleagues.

Resources

Stars

Watchers

Forks

Packages

No packages published