mirror of
https://github.com/PrivateCaptcha/PrivateCaptcha.git
synced 2026-02-08 23:09:11 -06:00
Allow build-time redefining activation URL for selfhosted licenses
This commit is contained in:
@@ -2,9 +2,11 @@ services:
|
||||
server:
|
||||
build:
|
||||
args:
|
||||
GO_LDFLAGS: '-s -w -X github.com/PrivateCaptcha/PrivateCaptcha/pkg/maintenance.LicenseURL=http://host.docker.internal:8181/selfhosted/activation'
|
||||
EXTRA_BUILD_FLAGS: '-tags enterprise'
|
||||
|
||||
migration:
|
||||
build:
|
||||
args:
|
||||
GO_LDFLAGS: '-s -w -X github.com/PrivateCaptcha/PrivateCaptcha/pkg/maintenance.LicenseURL=http://host.docker.internal:8181/selfhosted/activation'
|
||||
EXTRA_BUILD_FLAGS: '-tags enterprise'
|
||||
|
||||
@@ -36,7 +36,7 @@ const (
|
||||
|
||||
var (
|
||||
// NOTE: for testing, replace with host.docker.internal domain
|
||||
licenseURL = fmt.Sprintf("https://api.privatecaptcha.com/%s/%s", common.SelfHostedEndpoint, common.ActivationEndpoint)
|
||||
LicenseURL string
|
||||
errLicenseRequest = errors.New("license request error")
|
||||
errLicenseServer = errors.New("license server error")
|
||||
errEnterpriseConfigError = errors.New("enterprise config error")
|
||||
@@ -44,6 +44,12 @@ var (
|
||||
errNoMacAddress = errors.New("mac address not found")
|
||||
)
|
||||
|
||||
func init() {
|
||||
if LicenseURL == "" {
|
||||
LicenseURL = fmt.Sprintf("https://api.privatecaptcha.com/%s/%s", common.SelfHostedEndpoint, common.ActivationEndpoint)
|
||||
}
|
||||
}
|
||||
|
||||
func NewCheckLicenseJob(store db.Implementor, config common.ConfigStore, version string, quitFunc func(ctx context.Context)) (common.PeriodicJob, error) {
|
||||
keys, err := license.ActivationKeys()
|
||||
if err != nil {
|
||||
@@ -54,14 +60,14 @@ func NewCheckLicenseJob(store db.Implementor, config common.ConfigStore, version
|
||||
return nil, errNoEnterpriseKeys
|
||||
}
|
||||
|
||||
if len(licenseURL) == 0 {
|
||||
if len(LicenseURL) == 0 {
|
||||
return nil, errEnterpriseConfigError
|
||||
}
|
||||
|
||||
return &checkLicenseJob{
|
||||
store: store,
|
||||
keys: keys,
|
||||
url: licenseURL,
|
||||
url: LicenseURL,
|
||||
licenseKey: config.Get(common.EnterpriseLicenseKeyKey),
|
||||
adminEmail: config.Get(common.AdminEmailKey),
|
||||
quitFunc: quitFunc,
|
||||
|
||||
Reference in New Issue
Block a user