update README
Docker / build (push) Has been cancelled Details

This commit is contained in:
Chris W 2024-01-03 13:15:53 -07:00
parent 9d4748d8b7
commit 39a21bd7a9
3 changed files with 131 additions and 9 deletions

View File

@ -3,6 +3,19 @@
This project has undergone several changes, but here's where we are now: This project has undergone several changes, but here's where we are now:
Paste69 is a clone of the popular pastebin service 0x45.st, but written in Crystal using [the Athena framework](https://athenaframework.org/) rather than in Python with Flask. Paste69 is a clone of the popular pastebin service 0x45.st, but written in Crystal using [the Athena framework](https://athenaframework.org/) rather than in Python with Flask.
## Differences from 0x0
I have tried to keep feature parody with 0x0, but there are some small differences:
- Multiple storage providers are supported (local and s3 for now)
- The configuration format is slightly different, as are some config items
Some features have also yet to be implemented. They will be coming in the near future. These features include:
- NSFW detection
- Virus scanning
- IP blocklisting
## Installation ## Installation
Installation requires [Crystal](https://crystal-lang.org/) and Postgres. Other databases might be supported in the future. Installation requires [Crystal](https://crystal-lang.org/) and Postgres. Other databases might be supported in the future.
@ -30,12 +43,84 @@ shards build
./bin/server ./bin/server
``` ```
Alternatively, you can use Docker to make things quicker: ### Using Docker
If you want, you can build the Docker container yourself locally:
```bash ```bash
docker build -v ./uploads:/app/uploads --tag paste69 ./docker docker build -v ./uploads:/app/uploads --tag paste69 ./docker
docker run -d -p 8080:8080 paste69 docker run -d -p 8080:8080 paste69
``` ```
Or, you can use the hosted version available through ghcr:
```bash
docker pull ghcr.io/watzon/paste69:main
docker run -d -p 8080:8080 ghcr.io/watzon/paste69:main
```
All configuration items are available through environment variables, in addition to the config file. Configuration items and their environment variable names are listed below.
## Configuration
I've done my best to make Paste69 as zero configuration as possible. The default values listed in [src/services/config_manager.cr](src/services/config_manager.cr) should be sufficient for most deployments. However, should you wish to change any of the values you can do so through a config file, or using environment variables.
Valid config file locations are:
- /etc/paste69/config.yml
- ~/.paste69/config.yml
- ~/.config/paste69/config.yml
The following table contains all available configuration options, their default values, and their environment variable counterparts:
| Config Item | Default Value | Environment Variable | Description |
|----------------------------|---------------------------|----------------------------|-----------------------------------------------------|
| `host` | `"0.0.0.0"` | `HOST` | Host to bind to |
| `port` | `8080` | `PORT` | Port to bind to |
| `site_url` | `"0.0.0.0:8080"` | `SITE_URL` | Public URL of the site (used for generating links) |
| `database_url` | `"sqlite://./db/data.db"` | `DATABASE_URL` | URL of the database (Postgres and SQLite supported) |
| `templates_dir` | `"src/templates"` | `TEMPLATES_DIR` | Directory for template overrides (jinja2 format) |
| `max_content_length` | `256 * 1024 * 1024` | `MAX_CONTENT_LENGTH` | Maximum size for incoming files |
| `max_url_length` | `4096` | `MAX_URL_LENGTH` | Maximum size for shortened URLs |
| `max_ext_length` | `9` | `MAX_EXT_LENGTH` | Maximum size for file extensions |
| `storage.path` | `"./uploads"` | `STORAGE.PATH` | Local storage path for files |
| `storage.type` | `"local"` | `STORAGE.TYPE` | Type of storage to use (local or s3) |
| `storage.s3.region` | `nil` | `STORAGE.S3.REGION` | S3 region |
| `storage.s3.bucket` | `nil` | `STORAGE.S3.BUCKET` | S3 bucket |
| `storage.s3.access_key` | `nil` | `STORAGE.S3.ACCESS_KEY` | S3 access key |
| `storage.s3.secret_key` | `nil` | `STORAGE.S3.SECRET_KEY` | S3 secret key |
| `storage.secret_bytes` | `16` | `STORAGE.SECRET_BYTES` | Number of bytes to use for secrets |
| `storage.ext_override` | _too long_ | `STORAGE.EXT_OVERRIDE` | File extension override map (mime => ext) |
| `storage.mime_blacklist` | _too long_ | `STORAGE.MIME_BLACKLIST` | Array containing mime types to blacklist |
| `storage.upload_blacklist` | `nil` | `STORAGE.UPLOAD_BLACKLIST` | Path to a file containing banned IP addresses |
| `nsfw.detect` | `false` | `NSFW.DETECT` | Enable NSFW detection (TODO) |
| `nsfw.threshold` | `0.608` | `NSFW.THRESHOLD` | NSFW detection threshold |
| `vscan.socket` | `nil` | `VSCAN.SOCKET` | ClamAV socket for virus scanning (TODO) |
| `vscan.quarantine_path` | `"./quarantine"` | `VSCAN.QUARANTINE_PATH` | Path for quarantined files |
| `vscan.interval` | `604800` | `VSCAN.INTERVAL` | How often to scan for viruses |
| `vscan.ignore` | _too long_ | `VSCAN.IGNORE` | Mime types for which to ignore virus scanning |
| `url_alphabet` | `"01234567890abcdef..."` | `URL_ALPHABET` | Alphabet string to use for shortened URL creation |
### Custom Templates
Paste69 supports custom templates, which can be used to override the default templates. To do this, simply create a directory somewhere and copy the default templates from [src/templates](src/templates) into it. For example:
```bash
mkdir -p ~/.config/paste69/templates
cp -r ./src/templates ~/.config/paste69/templates
```
and then update your config file (or set the TEMPLATES_DIR environment variable) to point to the new location.
```diff
*** ~/.config/paste69/config.yml 2024-01-01 12:00:00.000000000 -0500
--- ~/.config/paste69/config.yml 2024-01-01 12:00:00.000000000 -0500
@@ -1,1 +1,1 @@
-templates_dir: "src/templates"
+templates_dir: "~/.config/paste69/templates"
```
this directory will be used __in stead of__ the default templates, and not in addition to, so be sure to copy all of the templates over.
## Development ## Development
Feel free to make pull requests! Feel free to make pull requests!

View File

@ -1,7 +1,47 @@
host: 0.0.0.0 host: 0.0.0.0
port: 80 port: 8080
site_url: 0x45.st site_url: 0.0.0.0:80
database_url: postgres://postgres@127.0.0.1/paste69 use_ssl: false
database_url: sqlite://./db/data.db
templates_dir: src/templates
max_content_length: 268435456 # 256 MiB
max_url_length: 4096
max_ext_length: 9
storage: storage:
type: local type: local
path: ./uploads path: ./uploads
max_expiration: 31536000000 # 365 days
min_expiration: 2592000000 # 30 days
s3:
region: null
bucket: null
access_key: null
secret_key: null
secret_bytes: 16
ext_override:
audio/flac: .flac
image/gif: .gif
image/jpeg: .jpg
image/png: .png
image/svg+xml: .svg
video/webm: .webm
video/x-matroska: .mkv
application/octet-stream: .bin
text/plain: .txt
text/x-diff: .diff
mime_blacklist:
- application/x-dosexec
- application/java-archive
- application/java-vm
upload_blacklist: null
nsfw:
detect: false
theshold: 0.608
vscan:
socket: null
quarantine_path: ./quarantine
interval: 604800 # 7 days
ignore:
- Eicar-Test-Signature
- PUA.Win.Packer.XmMusicFile
url_alphabet: 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ

View File

@ -12,7 +12,6 @@ module Paste69
"templates_dir" => "src/templates", "templates_dir" => "src/templates",
"max_content_length" => 256 * 1024 * 1024, "max_content_length" => 256 * 1024 * 1024,
"max_url_length" => 4096, "max_url_length" => 4096,
"use_x_sendfile" => false,
"max_ext_length" => 9, "max_ext_length" => 9,
"storage.path" => "./uploads", "storage.path" => "./uploads",
"storage.type" => "local", "storage.type" => "local",
@ -32,7 +31,6 @@ module Paste69
"video/webm" => ".webm", "video/webm" => ".webm",
"video/x-matroska" => ".mkv", "video/x-matroska" => ".mkv",
"application/octet-stream" => ".bin", "application/octet-stream" => ".bin",
"text/plain" => ".log",
"text/plain" => ".txt", "text/plain" => ".txt",
"text/x-diff" => ".diff", "text/x-diff" => ".diff",
}, },
@ -41,7 +39,7 @@ module Paste69
"application/java-archive", "application/java-archive",
"application/java-vm" "application/java-vm"
], ],
"storage.upload_blacklist" => [] of String, "storage.upload_blacklist" => nil,
"nsfw.detect" => false, "nsfw.detect" => false,
"nsfw.threshold" => 0.608, "nsfw.threshold" => 0.608,
"vscan.socket" => nil, "vscan.socket" => nil,
@ -60,7 +58,6 @@ module Paste69
config = @config = Totem.new("config", "/etc/paste69") config = @config = Totem.new("config", "/etc/paste69")
config.config_paths << "~/.paste69" config.config_paths << "~/.paste69"
config.config_paths << "~/.config/paste69" config.config_paths << "~/.config/paste69"
config.config_paths << "./config"
config.load! rescue nil config.load! rescue nil
config.automatic_env config.automatic_env