Key features implemented: - Updated package metadata and dependencies in PKG-INFO, setup files - Added main.py entry point for backward compatibility with README launch method - Enhanced CLI with config options, system info command, and proper signal handling - Implemented minimal PluginManager loading only plugin-loader core plugin - Refactored PluginLoader to follow minimal core design, removed sandbox/isolation complexity - Updated auto-dependency plugin with safer PL injection mechanism and disabled pl_injection - Removed legacy plugin files (firewall, frp_proxy, ftp_server, multi_lang_deploy, ops_toolbox, security_gateway) as functionality moved to core plugin system - Improved gitignore with comprehensive ignore patterns The changes implement a minimal core framework design where only the plugin-loader is directly loaded by the core, with all other plugins managed through the PL injection mechanism, significantly simplifying the architecture.
37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
"""插件代理 - 防越级访问"""
|
|
|
|
|
|
class PermissionError(Exception):
|
|
"""权限错误"""
|
|
pass
|
|
|
|
|
|
class PluginProxy:
|
|
"""插件代理"""
|
|
|
|
def __init__(self, plugin_name: str, plugin_instance: any,
|
|
allowed_plugins: list[str], all_plugins: dict[str, dict]):
|
|
self._plugin_name = plugin_name
|
|
self._plugin_instance = plugin_instance
|
|
self._allowed_plugins = set(allowed_plugins)
|
|
self._all_plugins = all_plugins
|
|
|
|
def get_plugin(self, name: str) -> any:
|
|
"""获取其他插件实例(带权限检查)"""
|
|
if name not in self._allowed_plugins and "*" not in self._allowed_plugins:
|
|
raise PermissionError(
|
|
f"插件 '{self._plugin_name}' 无权访问插件 '{name}'"
|
|
)
|
|
if name not in self._all_plugins:
|
|
return None
|
|
return self._all_plugins[name]["instance"]
|
|
|
|
def list_plugins(self) -> list[str]:
|
|
"""列出有权限访问的插件"""
|
|
if "*" in self._allowed_plugins:
|
|
return list(self._all_plugins.keys())
|
|
return [n for n in self._allowed_plugins if n in self._all_plugins]
|
|
|
|
def __getattr__(self, name: str):
|
|
return getattr(self._plugin_instance, name)
|