fix licence
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
"net"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -70,7 +71,7 @@ func init() {
|
||||
|
||||
func WatchCheckLicence(licPath, licName string) {
|
||||
utils.SetInterval(func() {
|
||||
if CheckLicence(licPath, licName) == false {
|
||||
if !CheckLicence(licPath, licName) {
|
||||
log.Println("授权文件失效,请重新部署授权文件:", licPath)
|
||||
os.Exit(99)
|
||||
}
|
||||
@@ -81,6 +82,10 @@ func WatchCheckLicence(licPath, licName string) {
|
||||
// --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
func CheckLicence(licPath, licName string) bool {
|
||||
// 加载授权文件
|
||||
if licName == "" {
|
||||
licName = "licence.key"
|
||||
}
|
||||
licPath = filepath.Join(licPath, licName)
|
||||
content, err := LoadLicenceFromFile(licPath)
|
||||
if err != nil {
|
||||
return false
|
||||
@@ -98,11 +103,6 @@ func CheckLicence(licPath, licName string) bool {
|
||||
// --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
// Licence 校验
|
||||
func (l *Licence) VerifyLicence(licName string) bool {
|
||||
// 用于开发环境,为授权公司时跳过验证
|
||||
if l.CompanyName == licName {
|
||||
return true
|
||||
}
|
||||
|
||||
today := StrToInt(time.Now().Format("20060102"))
|
||||
// 机器日期不在授权文件有限期之内 (早于生效日期,或超过有效期)
|
||||
if (today < l.CreateDate) || (today > l.ExpireDate) {
|
||||
@@ -135,7 +135,7 @@ func (l *Licence) ValidMachineCode(code string) bool {
|
||||
// --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
// 加载授权文件
|
||||
func LoadLicenceFromFile(licPath string) (string, error) {
|
||||
key_path := path.Join(licPath, "licence.key")
|
||||
key_path := path.Join(licPath)
|
||||
if utils.PathExists(key_path) {
|
||||
file, err := os.Open(key_path)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user