mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-15 08:34:43 +01:00
toggle encryption in options
This commit is contained in:
36
src/utils/server.ts
Normal file
36
src/utils/server.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { fs } from '@tauri-apps/api'
|
||||
|
||||
export async function toggleEncryption(path: string) {
|
||||
let serverConf
|
||||
|
||||
try {
|
||||
serverConf = JSON.parse(await fs.readTextFile(path))
|
||||
} catch(e) {
|
||||
console.log(`Server config at ${path} not found or invalid`)
|
||||
return
|
||||
}
|
||||
|
||||
const enabled = serverConf.server.http.encryption.useEncryption
|
||||
|
||||
serverConf.server.http.encryption.useEncryption = !enabled
|
||||
serverConf.server.http.encryption.useInRouting = !enabled
|
||||
|
||||
// Write file
|
||||
await fs.writeFile({
|
||||
path,
|
||||
contents: JSON.stringify(serverConf)
|
||||
})
|
||||
}
|
||||
|
||||
export async function encryptionEnabled(path: string) {
|
||||
let serverConf
|
||||
|
||||
try {
|
||||
serverConf = JSON.parse(await fs.readTextFile(path))
|
||||
} catch(e) {
|
||||
console.log(`Server config at ${path} not found or invalid`)
|
||||
return false
|
||||
}
|
||||
|
||||
return serverConf.server.http.encryption.useEncryption
|
||||
}
|
||||
Reference in New Issue
Block a user