chore: bootstrap Claude setup

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
dasemuandClaude Sonnet 5 committed 2026-10-18 15:05:08 +02:00
1 parent 4f0a0423be
commit 4ed8ab0a0c
10 files changed
+428 -289

No files matched your search

+1
View File
@@ -0,0 +1 @@
2
+25
View File
@@ -0,0 +1,25 @@
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "file=$(cat | python3 -c 'import json,sys; print(json.load(sys.stdin).get(\"tool_input\",{}).get(\"file_path\",\"\"))'); case \"$file\" in *.py) python3 -m py_compile \"$file\" ;; esac"
}
]
}
],
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "python3 -m py_compile maskarr.py"
}
]
}
]
}
}
+24
View File
@@ -0,0 +1,24 @@
name: CI
on:
pull_request:
branches: [development]
push:
branches: [development, main]
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "pip"
- run: pip install -r requirements.txt
# No linter or test suite is configured for this project yet.
# This is a lightweight sanity check (syntax/import compile), not a test run.
- run: python3 -m py_compile maskarr.py
+68
View File
@@ -0,0 +1,68 @@
name: Version
on:
push:
branches: [development, main]
permissions:
contents: write
jobs:
bump:
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') && github.actor != 'github-actions[bot]' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Configure git identity
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Determine bump type
id: bump
run: |
if [ "${{ github.ref_name }}" = "development" ]; then
echo "type=patch" >> "$GITHUB_OUTPUT"
else
# main: minor bump only when this push is a merge (an approved
# development -> main PR), otherwise a direct hotfix push.
MERGE_COMMIT=$(git log -1 --merges --pretty=%H || true)
if [ -n "$MERGE_COMMIT" ]; then
echo "type=minor" >> "$GITHUB_OUTPUT"
else
echo "type=patch" >> "$GITHUB_OUTPUT"
fi
fi
- name: Bump VERSION
id: version
run: |
current=$(cat VERSION)
IFS='.' read -r major minor patch <<< "$current"
if [ "${{ steps.bump.outputs.type }}" = "minor" ]; then
minor=$((minor + 1))
patch=0
else
patch=$((patch + 1))
fi
new="$major.$minor.$patch"
echo "$new" > VERSION
echo "new=$new" >> "$GITHUB_OUTPUT"
- name: Commit and push version bump
run: |
git add VERSION
git commit -m "chore(release): v${{ steps.version.outputs.new }} [skip ci]"
git push origin HEAD:${{ github.ref_name }}
- name: Merge main back into development
if: github.ref_name == 'main'
run: |
git fetch origin development
git checkout development
git merge --no-edit origin/main
git push origin development
+29
View File
@@ -0,0 +1,29 @@
# CLAUDE.md
## Overview
Maskarr: a single-file Python HTTP proxy that rewrites User-Agent and headers so *arr stack apps (Prowlarr, Jackett) can reach private trackers. Includes a web UI for managing trackers and a JSON REST API.
## Commands
- Install: `pip install -r requirements.txt`
- Run (dev): `python3 maskarr.py`
- Quick check (no test suite exists yet): `python3 -m py_compile maskarr.py`
- Docker build: `docker build -t maskarr .`
- Docker run: `docker-compose up -d`
## Architecture
Everything lives in `maskarr.py`: an `http.server`-based proxy that forwards requests to the configured tracker domain with a rewritten User-Agent/headers, plus a small web UI and `/api/trackers` REST endpoints. Configuration persists to `maskarr_config.json` (path overridable via `CONFIG_PATH`). See `docs/usage.md` and `docs/deployment.md`.
## Conventions
- Only `CONFIG_PATH` is read from the environment (`maskarr.py`); everything else lives in `maskarr_config.json`.
- Keep `.env.example` limited to variable names actually read from the environment.
## Workflow quirks
- No linter/formatter (ruff/black/flake8) or test suite (pytest) is configured yet. The only available check is a syntax compile (`py_compile`); see LESSONS.md.
- No `development` branch exists yet; CI and the version workflow reference it per the standard shape, but they won't trigger until it's created.
## Deployment
Docker image published to GHCR and the private Gitea registry on push to `main`/tags (`.github/workflows/docker-publish.yml`, `.gitea/workflows/docker-publish.yml`). See `docs/deployment.md` for systemd and Docker instructions.
## Gotchas
- `maskarr_config.json` is tracked as an empty template; don't commit it populated with real tracker credentials/cookies.
- This proxy is meant for local/private-network use only (see Security notes in `docs/usage.md`).
+6
View File
@@ -0,0 +1,6 @@
# LESSONS.md
Recurring mistakes and how to avoid them. Read before starting work; add an entry when a mistake repeats.
## No linter or test suite configured
There is no `ruff`/`black`/`flake8`/`pytest` configuration in this repo. Don't assume a `lint`/`test` command exists — the closest available quick check is `python3 -m py_compile maskarr.py`.
+9 -289
View File
@@ -12,307 +12,27 @@ An HTTP proxy server that allows modifying User-Agent and headers to access priv
- **No crashes**: Robust exception and error handling
- **Logging**: Detailed request logging (optional)
## Requirements
## Quick start
```bash
pip install requests
```
# Install dependencies
pip install -r requirements.txt
## Installation
1. Clone or download the repository:
```bash
git clone <repo-url>
cd maskarr
```
2. Install dependencies:
```bash
pip install requests
```
3. Run the server:
```bash
# Run the server
python3 maskarr.py
```
Or make it executable:
```bash
chmod +x maskarr.py
./maskarr.py
```
Then open `http://localhost:8888` to configure your first tracker.
## Usage
## Documentation
### 1. Start the server
```bash
python3 maskarr.py
```
You'll see something like:
```
🎭 Maskarr - Tracker Proxy Server
==================================================
🌐 Server running on http://0.0.0.0:8888
📊 Web UI: http://localhost:8888
📝 Config file: /path/to/maskarr_config.json
==================================================
Press Ctrl+C to stop
```
### 2. Configure a tracker
1. Open your browser at `http://localhost:8888`
2. Fill in the form:
- **Tracker ID**: Unique identifier (e.g., `mytracker`)
- **Domain**: Tracker domain (e.g., `mytracker.com`)
- **User-Agent**: Browser user-agent you want to use
- **Additional headers**: JSON with extra headers (optional)
- **Timeout**: Timeout in seconds (default: 30)
- **Verify SSL**: Verify SSL certificate (recommended: enabled)
3. Click **Save Tracker**
### 3. Use the proxy in Prowlarr/Jackett
Each configured tracker will have a unique proxy URL:
```
http://localhost:8888/proxy/{tracker_id}/
```
For example, if you configured `mytracker`:
```
http://localhost:8888/proxy/mytracker/
```
You will have to create a custom definition for the indexer, copying one wich has been created already, and modifiyng it's base_url, using: `http://localhost:8888/proxy/mytracker`
## Configuration Examples
### Traker without custom headers
```json
{
"id": "mytracker",
"domain": "mytracker.com",
"user_agent": "Mozilla/5.0 (X11; Linux x86_64; rv:133.0) Gecko/20100101 Firefox/133.0",
"headers": {},
"timeout": 30,
"verify_ssl": true
}
```
### Tracker with custom headers
```json
{
"id": "mytracker",
"domain": "tracker.example.com",
"user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
"headers": {
"Referer": "https://tracker.example.com",
"X-Requested-With": "XMLHttpRequest"
},
"timeout": 45,
"verify_ssl": true
}
```
## REST API
### GET /api/trackers
Get all configured trackers.
**Response:**
```json
{
"trackers": {
"mytracker": {
"domain": "mytracker.com",
"user_agent": "Mozilla/5.0...",
"headers": {},
"timeout": 30,
"verify_ssl": true
}
}
}
```
### POST /api/trackers
Add or update a tracker.
**Body:**
```json
{
"id": "mytracker",
"domain": "mytracker.com",
"user_agent": "Mozilla/5.0...",
"headers": {},
"timeout": 30,
"verify_ssl": true
}
```
### DELETE /api/trackers/{tracker_id}
Delete a tracker.
## Advanced Configuration
### Change the port
Edit `maskarr_config.json`:
```json
{
"port": 9999,
"log_requests": true,
"trackers": {}
}
```
### Disable request logging
In `maskarr_config.json`:
```json
{
"log_requests": false
}
```
### Run as a service (systemd)
Create `/etc/systemd/system/maskarr.service`:
```ini
[Unit]
Description=Maskarr Tracker Proxy
After=network.target
[Service]
Type=simple
User=youruser
WorkingDirectory=/path/to/maskarr
ExecStart=/usr/bin/python3 /path/to/maskarr/maskarr.py
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
```
Enable and start:
```bash
sudo systemctl enable maskarr
sudo systemctl start maskarr
sudo systemctl status maskarr
```
### Docker
#### Using Docker Compose (recommended)
```bash
# Download docker-compose.yml
wget https://raw.githubusercontent.com/yourusername/maskarr/main/docker-compose.yml
# Create config directory
mkdir -p config
# Start the service
docker-compose up -d
# View logs
docker-compose logs -f
```
#### Using Docker directly
From GitHub Container Registry:
```bash
docker run -d \
--name maskarr \
-p 8888:8888 \
-v $(pwd)/config:/app/config \
--restart unless-stopped \
ghcr.io/yourusername/maskarr:latest
```
Or build the image locally:
```bash
# Clone the repository
git clone https://github.com/yourusername/maskarr.git
cd maskarr
# Build the image
docker build -t maskarr .
# Run the container
docker run -d \
--name maskarr \
-p 8888:8888 \
-v $(pwd)/config:/app/config \
--restart unless-stopped \
maskarr:latest
```
## CI/CD - Automatic Docker Image Publishing
The project includes workflows for **GitHub Actions** and **Gitea Actions** that automatically publish Docker images.
### Supported Registries
Each push to `main`/`master` or tag `v*.*.*` will publish to:
1. **GitHub Container Registry** (`ghcr.io`) - Primary and most reliable ⭐
2. **Gitea Container Registry** (your private instance)
### Using Published Images
```bash
# From GitHub Container Registry (recommended)
docker pull ghcr.io/dasemu/maskarr:latest
# From Gitea
docker pull git.dariosevilla.es/dasemu/maskarr:latest
```
## Troubleshooting
### Port in use
```
Error: Port 8888 might be already in use
```
Change the port in `maskarr_config.json` or close the application using port 8888.
### Permission denied
```
Error: Permission denied to bind to port 8888
```
Use a port > 1024 or run with privileges (not recommended).
### SSL Certificate Verify Failed
If the tracker uses a self-signed certificate, disable "Verify SSL" in the tracker configuration.
### Request timeout
Increase the "Timeout" value in the tracker configuration.
## Security
- **Don't expose the server to the internet**: It's designed for local use
- **Use HTTPS if exposing**: Consider a reverse proxy (nginx, Caddy)
- **Protect your cookies**: Cookies are passed through the proxy
- **Check the logs**: Enable `log_requests` for debugging
- [Usage, configuration and REST API](docs/usage.md)
- [Deployment (systemd, Docker, CI/CD)](docs/deployment.md)
## License
GNU GPL V3.0
GNU GPL v3.0
## Contributing
Pull requests welcome. For major changes, please open an issue first.
## Author
Created to facilitate the use of private trackers with *arr applications.
+1
View File
@@ -0,0 +1 @@
0.1.0
+99
View File
@@ -0,0 +1,99 @@
# Deployment
## Run as a service (systemd)
Create `/etc/systemd/system/maskarr.service`:
```ini
[Unit]
Description=Maskarr Tracker Proxy
After=network.target
[Service]
Type=simple
User=youruser
WorkingDirectory=/path/to/maskarr
ExecStart=/usr/bin/python3 /path/to/maskarr/maskarr.py
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
```
Enable and start:
```bash
sudo systemctl enable maskarr
sudo systemctl start maskarr
sudo systemctl status maskarr
```
## Docker
### Using Docker Compose (recommended)
```bash
# Download docker-compose.yml
wget https://raw.githubusercontent.com/yourusername/maskarr/main/docker-compose.yml
# Create config directory
mkdir -p config
# Start the service
docker-compose up -d
# View logs
docker-compose logs -f
```
### Using Docker directly
From GitHub Container Registry:
```bash
docker run -d \
--name maskarr \
-p 8888:8888 \
-v $(pwd)/config:/app/config \
--restart unless-stopped \
ghcr.io/yourusername/maskarr:latest
```
Or build the image locally:
```bash
# Clone the repository
git clone https://github.com/yourusername/maskarr.git
cd maskarr
# Build the image
docker build -t maskarr .
# Run the container
docker run -d \
--name maskarr \
-p 8888:8888 \
-v $(pwd)/config:/app/config \
--restart unless-stopped \
maskarr:latest
```
## CI/CD - automatic Docker image publishing
The project includes workflows for **GitHub Actions** and **Gitea Actions** that automatically
publish Docker images.
### Supported registries
Each push to `main`/`master` or tag `v*.*.*` will publish to:
1. **GitHub Container Registry** (`ghcr.io`) - primary and most reliable
2. **Gitea Container Registry** (your private instance)
### Using published images
```bash
# From GitHub Container Registry (recommended)
docker pull ghcr.io/dasemu/maskarr:latest
# From Gitea
docker pull git.dariosevilla.es/dasemu/maskarr:latest
```
+166
View File
@@ -0,0 +1,166 @@
# Usage
## 1. Start the server
```bash
python3 maskarr.py
```
You'll see something like:
```
Maskarr - Tracker Proxy Server
==================================================
Server running on http://0.0.0.0:8888
Web UI: http://localhost:8888
Config file: /path/to/maskarr_config.json
==================================================
Press Ctrl+C to stop
```
## 2. Configure a tracker
1. Open your browser at `http://localhost:8888`
2. Fill in the form:
- **Tracker ID**: Unique identifier (e.g., `mytracker`)
- **Domain**: Tracker domain (e.g., `mytracker.com`)
- **User-Agent**: Browser user-agent you want to use
- **Additional headers**: JSON with extra headers (optional)
- **Timeout**: Timeout in seconds (default: 30)
- **Verify SSL**: Verify SSL certificate (recommended: enabled)
3. Click **Save Tracker**
## 3. Use the proxy in Prowlarr/Jackett
Each configured tracker will have a unique proxy URL:
```
http://localhost:8888/proxy/{tracker_id}/
```
For example, if you configured `mytracker`:
```
http://localhost:8888/proxy/mytracker/
```
You will have to create a custom definition for the indexer, copying one which has been
created already, and modifying its `base_url` to:
`http://localhost:8888/proxy/mytracker`
## Configuration examples
### Tracker without custom headers
```json
{
"id": "mytracker",
"domain": "mytracker.com",
"user_agent": "Mozilla/5.0 (X11; Linux x86_64; rv:133.0) Gecko/20100101 Firefox/133.0",
"headers": {},
"timeout": 30,
"verify_ssl": true
}
```
### Tracker with custom headers
```json
{
"id": "mytracker",
"domain": "tracker.example.com",
"user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
"headers": {
"Referer": "https://tracker.example.com",
"X-Requested-With": "XMLHttpRequest"
},
"timeout": 45,
"verify_ssl": true
}
```
## REST API
### GET /api/trackers
Get all configured trackers.
**Response:**
```json
{
"trackers": {
"mytracker": {
"domain": "mytracker.com",
"user_agent": "Mozilla/5.0...",
"headers": {},
"timeout": 30,
"verify_ssl": true
}
}
}
```
### POST /api/trackers
Add or update a tracker.
**Body:**
```json
{
"id": "mytracker",
"domain": "mytracker.com",
"user_agent": "Mozilla/5.0...",
"headers": {},
"timeout": 30,
"verify_ssl": true
}
```
### DELETE /api/trackers/{tracker_id}
Delete a tracker.
## Advanced configuration
### Change the port
Edit `maskarr_config.json`:
```json
{
"port": 9999,
"log_requests": true,
"trackers": {}
}
```
### Disable request logging
In `maskarr_config.json`:
```json
{
"log_requests": false
}
```
## Troubleshooting
### Port in use
```
Error: Port 8888 might be already in use
```
Change the port in `maskarr_config.json` or close the application using port 8888.
### Permission denied
```
Error: Permission denied to bind to port 8888
```
Use a port > 1024 or run with privileges (not recommended).
### SSL certificate verify failed
If the tracker uses a self-signed certificate, disable "Verify SSL" in the tracker configuration.
### Request timeout
Increase the "Timeout" value in the tracker configuration.
## Security
- **Don't expose the server to the internet**: it's designed for local use.
- **Use HTTPS if exposing**: consider a reverse proxy (nginx, Caddy).
- **Protect your cookies**: cookies are passed through the proxy.
- **Check the logs**: enable `log_requests` for debugging.