--- title: "Config Editor" description: "Documentation for Config Editor" --- ## Table of Contents 1. [Overview & Editor Architecture](#1-overview--editor-architecture) 2. [Business & Operational Significance](#2-business--operational-significance) 3. [🎯 User Roles & Key Capabilities](#3--user-roles--key-capabilities) 4. [Visual Interface & Layout](#4-visual-interface--layout) 5. [Controls & Action Bar Reference](#5-controls--action-bar-reference) 6. [Safe Modification & Dry-Run Lifecycle](#6-safe-modification--dry-run-lifecycle) 7. [Best Practices for Direct Script Modifications](#7-best-practices-for-direct-script-modifications) 8. [Troubleshooting & Backup Recovery](#8-troubleshooting--backup-recovery) 9. [Model Context Protocol (MCP) AI Integration](#9-model-context-protocol-mcp-ai-integration) 10. [Glossary](#10-glossary) --- ## 1. Overview & Editor Architecture In **Ring2All SBC**, the **Config Editor** module provides a high-security, browser-based integrated development environment (IDE) for reviewing, modifying, validating, and applying changes to the primary Kamailio routing script (`/etc/kamailio/kamailio.cfg`) and auxiliary configuration files. Built on the Monaco editor engine, it features syntax highlighting, line numbering, code folding, and automated pre-flight dry-run validation (`kamailio -c`) to eliminate the risk of service disruption from syntax errors. ``` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Ring2All SBC Config Editor (Web IDE) β”‚ β”‚ β”‚ β”‚ 1. Edit kamailio.cfg in Monaco Editor β”‚ β”‚ 2. Click "Validate Syntax" ──► Runs "kamailio -c -f /tmp/test.cfg" β”‚ β”‚ 3. Syntax Passed (0 Errors)? β”‚ β”‚ β”œβ”€β”€ YES: Create Timestamped Backup (.bak) ──► Write /etc/kamailio β”‚ β”‚ └── NO: Lock Save Action & Highlight Syntax Error Line β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ``` The system treats configuration files as critical infrastructure assets, guaranteeing that an administrator cannot apply an invalid script that would prevent the SIP core from initializing. --- ## 2. Business & Operational Significance * **Zero-Terminal Platform Governance**: Allows authorized senior engineers to adjust routing scripts, modify module parameters, and define custom filters without requiring direct SSH terminal access. * **Guaranteed Uptime via Dry-Run Verification**: Enforces a strict pre-flight syntax validation cycle (`kamailio -c`) before changes can be written to disk, preventing syntax typos from causing platform crashes. * **Automated Rollback & Version Snapping**: Automatically generates an immutable, timestamped backup (`kamailio.cfg.YYYYMMDD_HHMMSS.bak`) prior to committing any file change. * **Complete Configuration Visibility**: Provides unified access to all modular includes (e.g., `tls.cfg`, `dispatcher.list`, `kamailio-local.cfg`) from a single management console. --- ## 3. 🎯 User Roles & Key Capabilities | Role | Primary Use Case | Key Capabilities | | :--- | :--- | :--- | | **Principal SBC Architect** | Core Script Maintenance | Author custom routing logic, configure module parameters, and optimize transaction pipelines. | | **DevOps & Telecom Engineer** | CI/CD & Configuration Auditing | Review live production configuration scripts against Git repositories and verify module parameters. | | **Security Compliance Specialist** | Perimeter Policy Enforcement | Review access control lists, TLS parameters, and firewall rules declared in script headers. | | **Operations Tier 3 Specialist** | Emergency Hotfixes | Apply hotfix logic for unusual carrier signaling behaviors directly through verified web workflows. | | **AI Configuration Assistant / Script Auditor** | Automated Syntax & Configuration Inspection | Inspect Kamailio configuration snippets, verify include directives, and audit core parameters via MCP. | --- ## 4. Visual Interface & Layout The Config Editor interface integrates a Monaco code editor canvas, file switcher tabs, a live syntax validation output drawer, and action buttons for testing, saving, and reloading. ![Config Editor Live Interface](/screenshots/sbc/settings/tools/config-editor/config-editor.png) --- ## 5. Controls & Action Bar Reference | Control Element | Action Type | Behavior & Purpose | | :--- | :--- | :--- | | **File Selector** | Dropdown | Switches between primary files: `kamailio.cfg`, `tls.cfg`, `kamailio-local.cfg`, `dispatcher.list`. | | **Validate Syntax** | Button (`kamailio -c`) | Executes a non-destructive syntax check in an isolated temporary buffer. Outputs results to the console drawer. | | **Save Configuration** | Button | Commits modifications to disk. Automatically disabled if the last validation failed. Creates an atomic `.bak` snapshot. | | **Reload Engine** | Button (`kamcmd`) | Triggers an engine reload of dynamic modules (or prompts for service restart if static parameters changed). | | **Console Output Drawer** | Collapsible Panel | Displays live standard output and standard error from the `kamailio -c` verification command. | --- ## 6. Safe Modification & Dry-Run Lifecycle To ensure 100% operational safety, Ring2All SBC enforces a five-stage deployment lifecycle: 1. **Staging Buffer**: Edits made in the browser are kept in browser memory and transferred to a temporary staging file (`/tmp/kamailio_check.cfg`). 2. **Dry-Run Validation**: The backend executes the native validation binary: ```bash kamailio -c -f /tmp/kamailio_check.cfg ``` 3. **Error Trapping**: If the parser encounters a missing semicolon, unclosed brace, or invalid module parameter, the save button remains locked and the exact line number is highlighted in the editor. 4. **Atomic Snapshot**: Upon successful validation, the current active configuration is cloned to `/etc/kamailio/backups/kamailio.cfg..bak`. 5. **Commit & Reload**: The verified file replaces `/etc/kamailio/kamailio.cfg`, and the operator is prompted to reload running configurations. --- ## 7. Best Practices for Direct Script Modifications * **Avoid Blocking I/O in Request Routes**: Never place synchronous database queries, slow HTTP calls, or file writes inside high-frequency `request_route` blocks. Always utilize asynchronous worker modules (`http_async_client`, `evapi`). * **Use Modular Includes**: Keep the main `kamailio.cfg` clean by separating complex rules into dedicated include files: ```text import_file "tls.cfg" import_file "custom_routing.cfg" ``` * **Verify Memory Allocation (`shm` / `pkg`)**: When adding new tables or large arrays, confirm in **Engine Settings** that shared memory pools are sufficiently sized to accommodate the expanded data structures. --- ## 8. Troubleshooting & Backup Recovery ### Manual Syntax Check via CLI If the Web UI is unavailable or testing from a terminal: ```bash kamailio -c -f /etc/kamailio/kamailio.cfg ``` Expected success output: ```text config file ok, syntax ok ``` ### Restoring an Automated Backup If an applied change leads to unintended routing behavior, restore the prior configuration: ```bash # List available backups ls -lt /etc/kamailio/backups/ # Restore the previous known-good backup cp /etc/kamailio/backups/kamailio.cfg.20260907_110000.bak /etc/kamailio/kamailio.cfg # Test and restart service kamailio -c && systemctl restart kamailio ``` --- ## 9. Model Context Protocol (MCP) AI Integration The Config Editor subsystem provides Model Context Protocol (MCP) tools that enable AI agents to read, analyze, and inspect Kamailio configuration scripts and modular includes safely without executing destructive writes. ### Available MCP Tools | Tool Name | Operation Type | Risk Level | Description | | :--- | :--- | :--- | :--- | | `list_config_snippets` | Status Query | `read` | List available Kamailio configuration files, drop-in snippets, and include modules. | | `get_config_snippet` | Content Inspection | `read` | Retrieve the read-only contents of a specific Kamailio configuration snippet or include file. | ### Tool Schemas & Payloads #### 1. `list_config_snippets` ##### Input Schema ```json { "type": "object", "properties": {} } ``` ##### Output Payload Example ```json { "success": true, "data": { "totalSnippets": 4, "snippets": [ { "name": "kamailio.cfg", "path": "/etc/kamailio/kamailio.cfg", "writable": true, "sizeBytes": 28410 }, { "name": "tls.cfg", "path": "/etc/kamailio/tls.cfg", "writable": true, "sizeBytes": 4120 }, { "name": "dispatcher.list", "path": "/etc/kamailio/dispatcher.list", "writable": true, "sizeBytes": 1280 }, { "name": "smr_rules.cfg", "path": "/etc/kamailio/smr_rules.cfg", "writable": true, "sizeBytes": 3490 } ] } } ``` #### 2. `get_config_snippet` ##### Input Schema ```json { "type": "object", "properties": { "snippet_name": { "type": "string", "description": "Name or relative filename of the configuration snippet (e.g. 'tls.cfg')." } }, "required": ["snippet_name"] } ``` ##### Output Payload Example ```json { "success": true, "data": { "name": "tls.cfg", "path": "/etc/kamailio/tls.cfg", "lines": 48, "content": "# TLS Configuration for Ring2All SBC\n[server:default]\nmethod = TLSv1.2+\nverify_certificate = no\nrequire_certificate = no\n..." } } ``` ### Natural Language AI Prompts #### English Examples * *"List all Kamailio configuration files and snippets available on the SBC."* * *"Read the contents of 'tls.cfg' to inspect active TLS cipher suites and verification options."* * *"Inspect the 'smr_rules.cfg' file to verify which header modification routes are currently loaded."* #### Spanish Examples (EspaΓ±ol) * *"Lista todos los archivos de configuraciΓ³n y snippets de Kamailio disponibles en el SBC."* * *"Lee el contenido de 'tls.cfg' para inspeccionar las suites de cifrado TLS y las opciones de verificaciΓ³n activas."* * *"Inspecciona el archivo 'smr_rules.cfg' para verificar quΓ© rutas de modificaciΓ³n de cabeceras estΓ‘n cargadas."* ### Enterprise Safeguards & Access Governance 1. **Strict Path Sandboxing**: The `get_config_snippet` tool strictly disallows path traversal outside `/etc/kamailio/`. 2. **Read-Only AI Operation**: Direct programmatic writes to core `.cfg` files via MCP are prevented; all live script mutations must pass through the Web IDE's dry-run validation lifecycle. 3. **Credential Redaction**: Any hardcoded passwords or authentication secrets in config files are automatically masked before being returned in MCP responses. --- ## 10. Glossary * **Monaco Editor**: The open-source code editor that powers Microsoft Visual Studio Code, integrated into Ring2All SBC for web-based editing. * **Dry-Run Validation (`-c`)**: A Kamailio command-line flag that compiles and validates the configuration file without starting network listeners or binding sockets. * **Atomic Save**: A file-writing technique that guarantees file contents are written completely or not at all, preventing corrupted partial files. * **Code Folding**: An editor feature that allows users to collapse or expand sections of code (such as routes or blocks) for easier navigation.