DockFlare v1.8.0 - Major Codebase Refactor!
This release marks a significant internal overhaul of DockFlare's codebase, focused on enhancing modularity, maintainability, and future development. While the core functionality remains the same, the underlying structure has been substantially improved.
Key Changes & Improvements:
-
Major Codebase Refactoring:
- The main
app.py
has been deconstructed into a more organized, package-based structure:app/core/
: Contains distinct modules for core business logic:access_manager.py
: Manages Cloudflare Access Application interactions.cloudflare_api.py
: Centralizes all direct Cloudflare API calls.docker_handler.py
: Handles Docker event listening and container label processing.reconciler.py
: Implements state reconciliation and cleanup of expired rules.state_manager.py
: Manages application state (managed_rules
) and persistence tostate.json
.tunnel_manager.py
: Handles Cloudflare Tunnel initialization, configuration updates, andcloudflared
agent management.
app/web/
: Contains Flask-specific components:routes.py
: Defines all web UI routes using Flask Blueprints.
app/config.py
: Centralizes all environment variable loading and application constants.app/__init__.py
: Initializes the Flask application, logging, and global components.app/main.py
: Serves as the main entry point for running the application.
- This modular structure improves separation of concerns, making the code easier to understand, debug, and extend.
- The main
-
Frontend JavaScript Externalized:
- All inline JavaScript from
status_page.html
has been moved toapp/static/js/main.js
. status_page.html
is now cleaner and primarily focused on HTML structure.
- All inline JavaScript from
-
Build Process Refinements:
Dockerfile
updated to correctly build the application with the new directory structure, including the multi-stage frontend asset build.- Paths in
package.json
(forbuild:css
script) andtailwind.config.js
(forcontent
scanning) updated to align with the newapp/
subdirectory structure. - GitHub Actions workflow (
docker-image.yml
) adjusted for the newDockerfile
location and build context.
-
Bug Fixes & Stability Improvements (discovered and addressed during refactoring):
- Resolved potential circular import issues related to the Flask
app
instance. - Addressed issues with
state.json
not saving correctly due to Python's handling of module-level global variables during imports and re-initialization. Theload_state
function now correctly mutates the sharedmanaged_rules
dictionary. - Fixed a deadlock scenario where
save_state
could hang if called by a thread that already held thestate_lock
, by changingstate_lock
to athreading.RLock()
(Re-entrant Lock). - Corrected
NameError
exceptions in UI route handlers by ensuring proper function calls (e.g., using module prefixes or correct imports). - Resolved a
TypeError
in UI policy updates by ensuring all required arguments were passed togenerate_access_app_config_hash
. - Fixed an
AttributeError
inupdate_cloudflared_container_status
related toNone.startswith()
. - Corrected an issue with oversized SVG icons in the UI by fixing a class name typo.
- Improved robustness of
save_state
by avoidingcopy.deepcopy()
on entire rule objects and instead explicitly selecting fields for serialization.
- Resolved potential circular import issues related to the Flask
-
Enhanced Logging:
- Added more detailed logging, including object ID tracking during critical state operations, to aid in debugging shared state and threading issues.