Implement license key checks
Former-commit-id: 62ed5b2956aebe70ef8cf758888098e1f4bb530b
This commit is contained in:
parent
d50da19fb4
commit
103fbf663e
3
deps/license/keycheck.h
vendored
Normal file
3
deps/license/keycheck.h
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
bool FValidKey(const char *key, size_t cch);
|
BIN
deps/license/libkey.a
vendored
Normal file
BIN
deps/license/libkey.a
vendored
Normal file
Binary file not shown.
@ -105,7 +105,7 @@ endif
|
|||||||
FINAL_CFLAGS=$(STD) $(WARN) $(OPT) $(DEBUG) $(CFLAGS) $(REDIS_CFLAGS)
|
FINAL_CFLAGS=$(STD) $(WARN) $(OPT) $(DEBUG) $(CFLAGS) $(REDIS_CFLAGS)
|
||||||
FINAL_CXXFLAGS=$(CXX_STD) $(WARN) $(OPT) $(DEBUG) $(CXXFLAGS) $(REDIS_CFLAGS)
|
FINAL_CXXFLAGS=$(CXX_STD) $(WARN) $(OPT) $(DEBUG) $(CXXFLAGS) $(REDIS_CFLAGS)
|
||||||
FINAL_LDFLAGS=$(LDFLAGS) $(REDIS_LDFLAGS) $(DEBUG)
|
FINAL_LDFLAGS=$(LDFLAGS) $(REDIS_LDFLAGS) $(DEBUG)
|
||||||
FINAL_LIBS=-lm -lz -latomic
|
FINAL_LIBS=-lm -lz -latomic -L../deps/license/ -lkey -lcrypto
|
||||||
DEBUG=-g -ggdb
|
DEBUG=-g -ggdb
|
||||||
|
|
||||||
ifeq ($(uname_S),SunOS)
|
ifeq ($(uname_S),SunOS)
|
||||||
@ -163,8 +163,8 @@ endif
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
# Include paths to dependencies
|
# Include paths to dependencies
|
||||||
FINAL_CFLAGS+= -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src
|
FINAL_CFLAGS+= -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src -I../deps/license/
|
||||||
FINAL_CXXFLAGS+= -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src -I../deps/rocksdb/include/
|
FINAL_CXXFLAGS+= -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src -I../deps/rocksdb/include/ -I../deps/license
|
||||||
|
|
||||||
ifeq ($(MALLOC),tcmalloc)
|
ifeq ($(MALLOC),tcmalloc)
|
||||||
FINAL_CFLAGS+= -DUSE_TCMALLOC
|
FINAL_CFLAGS+= -DUSE_TCMALLOC
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/sysinfo.h>
|
#include <sys/sysinfo.h>
|
||||||
|
#include "keycheck.h"
|
||||||
|
|
||||||
|
|
||||||
const char *KEYDB_SET_VERSION = KEYDB_REAL_VERSION;
|
const char *KEYDB_SET_VERSION = KEYDB_REAL_VERSION;
|
||||||
@ -841,6 +842,10 @@ void loadServerConfigFromString(char *config) {
|
|||||||
if (!initializeStorageProvider(argv+1, argc-1, &err))
|
if (!initializeStorageProvider(argv+1, argc-1, &err))
|
||||||
goto loaderr;
|
goto loaderr;
|
||||||
} else if (!strcasecmp(argv[0],"enable-pro") && argc == 2) {
|
} else if (!strcasecmp(argv[0],"enable-pro") && argc == 2) {
|
||||||
|
if (!FValidKey(argv[1], strlen(argv[1]))) {
|
||||||
|
err = "Invalid license key";
|
||||||
|
goto loaderr;
|
||||||
|
}
|
||||||
cserver.license_key = zstrdup(argv[1]);
|
cserver.license_key = zstrdup(argv[1]);
|
||||||
} else {
|
} else {
|
||||||
err = "Bad directive or wrong number of arguments"; goto loaderr;
|
err = "Bad directive or wrong number of arguments"; goto loaderr;
|
||||||
|
@ -61,6 +61,7 @@
|
|||||||
#include <uuid/uuid.h>
|
#include <uuid/uuid.h>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include "aelocker.h"
|
#include "aelocker.h"
|
||||||
|
#include "keycheck.h"
|
||||||
|
|
||||||
int g_fTestMode = false;
|
int g_fTestMode = false;
|
||||||
|
|
||||||
@ -1095,6 +1096,8 @@ void serverLog(int level, const char *fmt, ...) {
|
|||||||
|
|
||||||
static void checkTrialTimeout()
|
static void checkTrialTimeout()
|
||||||
{
|
{
|
||||||
|
if (cserver.license_key != nullptr && FValidKey(cserver.license_key, strlen(cserver.license_key)))
|
||||||
|
return;
|
||||||
time_t curtime = time(NULL);
|
time_t curtime = time(NULL);
|
||||||
int64_t elapsed = (int64_t)curtime - (int64_t)cserver.stat_starttime;
|
int64_t elapsed = (int64_t)curtime - (int64_t)cserver.stat_starttime;
|
||||||
int64_t remaining = (cserver.trial_timeout * 60L) - elapsed;
|
int64_t remaining = (cserver.trial_timeout * 60L) - elapsed;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user