(cfg: any, persistence = true)
| 143 | |
| 144 | // Pass in instance configuration, loosely and dynamically set configuration items for instance parameters |
| 145 | parameters(cfg: any, persistence = true) { |
| 146 | // If the instance type changes, default commands and lifecycle events must be reset |
| 147 | if (cfg?.type && cfg?.type != this.config.type) { |
| 148 | if (!this.isStoppedOrBusy()) |
| 149 | throw new Error($t("TXT_CODE_instanceConf.cantModifyInstanceType")); |
| 150 | configureEntityParams(this.config, cfg, "type", String); |
| 151 | this.forceExec(new FunctionDispatcher()); |
| 152 | } |
| 153 | |
| 154 | if (cfg?.enableRcon != null && cfg?.enableRcon !== this.config.enableRcon) { |
| 155 | if (!this.isStoppedOrBusy()) throw new Error($t("TXT_CODE_bdfa3457")); |
| 156 | configureEntityParams(this.config, cfg, "enableRcon", Boolean); |
| 157 | this.forceExec(new FunctionDispatcher()); |
| 158 | } |
| 159 | |
| 160 | if (cfg?.processType && cfg?.processType !== this.config.processType) { |
| 161 | if (!this.isStoppedOrBusy()) |
| 162 | throw new Error($t("TXT_CODE_instanceConf.cantModifyProcessType")); |
| 163 | configureEntityParams(this.config, cfg, "processType", String); |
| 164 | this.forceExec(new FunctionDispatcher()); |
| 165 | } |
| 166 | |
| 167 | // If the terminal type is changed, the default command must be reset |
| 168 | if ( |
| 169 | cfg?.terminalOption?.pty != null && |
| 170 | cfg?.terminalOption?.pty !== this.config.terminalOption.pty |
| 171 | ) { |
| 172 | if (!this.isStoppedOrBusy()) throw new Error($t("TXT_CODE_instanceConf.cantModifyPtyModel")); |
| 173 | configureEntityParams(this.config.terminalOption, cfg.terminalOption, "pty", Boolean); |
| 174 | this.forceExec(new FunctionDispatcher()); |
| 175 | } |
| 176 | |
| 177 | // Only allow some configuration items to be modified when the server is stopped |
| 178 | if (this.isStoppedOrBusy() && cfg.terminalOption) { |
| 179 | configureEntityParams(this.config.terminalOption, cfg.terminalOption, "ptyWindowCol", Number); |
| 180 | configureEntityParams(this.config.terminalOption, cfg.terminalOption, "ptyWindowRow", Number); |
| 181 | } |
| 182 | |
| 183 | if (cfg.tag instanceof Array) { |
| 184 | cfg.tag = cfg.tag.map((tag: any) => String(tag).trim()); |
| 185 | this.config.tag = cfg.tag; |
| 186 | } |
| 187 | |
| 188 | if (cfg?.extraServiceConfig) { |
| 189 | configureEntityParams( |
| 190 | this.config.extraServiceConfig, |
| 191 | cfg.extraServiceConfig, |
| 192 | "isOpenFrp", |
| 193 | Boolean |
| 194 | ); |
| 195 | configureEntityParams( |
| 196 | this.config.extraServiceConfig, |
| 197 | cfg.extraServiceConfig, |
| 198 | "openFrpToken", |
| 199 | String |
| 200 | ); |
| 201 | configureEntityParams( |
| 202 | this.config.extraServiceConfig, |
no test coverage detected