Skip to content

Expand documentation and add daemon CLI improvements#3

Open
jackhart wants to merge 1 commit into
mainfrom
claude/fix-daemon-functionality-7W4ct
Open

Expand documentation and add daemon CLI improvements#3
jackhart wants to merge 1 commit into
mainfrom
claude/fix-daemon-functionality-7W4ct

Conversation

@jackhart

@jackhart jackhart commented Feb 4, 2026

Copy link
Copy Markdown
Owner

Summary

This PR significantly expands the project documentation and improves the daemon CLI interface. The README has been restructured to provide comprehensive guidance on configuration, usage, and architecture, while the CLI has been enhanced with better argument handling and daemon mode support.

Key Changes

Documentation (README.md)

  • Expanded feature list with clear descriptions of static routing, wildcard routes, dynamic handling, SSM, C extension, and interactive shell
  • Detailed configuration guide with INI format specification, physical interface setup, and multicast route definitions
  • Route type documentation explaining the difference between static routes (explicit source) and dynamic/wildcard routes (source 0.0.0.0)
  • Comprehensive examples covering simple forwarding, CIDR wildcards, SSM, and mixed configurations
  • REST API documentation with endpoint tables, JSON format examples, and curl usage examples
  • Architecture diagram showing the layered design (REST API → Daemon → Kernel API → C Extension → Linux Kernel)
  • Developer quick start with project structure and roadmap
  • Host configuration section with sysctl settings for multicast routing

CLI Improvements (main.py)

  • Added --daemon flag to run as a background daemon (double-fork)
  • Changed default --host from 172.20.0.2 to 0.0.0.0 for broader accessibility
  • Added type=int to --port argument for proper type validation
  • Improved help text and argument descriptions
  • Added module-level docstring with usage examples
  • Refactored daemon execution logic to support both foreground and background modes
  • Renamed internal daemon attribute to daemon_main for clarity

Configuration Parser (config.py)

  • Added comprehensive docstrings to all functions and classes
  • Implemented MRoute.matches_group() method to support CIDR prefix matching
  • Enhanced _parse_group_address() to support both single addresses and CIDR networks
  • Added validation that configured interfaces exist and are multicast-capable
  • Improved error messages with context about which route/interface failed
  • Added file existence check in load_config()
  • Better handling of empty/missing configuration sections

Notable Implementation Details

  • CIDR Support: Routes can now use CIDR notation (e.g., 239.1.0.0/24) for wildcard group matching
  • Dynamic vs Static Routes: Documentation clarifies that routes with source = 0.0.0.0 are dynamic (installed on-demand) while explicit source IPs are static (pre-installed)
  • Daemon Mode: The --daemon flag uses a DaemonContext for proper double-fork daemonization
  • Configuration Validation: Interface names are validated against the configured phyints list to catch configuration errors early

https://claude.ai/code/session_011SHzjaNfRzKskvoWur8xD9

… docs

Bug fixes in simple.py:
- Fix VifManager.add() treating mcast_index=0 as None (`if not` -> `if is None`)
- Fix DELETE /vifs path parameter mismatch (interface_name vs interface_name_or_index)
- Fix MfcManager.add() crashing on new dynamic routes (ValueError from list.index)
- Fix MfcManager.match() accessing wrong attributes on MRoute vs MFCEntry objects
- Fix ControlMessageHandler accessing .oifs on MRoute (should be .to)
- Fix POST /mfc return using string key on int-keyed dict
- Add proper HTTP error responses (404, 400, 409) instead of bare Python exceptions
- Remove dead code (_ttls_list function)
- Fix static_mfc() dict key check (use `in` instead of `.get()` truthiness)

Bug fixes in config.py:
- Add CIDR notation support for multicast groups (e.g., 239.1.0.0/24)
- Add MRoute.matches_group() for wildcard/prefix matching
- Add config file existence check (raise FileNotFoundError)
- Add route interface validation against configured phyints
- Fix _str_to_list returning empty strings from trailing commas

Bug fixes in utils.py:
- Fix DaemonContext PID file writing (bytes(int) -> str(int))
- Fix PID file cleanup on exit (unlink instead of just close)
- Add proper signal handler registration (SIGTERM)
- Add stdin/stdout/stderr redirect to /dev/null
- Use os._exit() in fork to avoid flushing parent buffers

Other fixes:
- Fix hardcoded path in test_simple.py (use Path(__file__).parent)
- Update __main__.py: add --daemon flag, fix --port type, rename default host
- Comprehensive README with configuration reference, REST API docs, examples

https://claude.ai/code/session_011SHzjaNfRzKskvoWur8xD9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants