mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-11-30 02:38:17 +08:00
[ADD] use license key
This commit is contained in:
parent
edca0b62b7
commit
49284182bd
@ -49,10 +49,37 @@ func NewCmdLicense() cli.Command {
|
||||
table.AddRow("授权单数据中心节点数:", licInfo.Node)
|
||||
table.AddRow("授权开始时间:", licInfo.StartTime)
|
||||
table.AddRow("授权到期时间:", licInfo.EndTime)
|
||||
table.AddRow("授权key:", licInfo.LicKey)
|
||||
fmt.Println(table)
|
||||
return nil
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "genkey",
|
||||
Usage: "generate a license key for the machine",
|
||||
Flags: []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "lic-so-path, lsp",
|
||||
Usage: "license.so file path",
|
||||
Value: "/opt/rainbond/etc/license/license.so",
|
||||
},
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
Common(c)
|
||||
licSoPath := c.String("lic-so-path")
|
||||
licKey, err := licutil.GenLicKey(licSoPath)
|
||||
if err != nil {
|
||||
showError(err.Error())
|
||||
}
|
||||
|
||||
if licKey == "" {
|
||||
fmt.Println("non-enterprise version, no license key")
|
||||
return nil
|
||||
}
|
||||
fmt.Println(licKey)
|
||||
return nil
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
return c
|
||||
|
@ -86,7 +86,11 @@ build::binary() {
|
||||
elif [ "$1" = "gateway" ];then
|
||||
docker run --rm -e GOOS=${GOOS} -v `pwd`:${WORK_DIR} -w ${WORK_DIR} -it golang:${GATEWAY_GO_VERSION} go build -ldflags "-w -s -X github.com/goodrain/rainbond/cmd.version=${release_desc}" -o ${OUTPATH} ./cmd/$1
|
||||
else
|
||||
docker run --rm -e GOOS=${GOOS} -v `pwd`:${WORK_DIR} -w ${WORK_DIR} -it golang:${GO_VERSION} go build -ldflags "-w -s -X github.com/goodrain/rainbond/cmd.version=${release_desc}" -tags license -o ${OUTPATH} ./cmd/$1
|
||||
if [ "${ENTERPRISE}" = "true" ];then
|
||||
docker run --rm -e GOOS=${GOOS} -v `pwd`:${WORK_DIR} -w ${WORK_DIR} -it golang:${GO_VERSION} go build -ldflags "-w -s -X github.com/goodrain/rainbond/cmd.version=${release_desc}" -tags license -o ${OUTPATH} ./cmd/$1
|
||||
else
|
||||
docker run --rm -e GOOS=${GOOS} -v `pwd`:${WORK_DIR} -w ${WORK_DIR} -it golang:${GO_VERSION} go build -ldflags "-w -s -X github.com/goodrain/rainbond/cmd.version=${release_desc}" -o ${OUTPATH} ./cmd/$1
|
||||
fi
|
||||
fi
|
||||
if [ "$GOOS" = "windows" ];then
|
||||
mv $OUTPATH ${OUTPATH}.exe
|
||||
|
@ -32,6 +32,7 @@ import (
|
||||
|
||||
// LicInfo license information
|
||||
type LicInfo struct {
|
||||
LicKey string `json:"license_key"`
|
||||
Code string `json:"code"`
|
||||
Company string `json:"company"`
|
||||
Node int64 `json:"node"`
|
||||
@ -124,3 +125,19 @@ func GetLicInfo(licPath, licSoPath string) (*LicInfo, error) {
|
||||
}
|
||||
return &licInfo, nil
|
||||
}
|
||||
|
||||
// GenLicKey -
|
||||
func GenLicKey(licSoPath string) (string, error) {
|
||||
p, err := plugin.Open(licSoPath)
|
||||
if err != nil {
|
||||
logrus.Errorf("license.so path: %s; error opening license.so: %v", licSoPath, err)
|
||||
return "", fmt.Errorf("license.so path: %s; error opening license.so: %v", licSoPath, err)
|
||||
}
|
||||
|
||||
f, err := p.Lookup("GenLicKey")
|
||||
if err != nil {
|
||||
logrus.Errorf("method 'GenLicKey'; error looking up func: %v", err)
|
||||
return "", fmt.Errorf("method 'GenLicKey'; error looking up func: %v", err)
|
||||
}
|
||||
return f.(func() (string, error))()
|
||||
}
|
||||
|
@ -48,3 +48,8 @@ func VerifyNodes(licPath, licSoPath string, nodeNums int) bool {
|
||||
func GetLicInfo(licPath, licSoPath string) (*LicInfo, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// GenLicKey -
|
||||
func GenLicKey(licSoPath string) (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user