7.3 KiB
OctoPrint Tailscale Funnel Plugin Design Document
1. Overview
The OctoPrint Tailscale Funnel Plugin is designed to make the OctoPrint web interface publicly accessible via Tailscale Funnel. This plugin will enable users to securely access their OctoPrint instance from anywhere on the internet without needing to configure port forwarding, dynamic DNS, or deal with complex firewall settings.
1.1 Purpose
The primary purpose of this plugin is to provide a simple, secure way for OctoPrint users to access their 3D printer's web interface remotely using Tailscale's Funnel feature, which creates encrypted tunnels from the public internet to local services.
1.2 Scope
This plugin will:
- Integrate with the existing Tailscale installation on the system
- Provide a user interface within OctoPrint to enable/disable Funnel access
- Configure and manage Tailscale Funnel for the OctoPrint web service
- Display the public URL for accessing OctoPrint remotely
- Handle authentication and security considerations
2. Architecture
2.1 System Components
The plugin consists of the following components:
- Plugin Core: The main plugin implementation that integrates with OctoPrint's plugin system
- Tailscale Interface: Component that communicates with the Tailscale daemon via CLI
- Web UI: Frontend elements that allow users to configure and monitor Funnel status
- Settings Management: Component that stores and retrieves plugin configuration
- Status Monitor: Background service that monitors the Funnel connection status
2.2 Component Interaction Diagram
graph TD
A[OctoPrint Web Interface] --> B[Plugin Core]
B --> C[Tailscale Interface]
B --> D[Web UI]
B --> E[Settings Management]
B --> F[Status Monitor]
C --> G[Tailscale Daemon]
D --> A
E --> B
F --> C
2.3 Plugin Integration Points
The plugin will integrate with OctoPrint through several mixin types:
- StartupPlugin: Initialize Tailscale integration on startup
- SettingsPlugin: Manage plugin configuration
- AssetPlugin: Provide custom JavaScript and CSS assets
- TemplatePlugin: Add UI elements to OctoPrint's interface
- BlueprintPlugin: Create custom API endpoints for plugin functionality
3. Plugin Features
3.1 Core Functionality
Feature | Description |
---|---|
Funnel Enable/Disable | Toggle Tailscale Funnel for OctoPrint web interface |
Status Monitoring | Display current Funnel connection status |
Public URL Display | Show the public URL for accessing OctoPrint |
Configuration Management | Store and retrieve plugin settings |
3.2 User Interface
The plugin will add a new section to OctoPrint's settings panel with the following elements:
- Status Indicator: Shows whether Funnel is currently enabled or disabled
- Enable/Disable Button: Toggle to turn Funnel on or off
- Public URL Display: Shows the public URL when Funnel is enabled
- Status Messages: Displays current status and any error messages
3.3 Security Considerations
- The plugin will require explicit user consent before enabling Funnel
- All communication with Tailscale will be done through the local CLI
- The plugin will not store any authentication credentials
- Users will be warned about the security implications of making their printer accessible from the internet
4. Implementation Details
4.1 Plugin Structure
The plugin will follow a standard OctoPrint plugin structure with separate directories for Python code, static assets (JavaScript and CSS), templates, and documentation files.
4.2 Main Plugin Implementation
The main plugin class will implement several OctoPrint mixins:
- StartupPlugin: Initialize Tailscale integration on startup
- SettingsPlugin: Manage plugin configuration
- AssetPlugin: Provide custom JavaScript and CSS assets
- TemplatePlugin: Add UI elements to OctoPrint's interface
- BlueprintPlugin: Create custom API endpoints for plugin functionality
4.3 Tailscale Integration
The plugin will interact with Tailscale through subprocess calls to the Tailscale command-line tool to check status, enable/disable Funnel, and retrieve connection information.
4.4 Configuration Options
The plugin will store the following settings:
Setting | Description | Default |
---|---|---|
enabled | Whether Funnel is enabled | False |
port | Port to expose via Funnel | 80 |
confirm_enable | Require confirmation before enabling | True |
5. API Endpoints
5.1 Custom API Routes
The plugin will expose the following API endpoints:
Endpoint | Method | Description |
---|---|---|
/api/plugin/tailscale_funnel/status | GET | Get current Funnel status |
/api/plugin/tailscale_funnel/enable | POST | Enable Tailscale Funnel |
/api/plugin/tailscale_funnel/disable | POST | Disable Tailscale Funnel |
5.2 API Response Format
All API responses will follow a standardized format that includes a status indicator, descriptive message, and data payload.
6. Frontend Implementation
6.1 JavaScript Components
The frontend will include a view model that:
- Fetches current Funnel status from the backend
- Provides methods to enable/disable Funnel
- Updates the UI with status information
- Handles user interactions
6.2 UI Elements
The settings panel will include:
- Toggle switch for enabling/disabling Funnel
- Read-only field displaying the public URL
- Status indicator showing connection state
- Action buttons for enabling/disabling
- Warning messages about security implications
7. Error Handling
7.1 Common Error Conditions
Error | Cause | Handling |
---|---|---|
Tailscale not installed | Missing tailscale command | Show installation instructions |
Not connected to tailnet | Tailscale not logged in | Prompt user to login |
Insufficient permissions | User can't run tailscale | Show permission error |
Funnel not enabled | Admin setting | Show configuration instructions |
7.2 User Feedback
The plugin will provide clear feedback for all operations:
- Success messages when operations complete
- Error messages with troubleshooting suggestions
- Progress indicators during operations
- Status updates in real-time
8. Testing Strategy
8.1 Unit Tests
Unit tests will cover:
- Tailscale command execution
- Status parsing logic
- Configuration management
- API endpoint responses
8.2 Integration Tests
Integration tests will verify:
- Proper communication with Tailscale daemon
- Correct UI updates based on status changes
- Settings persistence
- Error handling scenarios
8.3 Manual Testing
Manual testing will validate:
- UI appearance and usability
- End-to-end enable/disable workflow
- Error message clarity
- Cross-platform compatibility
9. Deployment
9.1 Installation Requirements
- OctoPrint 1.3.0 or higher
- Tailscale installed and configured on the system
- Python 3.7 or higher
9.2 Installation Process
- Install Tailscale on the system
- Install the plugin through OctoPrint's plugin manager
- Configure plugin settings in OctoPrint's settings panel
- Enable Funnel through the plugin interface
9.3 Dependencies
The plugin will have minimal dependencies:
- Standard Python libraries for subprocess management
- OctoPrint's built-in plugin framework
- Tailscale CLI (installed separately by user)