GateKeeper
A security monitoring and IP blocking system written in Go that detects direct IP access attempts, checks them against AbuseIPDB, and automatically blocks malicious IPs in UniFi firewalls.
Features
- π Direct IP Access Detection - Monitors and logs all direct IP access attempts
- π‘οΈ Automatic IP Blocking - Integrates with UniFi controllers to block high-risk IPs
- π AbuseIPDB Integration - Checks IP reputation against AbuseIPDB
- π¨ Telegram Notifications - Real-time alerts via Telegram with customizable templates
- πΎ Payload Saving - Optional request payload capture for analysis
- β‘ Rate Limiting - Configurable per-IP rate limiting
- π Web Dashboard - Modern web interface to monitor blocked IPs and statistics
- ποΈ SQLite Database - Persistent storage of IP information
- π― IP Exclusion - Whitelist trusted IPs
- π Tarpit Mode - Slow down high-risk attackers
Installation
From Source
git clone https://github.com/TOomaAh/GateKeeper.git
cd GateKeeper
go build -o gatekeeper ./cmd/gatekeeper
Using Docker
docker-compose up -d
Using Pre-built Binaries
Download the latest release from the releases page.
Configuration
Create a config.yaml file based on config.yaml.example:
notifications:
telegram:
- chat_id: "YOUR_TELEGRAM_CHAT_ID"
token: "YOUR_TELEGRAM_BOT_TOKEN"
abuseip:
api_key: "YOUR_ABUSEIPDB_API_KEY"
unifi:
- url: "https://192.168.1.1:8443"
username: "admin"
password: "your_unifi_password"
ratelimit:
enabled: true
requests_per_minute: 5
database:
path: "./gatekeeper.db"
payload:
enabled: true
max_size: 1048576 # 1MB
directory: "./payloads"
dashboard:
enabled: true
port: ":8080"
excluded_ips:
- "192.168.1.10"
- "10.0.0.5"
Configuration Options
Notifications
- telegram: List of Telegram notification configurations
chat_id: Telegram chat ID for notifications
token: Telegram bot token
template: (Optional) Custom message template
AbuseIPDB
UniFi
- url: UniFi controller URL
- username: UniFi admin username
- password: UniFi admin password
You can configure multiple UniFi controllers.
Rate Limiting
- enabled: Enable/disable rate limiting
- requests_per_minute: Maximum requests per IP per minute
Database
- path: Path to SQLite database file
Payload
- enabled: Enable/disable payload saving
- max_size: Maximum payload size in bytes
- directory: Directory to store captured payloads
Dashboard
- enabled: Enable/disable web dashboard
- port: HTTP port for dashboard (e.g.,
:8080)
IP Exclusion
- excluded_ips: List of IPs to whitelist (no checks performed)
Usage
Running the Application
./gatekeeper -config config.yaml
Docker Compose
docker-compose up -d
Accessing the Dashboard
Once running, access the dashboard at: http://localhost:8080
The dashboard displays:
- Total IPs tracked
- Active entries
- Blocked IPs count
- Database size
- System uptime
- Recent IP activity table with scores and status
How It Works
- Detection: GateKeeper listens on port 8888 and detects direct IP access attempts
- Rate Limiting: Applies per-IP rate limiting if enabled
- IP Check: Queries AbuseIPDB for IP reputation score
- Database: Stores IP information in SQLite with TTL
- Blocking: High-risk IPs (score β₯ 75) are automatically added to UniFi firewall groups
- Notification: Sends alerts via Telegram with IP details
- Response:
- High-risk IPs: Tarpit mode (slow connection)
- Other IPs: Drop connection immediately
API Endpoints
Dashboard API
GET /api/stats - Returns system statistics
GET /api/ips - Returns list of recent IPs (last 100)
Example response for /api/stats:
{
"database_stats": {
"TotalEntries": 150,
"ActiveEntries": 45,
"BlockedEntries": 23,
"DBSize": 49152
},
"uptime": "2h15m30s",
"timestamp": "2025-11-05T10:30:00Z"
}
Building from Source
Requirements
Build
go build -o gatekeeper ./cmd/gatekeeper
Cross-compilation
# Linux AMD64
GOOS=linux GOARCH=amd64 go build -o gatekeeper-linux-amd64 ./cmd/gatekeeper
# Windows AMD64
GOOS=windows GOARCH=amd64 go build -o gatekeeper-windows-amd64.exe ./cmd/gatekeeper
# macOS ARM64
GOOS=darwin GOARCH=arm64 go build -o gatekeeper-darwin-arm64 ./cmd/gatekeeper
Development
Project Structure
.
βββ cmd/
β βββ gatekeeper/
β βββ main.go # Application entry point
βββ internal/
β βββ abuseip/ # AbuseIPDB client
β βββ cache/ # Caching layer
β βββ config/ # Configuration management
β βββ dashboard/ # Web dashboard
β βββ database/ # SQLite database
β βββ domain/ # Domain types
β βββ gatekeeper/ # Core logic
β βββ notification/ # Notification system
β βββ ratelimit/ # Rate limiting
β βββ unifi/ # UniFi controller client
βββ config.yaml.example # Example configuration
βββ Dockerfile # Docker image definition
βββ docker-compose.yml # Docker compose setup
βββ .goreleaser.yml # GoReleaser configuration
Running Tests
go test ./...
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Security Considerations
- Store your
config.yaml securely and never commit it to version control
- Use strong passwords for UniFi controllers
- Keep your AbuseIPDB API key confidential
- Regularly review the excluded IPs list
- Monitor the dashboard for unusual activity
- Review captured payloads for security research only
Acknowledgments