From 7c00b364d1082a52abcddb8412563ea8bed7982d Mon Sep 17 00:00:00 2001 From: Julien Riou Date: Sun, 24 Aug 2025 15:48:12 +0200 Subject: [PATCH] docs: Add READMEs Signed-off-by: Julien Riou --- README.md | 52 ++++++++++++++++++++++++++++++++++++++- src/cmd/coller/README.md | 42 +++++++++++++++++++++++++++++++ src/cmd/collerd/README.md | 31 +++++++++++++++++++++++ src/cmd/copier/README.md | 16 ++++++++++++ src/server/db.go | 4 ++- 5 files changed, 143 insertions(+), 2 deletions(-) create mode 100644 src/cmd/coller/README.md create mode 100644 src/cmd/collerd/README.md create mode 100644 src/cmd/copier/README.md diff --git a/README.md b/README.md index a3ef6f3..6bbdeb9 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,53 @@ # Coller -Simple self-contained pastebin solution. +Simple self-contained pastebin solution written in Go. + +# Description + +Coller is a set a binaries: +- **collerd**: HTTP server to handle note management +- **coller**: CLI to create notes +- **copier**: CLI to download and decrypt notes (client-side decryption) + +# Installation + +## From source code + +Requires [Go](https://go.dev/dl/). + +``` +git clone https://git.riou.xyz/jriou/coller.git +cd coller +make +sudo cp -p bin/* /usr/local/bin/ +``` + +## Docker + +``` +git clone https://git.riou.xyz/jriou/coller.git +cd coller +docker build -t coller:latest . +docker run --network host --rm --name collerd -p 8080:8080 coller:latest +``` + +Then go to http://localhost:8080 (website). + +## Ansible + +See [ansible-role-coller](https://git.riou.xyz/jriou/ansible-role-coller). + + +# Usage and configuration + +* [collerd](src/cmd/collerd/README.md) +* [coller](src/cmd/coller/README.md) +* [copier](src/cmd/copier/README.md) + +# Contributions + +Contributions are welcomed! Feel free to provide unit tests when possible. Lint your code with `go fmt`. If you don't feel confident enough to contribute, feel free to open an issue to describe the feature you would like to see implemented or the problem you are facing. + +# License + +See [LICENSE](LICENSE). \ No newline at end of file diff --git a/src/cmd/coller/README.md b/src/cmd/coller/README.md new file mode 100644 index 0000000..1cf57a6 --- /dev/null +++ b/src/cmd/coller/README.md @@ -0,0 +1,42 @@ +# coller + +CLI to create notes. + +# Usage + +``` +coller -help +``` + +# Examples + +Create from clipboard: + +``` +coller +``` + +Create from file: + +``` +coller -file filename.txt +``` + +Provide password for encryption: + +``` +coller -ask-password +coller -password PASSWORD +``` + +Create public note: + +``` +coller -no-password +``` + +Return the copier command to use client-side decryption instead of the URL: + +``` +coller -copier +``` \ No newline at end of file diff --git a/src/cmd/collerd/README.md b/src/cmd/collerd/README.md new file mode 100644 index 0000000..e51ba03 --- /dev/null +++ b/src/cmd/collerd/README.md @@ -0,0 +1,31 @@ +# collerd + +Server to manage notes: +* Website +* API +* Database management + +## Usage + +``` +collerd -help +``` + +## Configuration + +The file format is **JSON**: + +* **title** (string): Title of the website +* **database_type** (string): Type of the database (default "sqlite", "postgres" also supported) +* **database_dsn** (string): Connection string for the database (default "collerd.db") +* **id_length** (int): Number of characters for note identifiers (default 5) +* **password_length** (int): Number of characters for generated passwords (default 16) +* **expiration_interval** (int): Number of seconds to wait between two expiration runs +* **listen_address** (string): Address to listen for the web server (default "127.0.0.1") +* **listen_port** (int): Port to listen for the web server (default 8080) +* **expirations** ([]int): List of supported expiration times in seconds (default 300, 86400, 604800, 18144000) +* **expiration** (int): Default expiration time in seconds +* **max_upload_size** (int): Maximum number of bytes received by the server for notes (the base64 encoding may use more space than the real size of the note) +* **show_version** (bool): Show version on the website + +The configuration file is not required but the service might not be exposed to the public. \ No newline at end of file diff --git a/src/cmd/copier/README.md b/src/cmd/copier/README.md new file mode 100644 index 0000000..f9b5660 --- /dev/null +++ b/src/cmd/copier/README.md @@ -0,0 +1,16 @@ +# copier + +CLI to download and decrypt notes from the client. + +# Usage + +``` +copier -help +``` + +# Examples + +``` +copier -password PASSWORD URL +copier -w URL +``` \ No newline at end of file diff --git a/src/server/db.go b/src/server/db.go index bd89697..06e27ee 100644 --- a/src/server/db.go +++ b/src/server/db.go @@ -35,8 +35,10 @@ func NewDatabase(logger *slog.Logger, config *Config) (d *Database, err error) { switch config.DatabaseType { case "postgres": db, err = gorm.Open(postgres.New(postgres.Config{DSN: config.DatabaseDsn}), gconfig) - default: + case "sqlite": db, err = gorm.Open(sqlite.Open(config.DatabaseDsn), gconfig) + default: + return nil, fmt.Errorf("database type '%s' not supported", config.DatabaseType) } if err != nil { return nil, err