()
| 211 | static async get(key: string, defaultValue?: string): Promise<string> { |
| 212 | await this.init(); |
| 213 | if (!this.db) return defaultValue || DEFAULT_CONFIG[key] || ""; |
| 214 | const value = this.db.data[key]; |
| 215 | return value ?? defaultValue ?? DEFAULT_CONFIG[key] ?? ""; |
| 216 | } |
| 217 | |
| 218 | static async set(key: string, value: string): Promise<boolean> { |
| 219 | await this.init(); |
| 220 | if (!this.db) return false; |
| 221 | try { |
| 222 | this.db.data[key] = value; |
| 223 | await this.db.write(); |
| 224 | return true; |
| 225 | } catch (error) { |
| 226 | console.error(`[ssh] 设置配置失败 ${key}:`, error); |
| 227 | return false; |
| 228 | } |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | // 帮助文本 |
| 233 | // SSH服务重启通用函数 |
| 234 | const restartSSHService = async (): Promise<{ success: boolean; command?: string }> => { |
no outgoing calls
no test coverage detected