mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-17 01:14:40 +08:00
fix: respect transport_encryption setting in API config functions
When TRANSPORT_ENCRYPTION=false, updateModelConfigs and updateExchangeConfigsEncrypted now send plain JSON instead of attempting encryption which would fail with an empty public key.
This commit is contained in:
@@ -169,6 +169,16 @@ export const api = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async updateModelConfigs(request: UpdateModelConfigRequest): Promise<void> {
|
async updateModelConfigs(request: UpdateModelConfigRequest): Promise<void> {
|
||||||
|
// 检查是否启用了传输加密
|
||||||
|
const config = await CryptoService.fetchCryptoConfig()
|
||||||
|
|
||||||
|
if (!config.transport_encryption) {
|
||||||
|
// 传输加密禁用时,直接发送明文
|
||||||
|
const result = await httpClient.put(`${API_BASE}/models`, request)
|
||||||
|
if (!result.success) throw new Error('更新模型配置失败')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// 获取RSA公钥
|
// 获取RSA公钥
|
||||||
const publicKey = await CryptoService.fetchPublicKey()
|
const publicKey = await CryptoService.fetchPublicKey()
|
||||||
|
|
||||||
@@ -214,10 +224,20 @@ export const api = {
|
|||||||
if (!result.success) throw new Error('更新交易所配置失败')
|
if (!result.success) throw new Error('更新交易所配置失败')
|
||||||
},
|
},
|
||||||
|
|
||||||
// 使用加密传输更新交易所配置
|
// 使用加密传输更新交易所配置(自动检测是否启用加密)
|
||||||
async updateExchangeConfigsEncrypted(
|
async updateExchangeConfigsEncrypted(
|
||||||
request: UpdateExchangeConfigRequest
|
request: UpdateExchangeConfigRequest
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
// 检查是否启用了传输加密
|
||||||
|
const config = await CryptoService.fetchCryptoConfig()
|
||||||
|
|
||||||
|
if (!config.transport_encryption) {
|
||||||
|
// 传输加密禁用时,直接发送明文
|
||||||
|
const result = await httpClient.put(`${API_BASE}/exchanges`, request)
|
||||||
|
if (!result.success) throw new Error('更新交易所配置失败')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// 获取RSA公钥
|
// 获取RSA公钥
|
||||||
const publicKey = await CryptoService.fetchPublicKey()
|
const publicKey = await CryptoService.fetchPublicKey()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user