diff --git a/server/app/controller/user.js b/server/app/controller/user.js
index bda28bd..e9cff7e 100644
--- a/server/app/controller/user.js
+++ b/server/app/controller/user.js
@@ -3,11 +3,13 @@ const axios = require('axios')
const speakeasy = require('speakeasy')
const QRCode = require('qrcode')
const version = require('../../package.json').version
+const getLicenseInfo = require('../utils/get-plus')
const { plusServer1, plusServer2 } = require('../utils/plus-server')
const { sendNoticeAsync } = require('../utils/notify')
const { RSADecryptAsync, AESEncryptAsync, SHA1Encrypt } = require('../utils/encrypt')
const { getNetIPInfo } = require('../utils/tools')
const { KeyDB, LogDB, PlusDB } = require('../utils/db-class')
+
const keyDB = new KeyDB().getInstance()
const logDB = new LogDB().getInstance()
const plusDB = new PlusDB().getInstance()
@@ -175,6 +177,7 @@ const getPlusInfo = async ({ res }) => {
}
const getPlusDiscount = async ({ res } = {}) => {
+ if (process.env.EXEC_ENV === 'local') return res.success({ discount: false })
const servers = [plusServer1, plusServer2]
for (const server of servers) {
try {
@@ -195,6 +198,18 @@ const getPlusDiscount = async ({ res } = {}) => {
}
}
+const getPlusConf = async ({ res }) => {
+ const { key } = await plusDB.findOneAsync({}) || {}
+ res.success({ data: key || '', msg: 'success' })
+}
+
+const updatePlusKey = async ({ res, request }) => {
+ const { body: { key } } = request
+ const { success, msg } = await getLicenseInfo(key)
+ if (!success) return res.fail({ msg })
+ res.success({ msg: 'success' })
+}
+
module.exports = {
login,
getpublicKey,
@@ -205,5 +220,7 @@ module.exports = {
enableMFA2,
disableMFA2,
getPlusInfo,
- getPlusDiscount
+ getPlusDiscount,
+ getPlusConf,
+ updatePlusKey
}
diff --git a/server/app/router/routes.js b/server/app/router/routes.js
index e55a906..d3c2b55 100644
--- a/server/app/router/routes.js
+++ b/server/app/router/routes.js
@@ -1,6 +1,6 @@
const { getSSHList, addSSH, updateSSH, removeSSH, getCommand, decryptPrivateKey } = require('../controller/ssh')
const { getHostList, addHost, updateHost, batchUpdateHost, removeHost, importHost } = require('../controller/host')
-const { login, getpublicKey, updatePwd, getEasynodeVersion, getMFA2Status, getMFA2Code, enableMFA2, disableMFA2, getPlusInfo, getPlusDiscount } = require('../controller/user')
+const { login, getpublicKey, updatePwd, getEasynodeVersion, getMFA2Status, getMFA2Code, enableMFA2, disableMFA2, getPlusInfo, getPlusDiscount, getPlusConf, updatePlusKey } = require('../controller/user')
const { getNotifyConfig, updateNotifyConfig, getNotifyList, updateNotifyList } = require('../controller/notify')
const { getGroupList, addGroupList, updateGroupList, removeGroup } = require('../controller/group')
const { getScriptList, getLocalScriptList, addScript, updateScriptList, removeScript, batchRemoveScript, importScript } = require('../controller/scripts')
@@ -121,6 +121,16 @@ const user = [
method: 'get',
path: '/plus-discount',
controller: getPlusDiscount
+ },
+ {
+ method: 'get',
+ path: '/plus-conf',
+ controller: getPlusConf
+ },
+ {
+ method: 'post',
+ path: '/plus-conf',
+ controller: updatePlusKey
}
]
const notify = [
diff --git a/server/app/utils/get-plus.js b/server/app/utils/get-plus.js
index 5184915..f850f74 100644
--- a/server/app/utils/get-plus.js
+++ b/server/app/utils/get-plus.js
@@ -3,10 +3,16 @@ const { getLocalNetIP } = require('./tools')
const { AESEncryptAsync } = require('./encrypt')
const version = require('../../package.json').version
const { plusServer1, plusServer2 } = require('./plus-server')
+const { PlusDB } = require('./db-class')
+const plusDB = new PlusDB().getInstance()
-async function getLicenseInfo() {
- let key = process.env.PLUS_KEY
- if (!key || typeof key !== 'string' || key.length < 20) return
+async function getLicenseInfo(key = '') {
+ const { key: plusKey } = await plusDB.findOneAsync({}) || {}
+ // console.log('plusKey: ', plusKey)
+ // console.log('key: ', key)
+ // console.log('process.env.PLUS_KEY: ', process.env.PLUS_KEY)
+ key = key || plusKey || process.env.PLUS_KEY
+ if (!key || key.length < 16) return { success: false, msg: 'Invalid Plus Key' }
let ip = ''
if (global.serverIp && (Date.now() - global.getServerIpLastTime) / 1000 / 60 < 60) {
ip = global.serverIp
@@ -20,7 +26,7 @@ async function getLicenseInfo() {
if (!ip) {
consola.error('activate plus failed: get public ip failed')
global.serverIp = ''
- return
+ return { success: false, msg: 'get public ip failed' }
}
try {
let response
@@ -64,9 +70,7 @@ async function getLicenseInfo() {
let { decryptKey, expiryDate, usedIPCount, maxIPs, usedIPs } = data
decryptKey = await AESEncryptAsync(decryptKey)
consola.success('activate plus success')
- const { PlusDB } = require('./db-class')
const plusData = { key, decryptKey, expiryDate, usedIPCount, maxIPs, usedIPs }
- const plusDB = new PlusDB().getInstance()
let count = await plusDB.countAsync({})
if (count === 0) {
await plusDB.insertAsync(plusData)
@@ -74,14 +78,16 @@ async function getLicenseInfo() {
await plusDB.removeAsync({}, { multi: true })
await plusDB.insertAsync(plusData)
}
+ return { success: true, msg: '激活成功' }
}
+ consola.error('activate plus failed: ', data)
+ return { success: false, msg: '激活失败' }
} catch (error) {
consola.error(`activate plus failed: ${ error.message || error.errMsg?.message }`)
if (error.clear) {
- const { PlusDB } = require('./db-class')
- const plusDB = new PlusDB().getInstance()
await plusDB.removeAsync({}, { multi: true })
}
+ return { success: false, msg: error.message || error.errMsg?.message }
}
}
diff --git a/web/src/api/index.js b/web/src/api/index.js
index 2c15ee9..0e013d4 100644
--- a/web/src/api/index.js
+++ b/web/src/api/index.js
@@ -126,5 +126,11 @@ export default {
},
getEasynodeVersion() {
return axios({ url: '/version', method: 'get' })
+ },
+ getPlusConf() {
+ return axios({ url: '/plus-conf', method: 'get' })
+ },
+ updatePlusKey(data) {
+ return axios({ url: '/plus-conf', method: 'post', data })
}
}
diff --git a/web/src/components/plus-table.vue b/web/src/components/plus-table.vue
new file mode 100644
index 0000000..58ece10
--- /dev/null
+++ b/web/src/components/plus-table.vue
@@ -0,0 +1,206 @@
+
+
+
+ EasyNode最初是一个简单的Web终端工具,随着用户群的不断扩大,功能需求也日益增长,为了实现大家的功能需求,我投入了大量的业余时间进行开发和维护。
+ 一直在为爱发电,渐渐的也没了开发的动力。
+
+ 为了项目的可持续发展,后续版本开始推出PLUS版本,具体特性鼠标悬浮右上角PLUS图标查看,后续特性功能开发也会优先在PLUS版本中实现,但即使不升级到PLUS,也不会影响到EasyNode的基础功能使用【注意:
+ 暂不支持纯内网用户激活PLUS功能】。
+
+
+ 为了感谢前期赞赏过的用户, 在PLUS功能正式发布前,所有进行过赞赏的用户,无论金额大小,均可联系作者TG: @chaoszhu 凭打赏记录免费获取永久PLUS授权码。
+
+
-
-
- PLUS说明:
- EasyNode最初是一个简单的Web终端工具,随着用户群的不断扩大,功能需求也日益增长,为了实现大家的功能需求,我投入了大量的业余时间进行开发和维护。
- 一直在为爱发电,渐渐的也没了开发的动力。
-
- 为了项目的可持续发展,从3.0.0版本开始推出了PLUS版本,具体特性鼠标悬浮右上角PLUS图标查看,后续特性功能开发也会优先在PLUS版本中实现,但即使不升级到PLUS,也不会影响到EasyNode的基础功能使用【注意: 暂不支持纯内网用户激活PLUS功能】。
-
-
- 为了感谢前期赞赏过的用户, 在PLUS功能正式发布前,所有进行过赞赏的用户,无论金额大小,均可联系作者TG: @chaoszhu 凭打赏记录免费获取永久PLUS授权码。
-
-