Medusa is a modern, refactored config generator for proxy tools. It fetches subscription URLs and converts them to proxy configurations with improved security, maintainability, and extensibility.
- Secure: Eliminated
eval()security vulnerability with proper dispatch system - Modular: Clean separation of concerns with pluggable backends
- Type-safe: Full type annotations with Pydantic validation
- Robust: Comprehensive error handling and logging
- Extensible: Easy to add new proxy types and backends
- Tested: Comprehensive test suite with pytest
pip install -e .For development:
pip install -e ".[dev]"Basic usage:
medusa -o glider.confWith custom configuration:
medusa -o output.conf --config my_config.yml --backend glider --verboseCreate a config.yml file with your subscription URLs:
subscriptions:
- https://example.com/subscription1
- https://example.com/subscription2The refactored Medusa follows a clean, modular architecture:
medusa/
├── cli/ # Command-line interface
├── core/ # Core functionality (fetching, parsing, converting)
├── backends/ # Backend implementations (Glider, etc.)
├── config/ # Configuration management
├── utils/ # Utilities (logging, exceptions)
└── templates/ # Configuration templates
- URLFetcher: Handles subscription URL fetching with retry logic
- ContentDecoder: Multi-strategy content decoding (Base64, plain text)
- URLParser: Validates and parses proxy URLs
- BackendConverter: Pluggable backend system for different proxy tools
- ConfigLoader: Configuration loading with validation
- Glider (default) - Full support
- Shadowsocks (ss://) - ✅ Full support
- Trojan (trojan://) - ✅ Full support
- VMess (vmess://) - 🚧 Framework ready, implementation pending
- VLESS (vless://) - 🚧 Framework ready, implementation pending
pytestWith coverage:
pytest --cov=medusa --cov-report=htmlFormat code:
black medusa/ tests/Lint code:
ruff check medusa/ tests/Type checking:
mypy medusa/- Create a new backend class inheriting from
BackendConverter - Implement required methods (
name,supported_schemes,convert) - Register the backend in
ConverterRegistry
- Create a handler class inheriting from
ProxyHandler - Implement the
convertmethod for your proxy type - Add the handler to the appropriate backend converter
The refactored version maintains CLI compatibility while providing:
- Improved Security: No more
eval()usage - Better Error Handling: Graceful failure with detailed logging
- Enhanced Logging: Structured logging with configurable levels
- Type Safety: Full type annotations and validation
- Modular Design: Easy to extend and maintain
MIT License