You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
1.2 KiB
33 lines
1.2 KiB
const crypto = require('crypto');
|
|
const colors = require('colors');
|
|
|
|
// 必须与 src/licenseManager.js 中的 SECRET_SALT 完全一致
|
|
const SECRET_SALT = 'Medical_SFU_Secure_Salt_2024';
|
|
|
|
const args = process.argv.slice(2);
|
|
if (args.length < 1) {
|
|
console.log('\n使用方法: node genLicense.js <服务器机器码>\n'.yellow);
|
|
process.exit(0);
|
|
}
|
|
|
|
const machineId = args[0];
|
|
// 设置有效期为 1 年 (365天)
|
|
const expiry = Date.now() + (365 * 24 * 60 * 60 * 1000);
|
|
|
|
// 生成签名: machineId + expiry + SALT
|
|
const signature = crypto
|
|
.createHmac('sha256', SECRET_SALT)
|
|
.update(`${machineId}.${expiry}`)
|
|
.digest('hex');
|
|
|
|
const licenseCode = `${machineId}.${expiry}.${signature}`;
|
|
|
|
console.log('========================================'.blue);
|
|
console.log(' 远程超声 SFU 授权码生成成功 '.bold.white);
|
|
console.log('========================================'.blue);
|
|
console.log('[机器码]: '.cyan + machineId);
|
|
console.log('[到期日]: '.cyan + new Date(expiry).toLocaleString());
|
|
console.log('[激活码]: '.green.bold);
|
|
console.log('\n' + licenseCode + '\n');
|
|
console.log('========================================'.blue);
|
|
console.log('请将上方红色文字拷贝到服务器根目录的 license.txt 文件中。'.grey);
|
|
|