We welcome contributions to enhance Caddy Defender's capabilities! This guide outlines how to add new functionality through IP range sources or response handlers.
To block new IP ranges, you can create fetchers for different services or networks. These can be either:
- Static ranges: Predefined lists of IPs/CIDRs
- Dynamic sources: API-driven updates from service providers
-
Create a new fetcher
- Make a new file in
ranges/fetchers
- Implement the core interface with:
- Service name and description
- Range fetching logic
- Error handling
- Make a new file in
-
Register your fetcher
Add your new fetcher to the main registry list -
Rebuild and test
Use standard build tools to compile and verify your changes -
Update documentation
Add your source to the predefined ranges list in documentation
Response handlers determine how Caddy Defender interacts with matched requests. Common patterns include:
- Blocking requests
- Returning custom content
- Triggering security workflows
-
Create response handler
- Make a new file in
responders
- Implement the core response interface
- Include any configuration parameters
- Make a new file in
-
Register handler type
Add your handler to the configuration parser -
Add validation
Implement sanity checks for required parameters -
Update documentation
Document your handler in:- Caddyfile syntax examples
- JSON configuration reference
- Responder type matrix
-
Testing
Include unit tests for new features using the standard Go testing framework -
Documentation
Keep both developer and user documentation updated -
Backwards Compatibility
Maintain existing functionality unless deprecating features -
Code Style
Follow existing patterns and Go community standards -
Security Considerations
Highlight any security implications in pull requests
- Fork the repository
- Create a feature branch
- Implement your changes
- Add/update tests
- Update documentation
- Submit a pull request
For complex changes, please open an issue first to discuss the implementation approach.
Reach out through:
- GitHub Issues
- Email: caddydefender@jasoncameron.dev
We appreciate your contributions to making Caddy Defender more powerful and flexible!