license

package
v5.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2023 License: AGPL-3.0 Imports: 21 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrLicenseNotFound 授权证书不存在
	ErrLicenseNotFound = errors.New(`License does not exist`)
	// SkipLicenseCheck 跳过授权检测
	SkipLicenseCheck = true
)
View Source
var (
	MachineIDEncode = func(v string) string {
		return com.MakePassword(v, `coscms`, 3, 8, 19)
	}
	LicenseDecode = func(b []byte) ([]byte, string) {
		return b, GetOrLoadPublicKey()
	}
)
View Source
var (
	ErrConnectionFailed       = errors.New(`连接授权服务器失败`)
	ErrOfficialDataUnexcepted = errors.New(`官方数据返回异常`)
	ErrLicenseDownloadFailed  = errors.New(`下载证书失败:官方数据返回异常`)
)
View Source
var NewValidateResponse = func() *ValidateResponse {
	return &ValidateResponse{
		Data: ValidateResultInitor(),
	}
}
View Source
var ValidateResultInitor = func() Validator {
	return &ValidateResult{}
}

Functions

func Check

func Check(ctx echo.Context) error

Check 检查权限

func CheckSiteURL

func CheckSiteURL(siteURL string, recordAvailableDomain ...bool) error

func Domain

func Domain() string

func Download

func Download(ctx echo.Context) error

Download 从官方服务器重新下载许可证

func DownloadOnce

func DownloadOnce(ctx echo.Context) error

func DownloadTime

func DownloadTime() time.Time

func EqDomain

func EqDomain(fullDomain string, rootDomain string) bool

func Error

func Error() error

func FileName

func FileName() string

func FilePath

func FilePath() string

func FireSetLicense

func FireSetLicense(data *lib.LicenseData)

func FullDomain

func FullDomain() string

func FullLicenseURL

func FullLicenseURL(ctx echo.Context) string

FullLicenseURL 包含完整参数的授权网址

func Generate

func Generate(privBytes []byte, pemSaveDirs ...string) error

Generate 生成演示版证书

func GetOrLoadPublicKey

func GetOrLoadPublicKey() string

func License

func License() lib.LicenseData

func LoadPublicKey

func LoadPublicKey()

func MachineID

func MachineID() (string, error)

MachineID 生成当前机器的机器码

func Ok

func Ok(ctx echo.Context) bool

func OnSetLicense

func OnSetLicense(fn func(*lib.LicenseData))

func Package

func Package() string

func ProductDetailURL

func ProductDetailURL() (url string)

func ProductURL

func ProductURL() string

func PublicKey

func PublicKey() string

func ReadLicenseKeyFile

func ReadLicenseKeyFile() ([]byte, error)

func Save

func Save(b []byte) error

Save 保存授权文件

func SetDomain

func SetDomain(_domain string)

func SetError

func SetError(err error)

func SetLicense

func SetLicense(data *lib.LicenseData)

func SetPackage

func SetPackage(pkg string)

func SetProductDomain

func SetProductDomain(domain string)

func SetProductName

func SetProductName(name string, domains ...string)

func SetPublicKey

func SetPublicKey(pubkey string)

func SetServerURL

func SetServerURL(s *ServerURL)

func SetVersion

func SetVersion(ver string)

func TrackerHTML

func TrackerHTML() template.HTML

func TrackerURL

func TrackerURL() string

func URLValues

func URLValues(ctx echo.Context) url.Values

URLValues 组装网址参数

func Validate

func Validate(content ...[]byte) (err error)

Validate 验证授权

func VerifyPostLicenseContent

func VerifyPostLicenseContent(ctx echo.Context, content []byte) error

VerifyPostLicenseContent 验证提交的证书内容

func Version

func Version() string

Types

type Mode

type Mode int
const (
	ModeMachineID Mode = iota
	ModeDomain
)

func LicenseMode

func LicenseMode() Mode

type OfficialData

type OfficialData struct {
	License   string
	Timestamp int64
}

type OfficialResponse

type OfficialResponse struct {
	Code int
	Info string
	Zone string        `json:",omitempty" xml:",omitempty"`
	Data *OfficialData `json:",omitempty" xml:",omitempty"`
}

type ProductVersion

type ProductVersion struct {
	Id               uint64 `comment:"ID" json:"id" xml:"id"`
	ProductId        uint64 `comment:"产品ID" json:"product_id" xml:"product_id"`
	Version          string `comment:"版本号(格式1.0.1)" json:"version" xml:"version"`
	Type             string `comment:"版本类型(stable-稳定版;beta-公测版;alpha-内测版)" json:"type" xml:"type"`
	Os               string `comment:"支持的操作系统(多个用逗号分隔),留空表示不限制" json:"os" xml:"os"`
	Arch             string `comment:"硬件架构(多个用逗号分隔),留空表示不限制" json:"arch" xml:"arch"`
	ReleasedAt       uint   `comment:"发布时间" json:"released_at" xml:"released_at"`
	Created          uint   `comment:"创建时间" json:"created" xml:"created"`
	Updated          uint   `comment:"修改时间" json:"updated" xml:"updated"`
	Disabled         string `comment:"是否禁用" json:"disabled" xml:"disabled"`
	Audited          string `comment:"是否已审核" json:"audited" xml:"audited"`
	ForceUpgrade     string `comment:"是否强行升级为此版本" json:"force_upgrade" xml:"force_upgrade"`
	Description      string `comment:"发布说明" json:"description" xml:"description"`
	Remark           string `comment:"备注" json:"remark" xml:"remark"`
	DownloadUrl      string `comment:"下载网址" json:"download_url" xml:"download_url"`
	Sign             string `comment:"下载后验证签名(多个签名之间用逗号分隔)" json:"sign" xml:"sign"`
	DownloadUrlOther string `comment:"备用下载网址" json:"download_url_other" xml:"download_url_other"`
	DownloadedPath   string `comment:"自动下载保存路径" json:"-" xml:"-"`
}

func LatestVersion

func LatestVersion(ctx echo.Context, forceDownload bool) (*ProductVersion, error)

type ServerURL

type ServerURL struct {
	Tracker         string //用于统计分析的js地址
	Product         string //该产品的详情介绍页面网址
	License         string //许可证验证和许可证下载API网址
	Version         string //该产品最新版本信息API网址
	LicenseFileName string //许可证文件名称
}

func (*ServerURL) Apply

func (s *ServerURL) Apply()

type ValidateResponse

type ValidateResponse struct {
	Code int
	Info string
	Zone string    `json:",omitempty" xml:",omitempty"`
	Data Validator `json:",omitempty" xml:",omitempty"`
}

type ValidateResult

type ValidateResult struct {
}

func (*ValidateResult) Validate

func (v *ValidateResult) Validate() error

type Validation

type Validation struct {
	NowVersions []string
}

Validation 定义验证器

func (*Validation) Validate

func (v *Validation) Validate(data *lib.LicenseData) error

Validate 参数验证器

type Validator

type Validator interface {
	Validate() error
}

type VersionResponse

type VersionResponse struct {
	Code int
	Info string
	Zone string          `json:",omitempty" xml:",omitempty"`
	Data *ProductVersion `json:",omitempty" xml:",omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL