Home

Awesome

Paste69

<div align="center"> <img src="https://github.com/watzon/0x45/blob/main/public/images/0x45-og.png?raw=true" alt="0x45"> </div>

Go Report Card Docker Image Version GoDoc License: MIT

A modern, Go-based pastebin service inspired by 0x0.st.

Features

Installation

Prerequisites

Local Setup

# Clone the repository
git clone https://github.com/watzon/0x45.git
cd 0x45

# Install dependencies
go mod download

# Configure settings
vim config/config.yaml

# Start the server (migrations will be run automatically)
go run cmd/server/main.go

Alternatively for speedier local development, you can install the air package and run:

air

Docker

Build and run locally:

docker build -v ./uploads:/app/uploads --tag 0x45 ./docker
docker run -d -p 3000:3000 0x45

Or use the pre-built image:

docker pull ghcr.io/watzon/0x45:main
docker run -d -p 3000:3000 ghcr.io/watzon/0x45:main

Configuration

Configuration is done through the config/config.yaml file. See the example config for more information on the available options. When running in a docker container it might be more convenient to set the environment variables instead, here is a list of available options:

Database Configuration

Controls the database connection settings.

Environment VariableDescriptionDefault
0X_DATABASE_DRIVERDatabase driver to use (sqlite/postgres)sqlite
0X_DATABASE_HOSTDatabase hostlocalhost
0X_DATABASE_PORTDatabase port5432
0X_DATABASE_USERDatabase username""
0X_DATABASE_PASSWORDDatabase password""
0X_DATABASE_NAMEDatabase namepaste69.db
0X_DATABASE_SSLMODESSL mode for postgresdisable

Storage Configuration

Configure one or more storage backends for file storage. Multiple backends can be configured using numbered environment variables (0-9).

Environment VariableDescriptionDefault
0X_STORAGE_0_NAMEFirst storage backend namelocal
0X_STORAGE_0_TYPEFirst storage type (local/s3)local
0X_STORAGE_0_DEFAULTFirst storage is defaulttrue
0X_STORAGE_0_PATHFirst local storage path./uploads
0X_STORAGE_0_S3_BUCKETFirst S3 bucket name""
0X_STORAGE_0_S3_REGIONFirst S3 region""
0X_STORAGE_0_S3_KEYFirst S3 access key""
0X_STORAGE_0_S3_SECRETFirst S3 secret key""
0X_STORAGE_0_S3_ENDPOINTFirst S3 endpoint""
0X_STORAGE_1_NAMESecond storage backend name""
...(and so on for STORAGE_1 through STORAGE_9)

Server Configuration

Core server settings and behavior.

Environment VariableDescriptionDefault
0X_SERVER_ADDRESSServer listen address:3000
0X_SERVER_BASE_URLBase URL for the server""
0X_SERVER_MAX_UPLOAD_SIZEMaximum upload size in bytes5242880
0X_SERVER_DEFAULT_UPLOAD_SIZEDefault upload size in bytes5242880
0X_SERVER_API_UPLOAD_SIZEAPI upload size in bytes5242880
0X_SERVER_PREFORKEnable prefork modefalse
0X_SERVER_SERVER_HEADERServer header valuePaste69
0X_SERVER_APP_NAMEApplication namePaste69
0X_SERVER_CORS_ORIGINSCORS allowed origins[]
0X_SERVER_VIEWS_DIRECTORYDirectory for view templates./views
0X_SERVER_PUBLIC_DIRECTORYDirectory for public files./public

Cleanup Configuration

Settings for automatic content cleanup.

Environment VariableDescriptionDefault
0X_SERVER_CLEANUP_ENABLEDEnable automatic cleanuptrue
0X_SERVER_CLEANUP_INTERVALCleanup interval in seconds3600
0X_SERVER_CLEANUP_MAX_AGEMaximum age for content168h

Rate Limiting Configuration

Controls rate limiting behavior.

Environment VariableDescriptionDefault
0X_SERVER_RATE_LIMIT_GLOBAL_ENABLEDEnable global rate limitingtrue
0X_SERVER_RATE_LIMIT_GLOBAL_RATEGlobal requests per second100.0
0X_SERVER_RATE_LIMIT_GLOBAL_BURSTGlobal burst size50
0X_SERVER_RATE_LIMIT_PER_IP_ENABLEDEnable per-IP rate limitingtrue
0X_SERVER_RATE_LIMIT_PER_IP_RATEPer-IP requests per second1.0
0X_SERVER_RATE_LIMIT_PER_IP_BURSTPer-IP burst size5
0X_SERVER_RATE_LIMIT_USE_REDISUse Redis for rate limitingfalse
0X_SERVER_RATE_LIMIT_IP_CLEANUP_INTERVALIP cleanup interval1h

SMTP Configuration

Email sending configuration.

Environment VariableDescriptionDefault
0X_SMTP_ENABLEDEnable SMTP functionalityfalse
0X_SMTP_HOSTSMTP server host""
0X_SMTP_PORTSMTP server port587
0X_SMTP_USERNAMESMTP username""
0X_SMTP_PASSWORDSMTP password""
0X_SMTP_FROMFrom email address""
0X_SMTP_FROM_NAMEFrom namePaste69
0X_SMTP_STARTTLSUse STARTTLStrue

Redis Configuration

Redis connection settings.

Environment VariableDescriptionDefault
0X_REDIS_ENABLEDEnable Redisfalse
0X_REDIS_ADDRESSRedis server addresslocalhost:6379
0X_REDIS_PASSWORDRedis password""
0X_REDIS_DBRedis database number0

Retention Configuration

Content retention policy settings.

Environment VariableDescriptionDefault
0X_RETENTION_NO_KEY_MIN_AGEMinimum retention days without key7.0
0X_RETENTION_NO_KEY_MAX_AGEMaximum retention days without key128.0
0X_RETENTION_WITH_KEY_MIN_AGEMinimum retention days with key30.0
0X_RETENTION_WITH_KEY_MAX_AGEMaximum retention days with key730.0
0X_RETENTION_POINTSNumber of retention curve points50

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -am 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.