github ChrispyBacon-dev/DockFlare v1.8.0
DockFlare v1.8.0 - Major Codebase Refactor!

latest releases: v2.1.7, v2.1.6, v2.1.5...
3 months ago

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 to state.json.
        • tunnel_manager.py: Handles Cloudflare Tunnel initialization, configuration updates, and cloudflared 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.
  • Frontend JavaScript Externalized:

    • All inline JavaScript from status_page.html has been moved to app/static/js/main.js.
    • status_page.html is now cleaner and primarily focused on HTML structure.
  • 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 (for build:css script) and tailwind.config.js (for content scanning) updated to align with the new app/ subdirectory structure.
    • GitHub Actions workflow (docker-image.yml) adjusted for the new Dockerfile 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. The load_state function now correctly mutates the shared managed_rules dictionary.
    • Fixed a deadlock scenario where save_state could hang if called by a thread that already held the state_lock, by changing state_lock to a threading.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 to generate_access_app_config_hash.
    • Fixed an AttributeError in update_cloudflared_container_status related to None.startswith().
    • Corrected an issue with oversized SVG icons in the UI by fixing a class name typo.
    • Improved robustness of save_state by avoiding copy.deepcopy() on entire rule objects and instead explicitly selecting fields for serialization.
  • Enhanced Logging:

    • Added more detailed logging, including object ID tracking during critical state operations, to aid in debugging shared state and threading issues.

Don't miss a new DockFlare release

NewReleases is sending notifications on new releases.