Webhook Relay Service & CLI Tool
Forward webhooks from the cloud to your local development environment in real-time
DHOOK is a lightweight, self-hosted webhook relay service designed for developers. When building applications that integrate with external services like GitHub, Stripe, PayMe, or Telegram, you often need to receive webhooks during development. The problem is that these services require a publicly accessible URL, but your local development machine typically sits behind a NAT or firewall.
DHOOK solves this by acting as a relay between the internet and your local machine. You deploy the DHOOK server on any VPS or cloud server with a public IP, then run the DHOOK client on your local machine. The client connects to the server via WebSocket and receives all incoming webhooks in real-time, forwarding them to your local application. This allows you to develop and test webhook integrations without exposing your machine to the internet or paying for tunneling services.
# Install globally via pub.dev
dart pub global activate dhook
# Or install from source
dart pub global activate --source git https://github.com/alisheraxmedov/dhook.git# SSH to your server
ssh user@your-server.com
# Clone repository
git clone https://github.com/alisheraxmedov/dhook.git
cd dhook
# Run with Docker
docker-compose up -dcurl -X POST https://your-server.com/api/keys \
-H "Content-Type: application/json" \
-d '{"channel": "my-channel", "name": "production"}'
# Response: {"api_key": "dhk_xxx...", ...}dhook client \
--server wss://your-server.com/ws/my-channel \
--target http://localhost:8000 \
--api-key dhk_xxx...Point your webhook to:
https://your-server.com/webhook/my-channel
DHOOK uses API key authentication by default to secure your channels.
# First, start the server
dhook server --port 3000
# Create API key for your channel
curl -X POST https://your-server.com/api/keys \
-H "Content-Type: application/json" \
-d '{"channel": "my-channel", "name": "production"}'
# Response:
# {"api_key": "dhk_xxx...", "channel": "my-channel", ...}dhook client \
--server wss://your-server.com/ws/my-channel \
--target http://localhost:8000 \
--api-key dhk_xxx...# β οΈ NOT recommended for production!
dhook server --port 3000 --no-auth# Build and run
docker-compose up -d
# Check logs
docker-compose logs -f
# Stop
docker-compose down# Start relay server (auth enabled by default)
dhook server
# Start on custom port
dhook server --port 8080
# Disable auth (local development only)
dhook server --port 3000 --no-authdhook client \
--server wss://your-server.com/ws/my-channel \
--target http://localhost:8000 \
--api-key dhk_your_api_key| Endpoint | Method | Description |
|---|---|---|
/ |
GET | Health check |
/new |
GET | Generate new channel (redirects to /channel/) |
/ws/<channel> |
WS | WebSocket connection for CLI |
/webhook/<channel> |
ANY | Receive webhooks |
/webhook/<channel>/<path> |
ANY | Receive webhooks with subpath |
/api/keys |
POST | Create new API key (auth mode) |
/api/keys |
GET | List registered channels (auth mode) |
import 'package:dhook/dhook.dart';
// Start relay server (auth enabled by default)
final server = RelayServer(
port: 3000,
apiKeyStoragePath: 'keys.json',
);
await server.start();
// Start a CLI agent with API key
final agent = CliAgent(
serverUrl: 'wss://your-server.com/ws/my-channel',
targetUrl: 'http://localhost:8000',
apiKey: 'dhk_xxx...',
);
await agent.start();dhook/
βββ bin/
β βββ dhook.dart # CLI entry point
βββ lib/
β βββ dhook.dart # Library exports
β βββ src/
β βββ client/
β β βββ cli_agent.dart # WebSocket client
β βββ server/
β β βββ relay_server.dart # HTTP/WebSocket server
β β βββ api_key_manager.dart # API key authentication
β β βββ rate_limiter.dart # DoS protection
β βββ models/
β β βββ webhook_payload.dart
β βββ utils/
β βββ logger.dart
βββ Dockerfile
βββ docker-compose.yml
- API Key Authentication: Secure channels with
dhk_prefixed tokens - Rate Limiting: 100 requests/minute per IP (DoS protection)
- Body Size Limit: 1MB max for webhook payloads
- Cryptographic IDs: Secure channel ID generation
- TLS/SSL Support: Use with Nginx reverse proxy
MIT License - see LICENSE for details.
Alisher Axmedov
- GitHub: @alisheraxmedov
- Email: alisheraxmedov4x4@gmail.com
We welcome contributions from the community! If you would like to contribute to this project, please read our Contributing Guidelines for detailed instructions on how to get started.
If you find DHOOK useful, consider buying me a coffee!
Made with β€οΈ in Uzbekistan πΊπΏ
