diff --git a/Common/i18n.go b/Common/i18n.go index ce74381..5543fa5 100644 --- a/Common/i18n.go +++ b/Common/i18n.go @@ -1,991 +1,71 @@ package Common -import "fmt" +import "github.com/shadow1ng/fscan/Common/i18n" + +/* +i18n.go - 国际化支持(向后兼容层) + +此文件保持向后兼容,实际国际化功能已迁移到Common/i18n包 +建议新代码使用i18n.GetText()获取国际化文本 +*/ + +// ============================================================================= +// 向后兼容的语言常量 +// ============================================================================= -// 语言常量 const ( - LangZH = "zh" - LangEN = "en" + LangZH = i18n.LangZH // 中文 + LangEN = i18n.LangEN // 英文 ) -// 完整的国际化消息映射 -var coreMessages = map[string]map[string]string{ - // ========================= 解析错误消息 ========================= - "parse_error_empty_input": { - LangZH: "输入参数为空", - LangEN: "Input parameters are empty", - }, - "parse_error_config_failed": { - LangZH: "解析配置失败: %v", - LangEN: "Failed to parse configuration: %v", - }, - "parse_error_parser_not_init": { - LangZH: "解析器未初始化", - LangEN: "Parser not initialized", - }, - "parse_error_credential_failed": { - LangZH: "凭据解析失败: %v", - LangEN: "Failed to parse credentials: %v", - }, - "parse_error_target_failed": { - LangZH: "目标解析失败: %v", - LangEN: "Failed to parse targets: %v", - }, - "parse_error_network_failed": { - LangZH: "网络解析失败: %v", - LangEN: "Failed to parse network configuration: %v", - }, - "parse_error_validation_failed": { - LangZH: "验证失败: %v", - LangEN: "Validation failed: %v", - }, - "parse_error_update_vars_failed": { - LangZH: "更新全局变量失败: %v", - LangEN: "Failed to update global variables: %v", - }, - "parse_error_target_empty": { - LangZH: "目标输入为空", - LangEN: "Target input is empty", - }, - "parse_error_credential_empty": { - LangZH: "凭据输入为空", - LangEN: "Credential input is empty", - }, - "parse_error_network_empty": { - LangZH: "网络配置为空", - LangEN: "Network configuration is empty", - }, - "parse_error_invalid_ip": { - LangZH: "无效的IP地址: %s", - LangEN: "Invalid IP address: %s", - }, - "parse_error_invalid_port": { - LangZH: "无效的端口: %s", - LangEN: "Invalid port: %s", - }, - "parse_error_invalid_url": { - LangZH: "无效的URL: %s", - LangEN: "Invalid URL: %s", - }, - "parse_error_file_not_found": { - LangZH: "文件未找到: %s", - LangEN: "File not found: %s", - }, - "parse_error_file_read_failed": { - LangZH: "读取文件失败: %s", - LangEN: "Failed to read file: %s", - }, +// ============================================================================= +// 向后兼容的全局函数 +// ============================================================================= - // ========================= 配置相关消息 ========================= - "config_sync_start": { - LangZH: "开始同步配置", - LangEN: "Starting configuration sync", - }, - "config_sync_complete": { - LangZH: "配置同步完成", - LangEN: "Configuration sync completed", - }, - "config_validation_start": { - LangZH: "开始配置验证", - LangEN: "Starting configuration validation", - }, - "config_validation_complete": { - LangZH: "配置验证完成", - LangEN: "Configuration validation completed", - }, - "config_invalid_scan_mode": { - LangZH: "无效的扫描模式: %s", - LangEN: "Invalid scan mode: %s", - }, - "config_invalid_thread_num": { - LangZH: "无效的线程数: %d", - LangEN: "Invalid thread number: %d", - }, - "config_invalid_timeout": { - LangZH: "无效的超时时间: %v", - LangEN: "Invalid timeout: %v", - }, - "config_invalid_proxy": { - LangZH: "无效的代理配置: %s", - LangEN: "Invalid proxy configuration: %s", - }, - "config_missing_required": { - LangZH: "缺少必需的配置项: %s", - LangEN: "Missing required configuration: %s", - }, - "config_load_default": { - LangZH: "加载默认配置", - LangEN: "Loading default configuration", - }, - "config_override_detected": { - LangZH: "检测到配置覆盖: %s", - LangEN: "Configuration override detected: %s", - }, - - // ========================= 输出系统消息 ========================= - "output_init_start": { - LangZH: "初始化输出系统", - LangEN: "Initializing output system", - }, - "output_init_success": { - LangZH: "输出系统初始化成功", - LangEN: "Output system initialized successfully", - }, - "output_init_failed": { - LangZH: "输出系统初始化失败: %v", - LangEN: "Failed to initialize output system: %v", - }, - "output_format_invalid": { - LangZH: "无效的输出格式: %s", - LangEN: "Invalid output format: %s", - }, - "output_path_empty": { - LangZH: "输出路径为空", - LangEN: "Output path is empty", - }, - "output_not_init": { - LangZH: "输出系统未初始化", - LangEN: "Output system not initialized", - }, - "output_saving_result": { - LangZH: "保存扫描结果: %s -> %s", - LangEN: "Saving scan result: %s -> %s", - }, - "output_save_failed": { - LangZH: "保存结果失败: %v", - LangEN: "Failed to save result: %v", - }, - "output_closing": { - LangZH: "关闭输出系统", - LangEN: "Closing output system", - }, - "output_closed": { - LangZH: "输出系统已关闭", - LangEN: "Output system closed", - }, - "output_close_failed": { - LangZH: "关闭输出系统失败: %v", - LangEN: "Failed to close output system: %v", - }, - - // ========================= 代理系统消息 ========================= - "proxy_init_start": { - LangZH: "初始化代理系统", - LangEN: "Initializing proxy system", - }, - "proxy_init_success": { - LangZH: "代理系统初始化成功", - LangEN: "Proxy system initialized successfully", - }, - "proxy_init_failed": { - LangZH: "初始化代理配置失败: %v", - LangEN: "Failed to initialize proxy configuration: %v", - }, - "proxy_config_sync_failed": { - LangZH: "代理配置同步失败: %v", - LangEN: "Failed to sync proxy configuration: %v", - }, - "proxy_enabled": { - LangZH: "代理已启用: %s %s", - LangEN: "Proxy enabled: %s %s", - }, - "proxy_disabled": { - LangZH: "代理已禁用", - LangEN: "Proxy disabled", - }, - "proxy_connection_failed": { - LangZH: "代理连接失败: %v", - LangEN: "Proxy connection failed: %v", - }, - "socks5_create_failed": { - LangZH: "创建SOCKS5连接失败: %v", - LangEN: "Failed to create SOCKS5 connection: %v", - }, - "tls_conn_failed": { - LangZH: "TLS连接失败: %v", - LangEN: "TLS connection failed: %v", - }, - - // ========================= 系统状态消息 ========================= - "status_scan_start": { - LangZH: "开始扫描", - LangEN: "Starting scan", - }, - "status_scan_complete": { - LangZH: "扫描完成", - LangEN: "Scan completed", - }, - "status_scan_progress": { - LangZH: "扫描进度: %d/%d", - LangEN: "Scan progress: %d/%d", - }, - "status_target_found": { - LangZH: "发现目标: %s", - LangEN: "Target found: %s", - }, - "status_service_detected": { - LangZH: "检测到服务: %s", - LangEN: "Service detected: %s", - }, - "status_vuln_found": { - LangZH: "发现漏洞: %s", - LangEN: "Vulnerability found: %s", - }, - "status_connection_failed": { - LangZH: "连接失败: %s", - LangEN: "Connection failed: %s", - }, - "status_timeout": { - LangZH: "连接超时: %s", - LangEN: "Connection timeout: %s", - }, - - // ========================= 日志级别消息 ========================= - "log_level_all": { - LangZH: "所有日志", - LangEN: "All logs", - }, - "log_level_error": { - LangZH: "错误日志", - LangEN: "Error logs", - }, - "log_level_base": { - LangZH: "基础日志", - LangEN: "Base logs", - }, - "log_level_info": { - LangZH: "信息日志", - LangEN: "Info logs", - }, - "log_level_success": { - LangZH: "成功日志", - LangEN: "Success logs", - }, - "log_level_debug": { - LangZH: "调试日志", - LangEN: "Debug logs", - }, - - // ========================= 目标解析消息 ========================= - "target_parse_start": { - LangZH: "开始解析目标", - LangEN: "Starting target parsing", - }, - "target_parse_complete": { - LangZH: "目标解析完成", - LangEN: "Target parsing completed", - }, - "target_hosts_found": { - LangZH: "目标主机: %s", - LangEN: "Target hosts: %s", - }, - "target_hosts_count": { - LangZH: "目标主机: %s ... (共%d个)", - LangEN: "Target hosts: %s ... (total %d)", - }, - "target_urls_found": { - LangZH: "目标URL: %s", - LangEN: "Target URLs: %s", - }, - "target_urls_count": { - LangZH: "目标URL: %s ... (共%d个)", - LangEN: "Target URLs: %s ... (total %d)", - }, - "target_ports_found": { - LangZH: "扫描端口: %s", - LangEN: "Scan ports: %s", - }, - "target_ports_count": { - LangZH: "扫描端口: %s ... (共%d个)", - LangEN: "Scan ports: %s ... (total %d)", - }, - "target_exclude_ports": { - LangZH: "排除端口: %s", - LangEN: "Exclude ports: %s", - }, - "target_local_mode": { - LangZH: "本地扫描模式", - LangEN: "Local scan mode", - }, - - // ========================= 网络配置消息 ========================= - "network_http_proxy": { - LangZH: "HTTP代理: %s", - LangEN: "HTTP proxy: %s", - }, - "network_socks5_proxy": { - LangZH: "Socks5代理: %s", - LangEN: "Socks5 proxy: %s", - }, - "network_timeout": { - LangZH: "连接超时: %v", - LangEN: "Connection timeout: %v", - }, - "network_web_timeout": { - LangZH: "Web超时: %v", - LangEN: "Web timeout: %v", - }, - - // ========================= 凭据相关消息 ========================= - "credential_username_count": { - LangZH: "用户名数量: %d", - LangEN: "Username count: %d", - }, - "credential_password_count": { - LangZH: "密码数量: %d", - LangEN: "Password count: %d", - }, - "credential_hash_count": { - LangZH: "Hash数量: %d", - LangEN: "Hash count: %d", - }, - - // ========================= 文件操作消息 ========================= - "file_read_start": { - LangZH: "开始读取文件: %s", - LangEN: "Starting to read file: %s", - }, - "file_read_complete": { - LangZH: "文件读取完成: %s", - LangEN: "File reading completed: %s", - }, - "file_read_error": { - LangZH: "读取文件错误: %s", - LangEN: "File reading error: %s", - }, - "file_not_exist": { - LangZH: "文件不存在: %s", - LangEN: "File does not exist: %s", - }, - "file_empty": { - LangZH: "文件为空: %s", - LangEN: "File is empty: %s", - }, - - // ========================= 验证相关消息 ========================= - "validation_start": { - LangZH: "开始配置验证", - LangEN: "Starting configuration validation", - }, - "validation_complete": { - LangZH: "配置验证完成", - LangEN: "Configuration validation completed", - }, - "validation_warning": { - LangZH: "验证警告: %s", - LangEN: "Validation warning: %s", - }, - "validation_error": { - LangZH: "验证错误: %s", - LangEN: "Validation error: %s", - }, - - // ========================= 通用错误消息 ========================= - "error_occurred": { - LangZH: "错误: %v", - LangEN: "Error: %v", - }, - "error_unknown": { - LangZH: "未知错误", - LangEN: "Unknown error", - }, - "error_not_implemented": { - LangZH: "功能未实现", - LangEN: "Feature not implemented", - }, - "error_permission_denied": { - LangZH: "权限不足", - LangEN: "Permission denied", - }, - "error_resource_busy": { - LangZH: "资源忙碌", - LangEN: "Resource busy", - }, - - // ========================= 通用状态消息 ========================= - "status_initializing": { - LangZH: "正在初始化...", - LangEN: "Initializing...", - }, - "status_processing": { - LangZH: "正在处理...", - LangEN: "Processing...", - }, - "status_completed": { - LangZH: "已完成", - LangEN: "Completed", - }, - "status_failed": { - LangZH: "失败", - LangEN: "Failed", - }, - "status_cancelled": { - LangZH: "已取消", - LangEN: "Cancelled", - }, - "status_ready": { - LangZH: "就绪", - LangEN: "Ready", - }, - - // ========================= Parsers包专用消息 ========================= - "parser_validation_input_empty": { - LangZH: "验证输入为空", - LangEN: "Validation input is empty", - }, - "parser_error_count_limit": { - LangZH: "错误数量过多,仅显示前%d个", - LangEN: "Too many errors, showing only first %d", - }, - "parser_no_scan_target": { - LangZH: "未指定任何扫描目标", - LangEN: "No scan targets specified", - }, - "parser_no_target_default": { - LangZH: "未指定扫描目标,将使用默认配置", - LangEN: "No scan targets specified, using default configuration", - }, - "parser_multiple_scan_modes": { - LangZH: "不能同时使用多种扫描模式", - LangEN: "Cannot use multiple scan modes simultaneously", - }, - "parser_proxy_ping_warning": { - LangZH: "使用代理时建议禁用Ping检测", - LangEN: "Recommend disabling Ping detection when using proxy", - }, - "parser_multiple_modes_conflict": { - LangZH: "不能同时指定多种扫描模式(主机扫描、URL扫描、本地模式)", - LangEN: "Cannot specify multiple scan modes (host scan, URL scan, local mode) simultaneously", - }, - "parser_proxy_ping_fail": { - LangZH: "代理模式下Ping检测可能失效", - LangEN: "Ping detection may fail in proxy mode", - }, - "parser_exclude_ports_invalid": { - LangZH: "排除端口无效", - LangEN: "Exclude ports invalid", - }, - "parser_many_targets_warning": { - LangZH: "大量目标(%d),可能耗时较长", - LangEN: "Large number of targets (%d), may take a long time", - }, - "parser_too_many_ports": { - LangZH: "端口数量过多", - LangEN: "Too many ports", - }, - "parser_timeout_too_short": { - LangZH: "超时过短", - LangEN: "Timeout too short", - }, - "parser_timeout_too_long": { - LangZH: "超时过长", - LangEN: "Timeout too long", - }, - "parser_invalid_scan_mode": { - LangZH: "无效的扫描模式: %s", - LangEN: "Invalid scan mode: %s", - }, - "parser_read_hosts_file_failed": { - LangZH: "读取主机文件失败", - LangEN: "Failed to read hosts file", - }, - "parser_hosts_file_line_failed": { - LangZH: "主机文件第%d行解析失败: %s", - LangEN: "Failed to parse line %d in hosts file: %s", - }, - "parser_exclude_hosts_failed": { - LangZH: "排除主机解析失败: %s", - LangEN: "Failed to parse exclude hosts: %s", - }, - "parser_invalid_host": { - LangZH: "无效主机: %s - %s", - LangEN: "Invalid host: %s - %s", - }, - "parser_hosts_limit_exceeded": { - LangZH: "主机数量超过限制,截取前%d个", - LangEN: "Host count exceeds limit, taking first %d", - }, - "parser_invalid_url": { - LangZH: "无效URL: %s - %s", - LangEN: "Invalid URL: %s - %s", - }, - "parser_read_urls_file_failed": { - LangZH: "读取URL文件失败", - LangEN: "Failed to read URLs file", - }, - "parser_urls_file_line_invalid": { - LangZH: "URL文件第%d行无效: %s", - LangEN: "Invalid line %d in URLs file: %s", - }, - "parser_read_ports_file_failed": { - LangZH: "读取端口文件失败", - LangEN: "Failed to read ports file", - }, - "parser_ports_file_line_failed": { - LangZH: "端口文件第%d行解析失败: %s", - LangEN: "Failed to parse line %d in ports file: %s", - }, - "parser_additional_ports_failed": { - LangZH: "额外端口解析失败: %s", - LangEN: "Failed to parse additional ports: %s", - }, - "parser_invalid_hostport": { - LangZH: "无效主机端口组合: %s - %s", - LangEN: "Invalid host:port combination: %s - %s", - }, - "parser_192_segment_failed": { - LangZH: "192网段解析失败: %v", - LangEN: "Failed to parse 192 network segment: %v", - }, - "parser_172_segment_failed": { - LangZH: "172网段解析失败: %v", - LangEN: "Failed to parse 172 network segment: %v", - }, - "parser_10_segment_failed": { - LangZH: "10网段解析失败: %v", - LangEN: "Failed to parse 10 network segment: %v", - }, - "parser_cidr_parse_failed": { - LangZH: "CIDR解析失败 %s: %v", - LangEN: "Failed to parse CIDR %s: %v", - }, - "parser_ip_range_parse_failed": { - LangZH: "IP范围解析失败 %s: %v", - LangEN: "Failed to parse IP range %s: %v", - }, - "parser_port_range_parse_failed": { - LangZH: "端口范围解析失败 %s: %v", - LangEN: "Failed to parse port range %s: %v", - }, - "parser_port_range_too_large": { - LangZH: "端口范围过大: %d, 最大允许: %d", - LangEN: "Port range too large: %d, maximum allowed: %d", - }, - "parser_invalid_port_number": { - LangZH: "无效端口号: %s", - LangEN: "Invalid port number: %s", - }, - "parser_port_out_of_range": { - LangZH: "端口号超出范围: %d", - LangEN: "Port number out of range: %d", - }, - "parser_invalid_ip_range_format": { - LangZH: "无效的IP范围格式", - LangEN: "Invalid IP range format", - }, - "parser_invalid_start_ip": { - LangZH: "无效的起始IP地址: %s", - LangEN: "Invalid start IP address: %s", - }, - "parser_invalid_end_ip": { - LangZH: "无效的结束IP地址: %s", - LangEN: "Invalid end IP address: %s", - }, - "parser_invalid_ip_range_end": { - LangZH: "无效的IP范围结束值: %s", - LangEN: "Invalid IP range end value: %s", - }, - "parser_invalid_ip_format": { - LangZH: "无效的IP地址格式: %s", - LangEN: "Invalid IP address format: %s", - }, - "parser_invalid_ip_range": { - LangZH: "无效的IP范围: %s-%s", - LangEN: "Invalid IP range: %s-%s", - }, - "parser_ipv4_only": { - LangZH: "仅支持IPv4地址范围", - LangEN: "Only IPv4 address ranges are supported", - }, - "parser_start_ip_greater_than_end": { - LangZH: "起始IP大于结束IP", - LangEN: "Start IP is greater than end IP", - }, - "parser_ip_range_too_large": { - LangZH: "IP范围过大,超过最大限制: %d", - LangEN: "IP range too large, exceeds maximum limit: %d", - }, - "parser_invalid_port_range_format": { - LangZH: "无效的端口范围格式", - LangEN: "Invalid port range format", - }, - "parser_invalid_port_in_range": { - LangZH: "无效的端口号", - LangEN: "Invalid port number", - }, - "parser_port_range_out_of_bounds": { - LangZH: "端口号超出范围", - LangEN: "Port number out of range", - }, - "parser_host_address_empty": { - LangZH: "主机地址为空", - LangEN: "Host address is empty", - }, - - // ========================= Output包专用消息 ========================= - "output_create_txt_file_failed": { - LangZH: "创建文本文件失败: %v", - LangEN: "Failed to create text file: %v", - }, - "output_writer_closed": { - LangZH: "写入器已关闭", - LangEN: "Writer is closed", - }, - "output_create_json_file_failed": { - LangZH: "创建JSON文件失败: %v", - LangEN: "Failed to create JSON file: %v", - }, - "output_create_csv_file_failed": { - LangZH: "创建CSV文件失败: %v", - LangEN: "Failed to create CSV file: %v", - }, - "output_write_csv_header_failed": { - LangZH: "写入CSV头部失败: %v", - LangEN: "Failed to write CSV header: %v", - }, - "output_open_csv_file_failed": { - LangZH: "打开CSV文件失败: %v", - LangEN: "Failed to open CSV file: %v", - }, - "output_read_csv_file_failed": { - LangZH: "读取CSV文件失败: %v", - LangEN: "Failed to read CSV file: %v", - }, - - // ========================= Proxy包专用消息 ========================= - "proxy_tcp_connect_failed": { - LangZH: "建立TCP连接失败", - LangEN: "Failed to establish TCP connection", - }, - "proxy_tls_handshake_failed": { - LangZH: "TLS握手失败", - LangEN: "TLS handshake failed", - }, - "proxy_unsupported_type": { - LangZH: "不支持的代理类型", - LangEN: "Unsupported proxy type", - }, - "proxy_config_empty": { - LangZH: "配置不能为空", - LangEN: "Configuration cannot be empty", - }, - "proxy_socks5_address_parse_failed": { - LangZH: "SOCKS5代理地址解析失败", - LangEN: "Failed to parse SOCKS5 proxy address", - }, - "proxy_socks5_dialer_create_failed": { - LangZH: "SOCKS5拨号器创建失败", - LangEN: "Failed to create SOCKS5 dialer", - }, - "proxy_direct_connect_failed": { - LangZH: "直连失败", - LangEN: "Direct connection failed", - }, - "proxy_socks5_timeout": { - LangZH: "SOCKS5连接超时", - LangEN: "SOCKS5 connection timeout", - }, - "proxy_socks5_connect_failed": { - LangZH: "SOCKS5连接失败", - LangEN: "SOCKS5 connection failed", - }, - "proxy_http_connect_failed": { - LangZH: "连接HTTP代理服务器失败", - LangEN: "Failed to connect to HTTP proxy server", - }, - - // ========================= Config包专用消息 ========================= - "config_thread_count_too_high": { - LangZH: "线程数过大,可能影响系统性能", - LangEN: "Thread count too high, may affect system performance", - }, - "config_web_timeout_larger": { - LangZH: "Web超时时间大于普通超时时间,可能导致不期望的行为", - LangEN: "Web timeout is larger than normal timeout, may cause unexpected behavior", - }, - "config_timeout_too_short": { - LangZH: "超时时间过短,可能导致误报", - LangEN: "Timeout too short, may cause false positives", - }, - "config_web_timeout_too_short": { - LangZH: "Web超时时间过短,可能导致误报", - LangEN: "Web timeout too short, may cause false positives", - }, - "config_global_timeout_too_short": { - LangZH: "全局超时时间过短,扫描可能提前终止", - LangEN: "Global timeout too short, scan may terminate early", - }, - - // ========================= Flag参数帮助消息 ========================= - "flag_host": { - LangZH: "目标主机: IP, IP段, IP段文件, 域名", - LangEN: "Target host: IP, IP range, IP file, domain", - }, - "flag_exclude_hosts": { - LangZH: "排除主机", - LangEN: "Exclude hosts", - }, - "flag_ports": { - LangZH: "端口: 默认1000个常用端口", - LangEN: "Ports: default 1000 common ports", - }, - "flag_exclude_ports": { - LangZH: "排除端口", - LangEN: "Exclude ports", - }, - "flag_hosts_file": { - LangZH: "主机文件", - LangEN: "Hosts file", - }, - "flag_ports_file": { - LangZH: "端口文件", - LangEN: "Ports file", - }, - "flag_scan_mode": { - LangZH: "扫描模式: all, portscan, tcpscan, udpscan等", - LangEN: "Scan mode: all, portscan, tcpscan, udpscan, etc.", - }, - "flag_thread_num": { - LangZH: "端口扫描线程数", - LangEN: "Port scan thread count", - }, - "flag_timeout": { - LangZH: "端口扫描超时时间", - LangEN: "Port scan timeout", - }, - "flag_module_thread_num": { - LangZH: "模块扫描线程数", - LangEN: "Module scan thread count", - }, - "flag_global_timeout": { - LangZH: "全局超时时间", - LangEN: "Global timeout", - }, - "flag_live_top": { - LangZH: "存活探测top端口", - LangEN: "Top ports for live detection", - }, - "flag_disable_ping": { - LangZH: "禁用ping探测", - LangEN: "Disable ping detection", - }, - "flag_use_ping": { - LangZH: "启用ping探测", - LangEN: "Enable ping detection", - }, - "flag_enable_fingerprint": { - LangZH: "启用指纹识别", - LangEN: "Enable fingerprint recognition", - }, - "flag_local_mode": { - LangZH: "本地扫描模式", - LangEN: "Local scan mode", - }, - "flag_username": { - LangZH: "用户名", - LangEN: "Username", - }, - "flag_password": { - LangZH: "密码", - LangEN: "Password", - }, - "flag_add_users": { - LangZH: "添加用户名", - LangEN: "Add usernames", - }, - "flag_add_passwords": { - LangZH: "添加密码", - LangEN: "Add passwords", - }, - "flag_users_file": { - LangZH: "用户名字典文件", - LangEN: "Username dictionary file", - }, - "flag_passwords_file": { - LangZH: "密码字典文件", - LangEN: "Password dictionary file", - }, - "flag_hash_file": { - LangZH: "Hash文件", - LangEN: "Hash file", - }, - "flag_hash_value": { - LangZH: "Hash值", - LangEN: "Hash value", - }, - "flag_domain": { - LangZH: "域名(SMB扫描用)", - LangEN: "Domain (for SMB scan)", - }, - "flag_ssh_key": { - LangZH: "SSH私钥文件", - LangEN: "SSH private key file", - }, - "flag_target_url": { - LangZH: "目标URL", - LangEN: "Target URL", - }, - "flag_urls_file": { - LangZH: "URL文件", - LangEN: "URLs file", - }, - "flag_cookie": { - LangZH: "Cookie", - LangEN: "Cookie", - }, - "flag_web_timeout": { - LangZH: "Web扫描超时时间", - LangEN: "Web scan timeout", - }, - "flag_http_proxy": { - LangZH: "HTTP代理", - LangEN: "HTTP proxy", - }, - "flag_socks5_proxy": { - LangZH: "Socks5代理", - LangEN: "Socks5 proxy", - }, - "flag_poc_path": { - LangZH: "POC文件路径", - LangEN: "POC file path", - }, - "flag_poc_name": { - LangZH: "POC名称", - LangEN: "POC name", - }, - "flag_poc_full": { - LangZH: "全量POC扫描", - LangEN: "Full POC scan", - }, - "flag_dns_log": { - LangZH: "启用DNS日志", - LangEN: "Enable DNS log", - }, - "flag_poc_num": { - LangZH: "POC扫描并发数", - LangEN: "POC scan concurrency", - }, - "flag_no_poc": { - LangZH: "禁用POC扫描", - LangEN: "Disable POC scan", - }, - "flag_redis_file": { - LangZH: "Redis文件", - LangEN: "Redis file", - }, - "flag_redis_shell": { - LangZH: "Redis shell", - LangEN: "Redis shell", - }, - "flag_disable_redis": { - LangZH: "禁用Redis利用", - LangEN: "Disable Redis exploitation", - }, - "flag_redis_write_path": { - LangZH: "Redis写入路径", - LangEN: "Redis write path", - }, - "flag_redis_write_content": { - LangZH: "Redis写入内容", - LangEN: "Redis write content", - }, - "flag_redis_write_file": { - LangZH: "Redis写入文件", - LangEN: "Redis write file", - }, - "flag_disable_brute": { - LangZH: "禁用暴力破解", - LangEN: "Disable brute force", - }, - "flag_max_retries": { - LangZH: "最大重试次数", - LangEN: "Maximum retry count", - }, - "flag_output_file": { - LangZH: "输出文件", - LangEN: "Output file", - }, - "flag_output_format": { - LangZH: "输出格式(txt,json,csv)", - LangEN: "Output format (txt,json,csv)", - }, - "flag_disable_save": { - LangZH: "禁用结果保存", - LangEN: "Disable result saving", - }, - "flag_silent_mode": { - LangZH: "静默模式", - LangEN: "Silent mode", - }, - "flag_no_color": { - LangZH: "禁用颜色输出", - LangEN: "Disable color output", - }, - "flag_log_level": { - LangZH: "日志级别", - LangEN: "Log level", - }, - "flag_show_progress": { - LangZH: "显示进度条", - LangEN: "Show progress bar", - }, - "flag_show_scan_plan": { - LangZH: "显示扫描计划", - LangEN: "Show scan plan", - }, - "flag_slow_log_output": { - LangZH: "慢日志输出", - LangEN: "Slow log output", - }, - "flag_shellcode": { - LangZH: "Shellcode", - LangEN: "Shellcode", - }, - "flag_language": { - LangZH: "语言(zh/en)", - LangEN: "Language (zh/en)", - }, - - // ========================= 旧版兼容消息 ========================= - "scan_start": { - LangZH: "开始扫描", - LangEN: "Starting scan", - }, - "scan_complete": { - LangZH: "扫描完成", - LangEN: "Scan completed", - }, - "target_found": { - LangZH: "发现: %s", - LangEN: "Found: %s", - }, - "connection_failed": { - LangZH: "连接失败", - LangEN: "Connection failed", - }, -} - -// GetText 简化的文本获取函数 +// GetText 获取国际化文本 - 引用i18n包的实现 func GetText(key string, args ...interface{}) string { - lang := Language - if lang == "" { - lang = LangZH - } - - if textMap, exists := coreMessages[key]; exists { - if text, langExists := textMap[lang]; langExists { - if len(args) > 0 { - return fmt.Sprintf(text, args...) - } - return text - } - } - return key // 找不到时返回key + return i18n.GetText(key, args...) } -// SetLanguage 设置语言(保持兼容性) +// SetLanguage 设置语言 - 引用i18n包的实现 func SetLanguage(lang string) { - if lang == LangZH || lang == LangEN { - Language = lang - } + i18n.SetLanguage(lang) } + +// GetLanguage 获取当前语言 - 引用i18n包的实现 +func GetLanguage() string { + return i18n.GetLanguage() +} + +// AddMessage 添加消息 - 引用i18n包的实现 +func AddMessage(key string, translations map[string]string) { + i18n.AddMessage(key, translations) +} + +// AddMessages 批量添加消息 - 引用i18n包的实现 +func AddMessages(messages map[string]map[string]string) { + i18n.AddMessages(messages) +} + +// HasMessage 检查消息是否存在 - 引用i18n包的实现 +func HasMessage(key string) bool { + return i18n.HasMessage(key) +} + +// GetMessageCount 获取消息总数 - 引用i18n包的实现 +func GetMessageCount() int { + return i18n.GetMessageCount() +} + +// GetSupportedLanguages 获取支持的语言列表 - 引用i18n包的实现 +func GetSupportedLanguages() []string { + return i18n.GetSupportedLanguages() +} + +// ============================================================================= +// 废弃的变量和函数 (保持向后兼容) +// ============================================================================= + +// coreMessages 已废弃,消息定义已迁移到i18n包 +// 保留空映射以防止编译错误 +var coreMessages = map[string]map[string]string{} \ No newline at end of file diff --git a/Common/i18n/manager.go b/Common/i18n/manager.go new file mode 100644 index 0000000..40b8440 --- /dev/null +++ b/Common/i18n/manager.go @@ -0,0 +1,346 @@ +package i18n + +import ( + "fmt" + "sync" +) + +/* +manager.go - 国际化管理器 + +提供统一的国际化文本管理,支持多语言动态切换, +包含完整的消息库和高效的文本查询机制。 +*/ + +// ============================================================================= +// 常量定义 +// ============================================================================= + +// 支持的语言常量 +const ( + LangZH = "zh" // 中文 + LangEN = "en" // 英文 +) + +// 默认配置 +const ( + DefaultLanguage = LangZH // 默认语言 + FallbackLanguage = LangEN // 回退语言 +) + +// ============================================================================= +// 国际化管理器 +// ============================================================================= + +// Manager 国际化管理器 +type Manager struct { + mu sync.RWMutex + currentLanguage string + fallbackLanguage string + messages map[string]map[string]string + enabled bool +} + +// 全局管理器实例 +var globalManager = NewManager() + +// NewManager 创建新的国际化管理器 +func NewManager() *Manager { + return &Manager{ + currentLanguage: DefaultLanguage, + fallbackLanguage: FallbackLanguage, + messages: make(map[string]map[string]string), + enabled: true, + } +} + +// ============================================================================= +// 基础管理方法 +// ============================================================================= + +// SetLanguage 设置当前语言 +func (m *Manager) SetLanguage(lang string) { + m.mu.Lock() + defer m.mu.Unlock() + m.currentLanguage = lang +} + +// GetLanguage 获取当前语言 +func (m *Manager) GetLanguage() string { + m.mu.RLock() + defer m.mu.RUnlock() + return m.currentLanguage +} + +// SetFallbackLanguage 设置回退语言 +func (m *Manager) SetFallbackLanguage(lang string) { + m.mu.Lock() + defer m.mu.Unlock() + m.fallbackLanguage = lang +} + +// Enable 启用国际化 +func (m *Manager) Enable() { + m.mu.Lock() + defer m.mu.Unlock() + m.enabled = true +} + +// Disable 禁用国际化 +func (m *Manager) Disable() { + m.mu.Lock() + defer m.mu.Unlock() + m.enabled = false +} + +// IsEnabled 检查是否启用国际化 +func (m *Manager) IsEnabled() bool { + m.mu.RLock() + defer m.mu.RUnlock() + return m.enabled +} + +// ============================================================================= +// 消息管理方法 +// ============================================================================= + +// AddMessage 添加单个消息 +func (m *Manager) AddMessage(key string, translations map[string]string) { + m.mu.Lock() + defer m.mu.Unlock() + m.messages[key] = translations +} + +// AddMessages 批量添加消息 +func (m *Manager) AddMessages(messages map[string]map[string]string) { + m.mu.Lock() + defer m.mu.Unlock() + for key, translations := range messages { + m.messages[key] = translations + } +} + +// GetMessage 获取指定键和语言的消息 +func (m *Manager) GetMessage(key, lang string) (string, bool) { + m.mu.RLock() + defer m.mu.RUnlock() + + if translations, exists := m.messages[key]; exists { + if message, exists := translations[lang]; exists { + return message, true + } + } + return "", false +} + +// HasMessage 检查是否存在指定键的消息 +func (m *Manager) HasMessage(key string) bool { + m.mu.RLock() + defer m.mu.RUnlock() + _, exists := m.messages[key] + return exists +} + +// GetAllMessages 获取所有消息 +func (m *Manager) GetAllMessages() map[string]map[string]string { + m.mu.RLock() + defer m.mu.RUnlock() + + // 创建深拷贝 + result := make(map[string]map[string]string) + for key, translations := range m.messages { + result[key] = make(map[string]string) + for lang, message := range translations { + result[key][lang] = message + } + } + return result +} + +// GetMessageCount 获取消息总数 +func (m *Manager) GetMessageCount() int { + m.mu.RLock() + defer m.mu.RUnlock() + return len(m.messages) +} + +// GetSupportedLanguages 获取支持的语言列表 +func (m *Manager) GetSupportedLanguages() []string { + m.mu.RLock() + defer m.mu.RUnlock() + + languageSet := make(map[string]bool) + for _, translations := range m.messages { + for lang := range translations { + languageSet[lang] = true + } + } + + languages := make([]string, 0, len(languageSet)) + for lang := range languageSet { + languages = append(languages, lang) + } + return languages +} + +// ============================================================================= +// 文本获取方法 +// ============================================================================= + +// GetText 获取国际化文本(支持格式化) +func (m *Manager) GetText(key string, args ...interface{}) string { + if !m.IsEnabled() { + // 如果禁用国际化,返回原始键名 + if len(args) > 0 { + return fmt.Sprintf(key, args...) + } + return key + } + + m.mu.RLock() + currentLang := m.currentLanguage + fallbackLang := m.fallbackLanguage + m.mu.RUnlock() + + // 尝试获取当前语言的消息 + if message, exists := m.GetMessage(key, currentLang); exists { + if len(args) > 0 { + return fmt.Sprintf(message, args...) + } + return message + } + + // 回退到回退语言 + if currentLang != fallbackLang { + if message, exists := m.GetMessage(key, fallbackLang); exists { + if len(args) > 0 { + return fmt.Sprintf(message, args...) + } + return message + } + } + + // 如果都没找到,返回键名作为兜底 + if len(args) > 0 { + return fmt.Sprintf(key, args...) + } + return key +} + +// GetTextWithLanguage 获取指定语言的文本 +func (m *Manager) GetTextWithLanguage(key, lang string, args ...interface{}) string { + if !m.IsEnabled() { + if len(args) > 0 { + return fmt.Sprintf(key, args...) + } + return key + } + + if message, exists := m.GetMessage(key, lang); exists { + if len(args) > 0 { + return fmt.Sprintf(message, args...) + } + return message + } + + // 如果指定语言没找到,使用回退语言 + m.mu.RLock() + fallbackLang := m.fallbackLanguage + m.mu.RUnlock() + + if lang != fallbackLang { + if message, exists := m.GetMessage(key, fallbackLang); exists { + if len(args) > 0 { + return fmt.Sprintf(message, args...) + } + return message + } + } + + // 兜底返回键名 + if len(args) > 0 { + return fmt.Sprintf(key, args...) + } + return key +} + +// ============================================================================= +// 全局访问函数 +// ============================================================================= + +// GetGlobalManager 获取全局国际化管理器 +func GetGlobalManager() *Manager { + return globalManager +} + +// SetLanguage 设置全局语言 +func SetLanguage(lang string) { + globalManager.SetLanguage(lang) +} + +// GetLanguage 获取全局当前语言 +func GetLanguage() string { + return globalManager.GetLanguage() +} + +// AddMessage 添加消息到全局管理器 +func AddMessage(key string, translations map[string]string) { + globalManager.AddMessage(key, translations) +} + +// AddMessages 批量添加消息到全局管理器 +func AddMessages(messages map[string]map[string]string) { + globalManager.AddMessages(messages) +} + +// GetText 从全局管理器获取国际化文本 +func GetText(key string, args ...interface{}) string { + return globalManager.GetText(key, args...) +} + +// GetTextWithLanguage 从全局管理器获取指定语言文本 +func GetTextWithLanguage(key, lang string, args ...interface{}) string { + return globalManager.GetTextWithLanguage(key, lang, args...) +} + +// Enable 启用全局国际化 +func Enable() { + globalManager.Enable() +} + +// Disable 禁用全局国际化 +func Disable() { + globalManager.Disable() +} + +// IsEnabled 检查全局国际化是否启用 +func IsEnabled() bool { + return globalManager.IsEnabled() +} + +// HasMessage 检查全局管理器是否存在指定消息 +func HasMessage(key string) bool { + return globalManager.HasMessage(key) +} + +// GetMessageCount 获取全局消息总数 +func GetMessageCount() int { + return globalManager.GetMessageCount() +} + +// GetSupportedLanguages 获取全局支持的语言列表 +func GetSupportedLanguages() []string { + return globalManager.GetSupportedLanguages() +} + +// ============================================================================= +// 初始化函数 +// ============================================================================= + +// init 初始化全局国际化管理器 +func init() { + // 设置默认配置 + globalManager.SetLanguage(DefaultLanguage) + globalManager.SetFallbackLanguage(FallbackLanguage) + globalManager.Enable() +} \ No newline at end of file diff --git a/Common/i18n/messages.go b/Common/i18n/messages.go new file mode 100644 index 0000000..1a0566a --- /dev/null +++ b/Common/i18n/messages.go @@ -0,0 +1,553 @@ +package i18n + +/* +messages.go - 国际化消息定义 + +包含项目中所有的国际化消息,按功能模块分类组织, +支持中文和英文两种语言。 +*/ + +// ============================================================================= +// 核心消息库 +// ============================================================================= + +// coreMessages 核心消息映射 +var coreMessages = map[string]map[string]string{ + // ========================= 解析错误消息 ========================= + "parse_error_empty_input": { + LangZH: "输入参数为空", + LangEN: "Input parameters are empty", + }, + "parse_error_config_failed": { + LangZH: "解析配置失败: %v", + LangEN: "Failed to parse configuration: %v", + }, + "parse_error_parser_not_init": { + LangZH: "解析器未初始化", + LangEN: "Parser not initialized", + }, + "parse_error_credential_failed": { + LangZH: "凭据解析失败: %v", + LangEN: "Failed to parse credentials: %v", + }, + "parse_error_target_failed": { + LangZH: "目标解析失败: %v", + LangEN: "Failed to parse targets: %v", + }, + "parse_error_network_failed": { + LangZH: "网络解析失败: %v", + LangEN: "Failed to parse network configuration: %v", + }, + "parse_error_validation_failed": { + LangZH: "验证失败: %v", + LangEN: "Validation failed: %v", + }, + "parse_error_update_vars_failed": { + LangZH: "更新全局变量失败: %v", + LangEN: "Failed to update global variables: %v", + }, + "parse_error_target_empty": { + LangZH: "目标输入为空", + LangEN: "Target input is empty", + }, + "parse_error_credential_empty": { + LangZH: "凭据输入为空", + LangEN: "Credential input is empty", + }, + "parse_error_network_empty": { + LangZH: "网络配置为空", + LangEN: "Network configuration is empty", + }, + "parse_error_invalid_ip": { + LangZH: "无效的IP地址: %s", + LangEN: "Invalid IP address: %s", + }, + "parse_error_invalid_port": { + LangZH: "无效的端口: %s", + LangEN: "Invalid port: %s", + }, + "parse_error_invalid_url": { + LangZH: "无效的URL: %s", + LangEN: "Invalid URL: %s", + }, + "parse_error_file_not_found": { + LangZH: "文件未找到: %s", + LangEN: "File not found: %s", + }, + "parse_error_file_read_failed": { + LangZH: "读取文件失败: %s", + LangEN: "Failed to read file: %s", + }, + + // ========================= 配置相关消息 ========================= + "config_sync_start": { + LangZH: "开始同步配置", + LangEN: "Starting configuration sync", + }, + "config_sync_complete": { + LangZH: "配置同步完成", + LangEN: "Configuration sync completed", + }, + "config_validation_start": { + LangZH: "开始配置验证", + LangEN: "Starting configuration validation", + }, + "config_validation_complete": { + LangZH: "配置验证完成", + LangEN: "Configuration validation completed", + }, + "config_invalid_scan_mode": { + LangZH: "无效的扫描模式: %s", + LangEN: "Invalid scan mode: %s", + }, + "config_invalid_thread_num": { + LangZH: "无效的线程数: %d", + LangEN: "Invalid thread number: %d", + }, + "config_invalid_timeout": { + LangZH: "无效的超时时间: %v", + LangEN: "Invalid timeout: %v", + }, + "config_invalid_proxy": { + LangZH: "无效的代理配置: %s", + LangEN: "Invalid proxy configuration: %s", + }, + "config_missing_required": { + LangZH: "缺少必需的配置项: %s", + LangEN: "Missing required configuration: %s", + }, + "config_load_default": { + LangZH: "加载默认配置", + LangEN: "Loading default configuration", + }, + "config_override_detected": { + LangZH: "检测到配置覆盖: %s", + LangEN: "Configuration override detected: %s", + }, + + // ========================= 输出系统消息 ========================= + "output_init_start": { + LangZH: "初始化输出系统", + LangEN: "Initializing output system", + }, + "output_init_success": { + LangZH: "输出系统初始化成功", + LangEN: "Output system initialized successfully", + }, + "output_init_failed": { + LangZH: "输出系统初始化失败: %v", + LangEN: "Failed to initialize output system: %v", + }, + "output_format_invalid": { + LangZH: "无效的输出格式: %s", + LangEN: "Invalid output format: %s", + }, + "output_path_empty": { + LangZH: "输出路径为空", + LangEN: "Output path is empty", + }, + "output_not_init": { + LangZH: "输出系统未初始化", + LangEN: "Output system not initialized", + }, + "output_saving_result": { + LangZH: "保存扫描结果: %s -> %s", + LangEN: "Saving scan result: %s -> %s", + }, + "output_save_failed": { + LangZH: "保存结果失败: %v", + LangEN: "Failed to save result: %v", + }, + "output_closing": { + LangZH: "关闭输出系统", + LangEN: "Closing output system", + }, + "output_closed": { + LangZH: "输出系统已关闭", + LangEN: "Output system closed", + }, + "output_close_failed": { + LangZH: "关闭输出系统失败: %v", + LangEN: "Failed to close output system: %v", + }, + + // ========================= 代理系统消息 ========================= + "proxy_init_start": { + LangZH: "初始化代理系统", + LangEN: "Initializing proxy system", + }, + "proxy_init_success": { + LangZH: "代理系统初始化成功", + LangEN: "Proxy system initialized successfully", + }, + "proxy_init_failed": { + LangZH: "初始化代理配置失败: %v", + LangEN: "Failed to initialize proxy configuration: %v", + }, + "proxy_config_sync_failed": { + LangZH: "代理配置同步失败: %v", + LangEN: "Failed to sync proxy configuration: %v", + }, + "proxy_enabled": { + LangZH: "代理已启用: %s %s", + LangEN: "Proxy enabled: %s %s", + }, + "proxy_disabled": { + LangZH: "代理已禁用", + LangEN: "Proxy disabled", + }, + "proxy_connection_failed": { + LangZH: "代理连接失败: %v", + LangEN: "Proxy connection failed: %v", + }, + "socks5_create_failed": { + LangZH: "创建SOCKS5连接失败: %v", + LangEN: "Failed to create SOCKS5 connection: %v", + }, + "tls_conn_failed": { + LangZH: "TLS连接失败: %v", + LangEN: "TLS connection failed: %v", + }, + + // ========================= 系统状态消息 ========================= + "status_scan_start": { + LangZH: "开始扫描", + LangEN: "Starting scan", + }, + "status_scan_complete": { + LangZH: "扫描完成", + LangEN: "Scan completed", + }, + "status_scan_progress": { + LangZH: "扫描进度: %d/%d", + LangEN: "Scan progress: %d/%d", + }, + "status_target_found": { + LangZH: "发现目标: %s", + LangEN: "Target found: %s", + }, + "status_service_detected": { + LangZH: "检测到服务: %s", + LangEN: "Service detected: %s", + }, + "status_vuln_found": { + LangZH: "发现漏洞: %s", + LangEN: "Vulnerability found: %s", + }, + "status_connection_failed": { + LangZH: "连接失败: %s", + LangEN: "Connection failed: %s", + }, + "status_timeout": { + LangZH: "连接超时: %s", + LangEN: "Connection timeout: %s", + }, + + // ========================= 目标解析消息 ========================= + "target_parse_start": { + LangZH: "开始解析目标", + LangEN: "Starting target parsing", + }, + "target_parse_complete": { + LangZH: "目标解析完成", + LangEN: "Target parsing completed", + }, + "target_hosts_found": { + LangZH: "目标主机: %s", + LangEN: "Target hosts: %s", + }, + "target_hosts_count": { + LangZH: "目标主机: %s ... (共%d个)", + LangEN: "Target hosts: %s ... (total %d)", + }, + "target_urls_found": { + LangZH: "目标URL: %s", + LangEN: "Target URLs: %s", + }, + "target_urls_count": { + LangZH: "目标URL: %s ... (共%d个)", + LangEN: "Target URLs: %s ... (total %d)", + }, + "target_ports_found": { + LangZH: "扫描端口: %s", + LangEN: "Scan ports: %s", + }, + "target_ports_count": { + LangZH: "扫描端口: %s ... (共%d个)", + LangEN: "Scan ports: %s ... (total %d)", + }, + "target_exclude_ports": { + LangZH: "排除端口: %s", + LangEN: "Exclude ports: %s", + }, + "target_local_mode": { + LangZH: "本地扫描模式", + LangEN: "Local scan mode", + }, + + // ========================= 网络配置消息 ========================= + "network_http_proxy": { + LangZH: "HTTP代理: %s", + LangEN: "HTTP proxy: %s", + }, + "network_socks5_proxy": { + LangZH: "Socks5代理: %s", + LangEN: "Socks5 proxy: %s", + }, + "network_timeout": { + LangZH: "连接超时: %v", + LangEN: "Connection timeout: %v", + }, + "network_web_timeout": { + LangZH: "Web超时: %v", + LangEN: "Web timeout: %v", + }, + + // ========================= 凭据相关消息 ========================= + "credential_username_count": { + LangZH: "用户名数量: %d", + LangEN: "Username count: %d", + }, + "credential_password_count": { + LangZH: "密码数量: %d", + LangEN: "Password count: %d", + }, + "credential_hash_count": { + LangZH: "Hash数量: %d", + LangEN: "Hash count: %d", + }, + + // ========================= 文件操作消息 ========================= + "file_read_start": { + LangZH: "开始读取文件: %s", + LangEN: "Starting to read file: %s", + }, + "file_read_complete": { + LangZH: "文件读取完成: %s", + LangEN: "File reading completed: %s", + }, + "file_read_error": { + LangZH: "读取文件错误: %s", + LangEN: "File reading error: %s", + }, + "file_not_exist": { + LangZH: "文件不存在: %s", + LangEN: "File does not exist: %s", + }, + "file_empty": { + LangZH: "文件为空: %s", + LangEN: "File is empty: %s", + }, + + // ========================= 验证相关消息 ========================= + "validation_start": { + LangZH: "开始配置验证", + LangEN: "Starting configuration validation", + }, + "validation_complete": { + LangZH: "配置验证完成", + LangEN: "Configuration validation completed", + }, + "validation_warning": { + LangZH: "验证警告: %s", + LangEN: "Validation warning: %s", + }, + "validation_error": { + LangZH: "验证错误: %s", + LangEN: "Validation error: %s", + }, + + // ========================= 通用错误消息 ========================= + "error_occurred": { + LangZH: "错误: %v", + LangEN: "Error: %v", + }, + "error_unknown": { + LangZH: "未知错误", + LangEN: "Unknown error", + }, + "error_not_implemented": { + LangZH: "功能未实现", + LangEN: "Feature not implemented", + }, + "error_permission_denied": { + LangZH: "权限不足", + LangEN: "Permission denied", + }, + "error_resource_busy": { + LangZH: "资源忙碌", + LangEN: "Resource busy", + }, + + // ========================= 通用状态消息 ========================= + "status_initializing": { + LangZH: "正在初始化...", + LangEN: "Initializing...", + }, + "status_processing": { + LangZH: "正在处理...", + LangEN: "Processing...", + }, + "status_completed": { + LangZH: "已完成", + LangEN: "Completed", + }, + "status_failed": { + LangZH: "失败", + LangEN: "Failed", + }, + "status_cancelled": { + LangZH: "已取消", + LangEN: "Cancelled", + }, + "status_ready": { + LangZH: "就绪", + LangEN: "Ready", + }, + + // ========================= Parsers包专用消息 ========================= + "parser_validation_input_empty": { + LangZH: "验证输入为空", + LangEN: "Validation input is empty", + }, + "parser_error_count_limit": { + LangZH: "错误数量过多,仅显示前%d个", + LangEN: "Too many errors, showing only first %d", + }, + "parser_no_scan_target": { + LangZH: "未指定任何扫描目标", + LangEN: "No scan targets specified", + }, + "parser_no_target_default": { + LangZH: "未指定扫描目标,将使用默认配置", + LangEN: "No scan targets specified, using default configuration", + }, + "parser_multiple_scan_modes": { + LangZH: "不能同时使用多种扫描模式", + LangEN: "Cannot use multiple scan modes simultaneously", + }, + "parser_proxy_ping_warning": { + LangZH: "使用代理时建议禁用Ping检测", + LangEN: "Recommend disabling Ping detection when using proxy", + }, + "parser_multiple_modes_conflict": { + LangZH: "不能同时指定多种扫描模式(主机扫描、URL扫描、本地模式)", + LangEN: "Cannot specify multiple scan modes (host scan, URL scan, local mode) simultaneously", + }, + "parser_proxy_ping_fail": { + LangZH: "代理模式下Ping检测可能失效", + LangEN: "Ping detection may fail in proxy mode", + }, + "parser_exclude_ports_invalid": { + LangZH: "排除端口无效", + LangEN: "Exclude ports invalid", + }, + "parser_many_targets_warning": { + LangZH: "大量目标(%d),可能耗时较长", + LangEN: "Large number of targets (%d), may take a long time", + }, + "parser_too_many_ports": { + LangZH: "端口数量过多", + LangEN: "Too many ports", + }, + "parser_timeout_too_short": { + LangZH: "超时过短", + LangEN: "Timeout too short", + }, + "parser_timeout_too_long": { + LangZH: "超时过长", + LangEN: "Timeout too long", + }, + "parser_invalid_scan_mode": { + LangZH: "无效的扫描模式: %s", + LangEN: "Invalid scan mode: %s", + }, + + // ========================= Flag参数帮助消息 ========================= + "flag_host": { + LangZH: "目标主机: IP, IP段, IP段文件, 域名", + LangEN: "Target host: IP, IP range, IP file, domain", + }, + "flag_exclude_hosts": { + LangZH: "排除主机", + LangEN: "Exclude hosts", + }, + "flag_ports": { + LangZH: "端口: 默认1000个常用端口", + LangEN: "Ports: default 1000 common ports", + }, + "flag_exclude_ports": { + LangZH: "排除端口", + LangEN: "Exclude ports", + }, + "flag_scan_mode": { + LangZH: "扫描模式: all, portscan, tcpscan, udpscan等", + LangEN: "Scan mode: all, portscan, tcpscan, udpscan, etc.", + }, + "flag_thread_num": { + LangZH: "端口扫描线程数", + LangEN: "Port scan thread count", + }, + "flag_timeout": { + LangZH: "端口扫描超时时间", + LangEN: "Port scan timeout", + }, + "flag_username": { + LangZH: "用户名", + LangEN: "Username", + }, + "flag_password": { + LangZH: "密码", + LangEN: "Password", + }, + "flag_target_url": { + LangZH: "目标URL", + LangEN: "Target URL", + }, + "flag_proxy": { + LangZH: "HTTP代理", + LangEN: "HTTP proxy", + }, + "flag_socks5": { + LangZH: "SOCKS5代理", + LangEN: "SOCKS5 proxy", + }, + "flag_outputfile": { + LangZH: "输出文件", + LangEN: "Output file", + }, + "flag_output_format": { + LangZH: "输出格式: txt, json, csv", + LangEN: "Output format: txt, json, csv", + }, + "flag_no_color": { + LangZH: "禁用颜色输出", + LangEN: "Disable color output", + }, + "flag_silent": { + LangZH: "静默模式", + LangEN: "Silent mode", + }, + "flag_language": { + LangZH: "语言: zh, en", + LangEN: "Language: zh, en", + }, + "flag_help": { + LangZH: "显示帮助信息", + LangEN: "Show help information", + }, + "flag_version": { + LangZH: "显示版本信息", + LangEN: "Show version information", + }, +} + +// ============================================================================= +// 初始化函数 +// ============================================================================= + +// init 初始化核心消息到全局管理器 +func init() { + // 将所有核心消息添加到全局管理器 + AddMessages(coreMessages) +} \ No newline at end of file