mirror of
https://github.com/unraid/api.git
synced 2026-01-11 11:10:04 -06:00
feat: add regState
This commit is contained in:
@@ -27,7 +27,7 @@ export const getLicense = async function (context: CoreContext): Promise<CoreRes
|
||||
|
||||
// Get license data
|
||||
const type = varState.data.regTy;
|
||||
const state = (varState.data.regCheck.trim() === '' ? type : varState.data.regCheck).toUpperCase();
|
||||
const state = varState.data.regState;
|
||||
const file = await fs.promises.readFile(varState.data.regFile, 'binary');
|
||||
const parsedFile = btoa(file).trim().replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
|
||||
|
||||
|
||||
@@ -39,20 +39,20 @@ const iniBooleanOrAutoToJsBoolean = (value: IniStringBooleanOrAuto | string) =>
|
||||
};
|
||||
|
||||
/**
|
||||
* Unraid registration check
|
||||
* Unraid registation check
|
||||
*/
|
||||
type RegistrationCheck =
|
||||
type RegistationCheck =
|
||||
/** Key file is missing. */
|
||||
'ENOKEYFILE2' |
|
||||
/** Everything is fine. */
|
||||
'';
|
||||
|
||||
/**
|
||||
* Unraid registration type
|
||||
* Unraid registation type
|
||||
*
|
||||
* Check the {@link https://unraid.net/pricing | pricing page} for up to date info.
|
||||
*/
|
||||
type RegistrationType =
|
||||
type RegistationType =
|
||||
/** Missing key file. */
|
||||
'- missing key file' |
|
||||
/** Up to 6 attached storage devices. */
|
||||
@@ -62,6 +62,31 @@ type RegistrationType =
|
||||
/** Unlimited attached storage devices. */
|
||||
'Pro';
|
||||
|
||||
type RegistrationState =
|
||||
'TRIAL' |
|
||||
'BASIC' |
|
||||
'PLUS' |
|
||||
'PRO' |
|
||||
'EEXPIRED' |
|
||||
'EGUID' |
|
||||
'EGUID1' |
|
||||
'ETRIAL' |
|
||||
'ENOKEYFILE2' |
|
||||
'ENOKEYFILE1' |
|
||||
'ENOFLASH1' |
|
||||
'ENOFLASH2' |
|
||||
'ENOFLASH3' |
|
||||
'ENOFLASH4' |
|
||||
'ENOFLASH5' |
|
||||
'ENOFLASH6' |
|
||||
'ENOFLASH7' |
|
||||
'EBLACKLISTED' |
|
||||
'EBLACKLISTED1' |
|
||||
'EBLACKLISTED2' |
|
||||
'ENOCONN' |
|
||||
/** Everything is fine. */
|
||||
'';
|
||||
|
||||
interface VarIni {
|
||||
bindMgt: IniStringBooleanOrAuto;
|
||||
cacheNumDevices: string;
|
||||
@@ -139,14 +164,15 @@ interface VarIni {
|
||||
portssl: string;
|
||||
porttelnet: string;
|
||||
queueDepth: string;
|
||||
regCheck: RegistrationCheck;
|
||||
regCheck: RegistationCheck;
|
||||
regFile: string;
|
||||
regGen: string;
|
||||
regGuid: string;
|
||||
regTm: string;
|
||||
regTm2: string;
|
||||
regTo: string;
|
||||
regTy: RegistrationType;
|
||||
regTy: RegistationType;
|
||||
regState: RegistrationState;
|
||||
safeMode: string;
|
||||
sbClean: string;
|
||||
sbEvents: string;
|
||||
@@ -204,7 +230,7 @@ const parse = (state: VarIni): Var => {
|
||||
bindMgt: iniBooleanOrAutoToJsBoolean(state.bindMgt),
|
||||
cacheNumDevices: toNumber(state.cacheNumDevices),
|
||||
cacheSbNumDisks: toNumber(state.cacheSbNumDisks),
|
||||
configValid: ['error', 'invalid'].includes(state.configValid) ? false : iniBooleanToJsBoolean(state.configValid),
|
||||
configValid: state.configValid === 'error' ? false : iniBooleanToJsBoolean(state.configValid),
|
||||
deviceCount: toNumber(state.deviceCount),
|
||||
fsCopyPrcnt: toNumber(state.fsCopyPrcnt),
|
||||
fsNumMounted: toNumber(state.fsNumMounted),
|
||||
@@ -237,6 +263,7 @@ const parse = (state: VarIni): Var => {
|
||||
porttelnet: toNumber(state.porttelnet),
|
||||
regCheck: state.regCheck === '' ? 'Valid' : 'Error',
|
||||
regTy: ['Basic', 'Plus', 'Pro'].includes(state.regTy) ? state.regTy : 'Invalid',
|
||||
regState: state.regCheck,
|
||||
safeMode: iniBooleanToJsBoolean(state.safeMode),
|
||||
sbClean: iniBooleanToJsBoolean(state.sbClean),
|
||||
sbEvents: toNumber(state.sbEvents),
|
||||
|
||||
@@ -114,6 +114,7 @@ export interface Var {
|
||||
porttelnet: number;
|
||||
queueDepth: string;
|
||||
regCheck: string;
|
||||
regState: string;
|
||||
/** Where the registeration key is stored. (e.g. "/boot/config/Pro.key") */
|
||||
regFile: string;
|
||||
regGen: string;
|
||||
|
||||
@@ -54,6 +54,7 @@ export const keyFile = () => {
|
||||
registration: {
|
||||
guid: varState.data.regGuid,
|
||||
type: varState.data.regTy,
|
||||
state: varState.data.regState,
|
||||
keyFile: {
|
||||
location: fullPath,
|
||||
contents: parsedFile
|
||||
|
||||
@@ -23,6 +23,7 @@ export default async (_: unknown, __: unknown, context: Context) => {
|
||||
return {
|
||||
guid: varState.data.regGuid,
|
||||
type: varState.data.regTy,
|
||||
state: varState.data.regState,
|
||||
keyFile: {
|
||||
location: varState.data.regFile,
|
||||
contents: parsedFile
|
||||
|
||||
@@ -113,6 +113,7 @@ type Vars {
|
||||
regGuid: String
|
||||
"""Registration type"""
|
||||
regTy: registrationType
|
||||
regState: registrationState
|
||||
"""Registration owner"""
|
||||
regTo: String
|
||||
regTm: String
|
||||
@@ -178,4 +179,28 @@ enum registrationType {
|
||||
Plus
|
||||
Pro
|
||||
Invalid
|
||||
}
|
||||
|
||||
enum registrationState {
|
||||
TRIAL
|
||||
BASIC
|
||||
PLUS
|
||||
PRO
|
||||
EEXPIRED
|
||||
EGUID
|
||||
EGUID1
|
||||
ETRIAL
|
||||
ENOKEYFILE2
|
||||
ENOKEYFILE1
|
||||
ENOFLASH1
|
||||
ENOFLASH2
|
||||
ENOFLASH3
|
||||
ENOFLASH4
|
||||
ENOFLASH5
|
||||
ENOFLASH6
|
||||
ENOFLASH7
|
||||
EBLACKLISTED
|
||||
EBLACKLISTED1
|
||||
EBLACKLISTED2
|
||||
ENOCONN
|
||||
}
|
||||
Reference in New Issue
Block a user