How destan19/openappfilter works
Project Type and Purpose
• The README clearly states that OAF is a parental control plug-in for OpenWrt routers, focusing on filtering apps (games, videos, chats, downloads, etc.) and allowing custom app rules.
• The project comprises several components: a LuCI-based web interface (for configuration) and underlying filtering modules (in C) that interact with the OpenWrt kernel/system.
File Structure
• Notice the presence of multiple packages:
– The “luci-app-oaf” directory contains the web interface components structured with MVC patterns:
▪ “luasrc/controller” – handles the routing of requests.
▪ “luasrc/model/cbi/appfilter” – contains configuration settings and business logic.
▪ “luasrc/view” – includes the front-end templates (HTML) to render configuration pages.
– The “oaf” and “open-app-filter” directories contain C source files and Makefiles:
▪ They implement the core filtering logic, configuration handling, possibly netlink communications with the kernel, and utilities (like JSON parsing via cJSON, regex handling, etc.).
– The “root” folder under “luci-app-oaf” includes UCI default configuration files which integrate the plug-in with OpenWrt’s system initialization.
• The separation into luci-app (UI) and C source code (core service/daemon) indicates a clear division between the presentation layer and the backend filtering functionality.
README for Additional Insights
• The README lays out the preparation, compilation, and installation steps. This highlights dependencies on the OpenWrt environment and the modular nature of the plug-in.
• It shows that proper version matching with OpenWrt and kernel compatibility is essential, implying a tight integration with the router’s firmware system.
a. Main Components:
• LuCI Web Interface Module:
• Controller, Model, and View layers found in “luci-app-oaf” facilitate user interactions and configurations.
• Core Filtering Service:
• C source modules (e.g., af_client, app_filter, and others in “oaf/src” and “open-app-filter/src”) implement the actual filtering logic.
• System Integration & Configuration:
• UCI defaults and Makefiles that integrate the plug-in into the OpenWrt environment.
• External Dependencies:
• Libraries such as cJSON and regexp, plus any netlink or kernel interaction components.
b. Relationships and Interactions:
• The LuCI interface (web frontend) sends configuration data via its controllers (Lua scripts) to the underlying service.
• The service layer (C components) processes these configurations, applies filtering rules, and interacts with the OpenWrt kernel or system (likely via netlink or system calls).
• Configuration files (such as those in “open-app-filter/files” and “luci-app-oaf/root/etc/uci-defaults”) ensure that when the router boots, the correct filtering rules and parameters are loaded.
c. Architectural Patterns & Design Principles:
• Use of the MVC pattern within the LuCI module for clear separation between UI and application logic.
• Modular design that separates user interface, business logic, and system integration.
• Clear delineation of compile-time configuration (Makefiles, UCI defaults) which enable integration into the OpenWrt system.
d. Relevant Technologies/Frameworks:
• OpenWrt and its SDK/build system.
• LuCI framework for the web interface.
• C programming for the filtering engine and related network/process management.
• Utility libraries such as cJSON and regular expression handling libraries.