mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-01-29 15:43:52 +00:00
Go ahead and spec out controller DB support for AuthToken -- GitHub issue #211 -- even though full implementation won't make it into 1.0.4.
This commit is contained in:
parent
7578b56298
commit
fcc5bf1e66
@ -146,9 +146,10 @@ SqliteNetworkController::SqliteNetworkController(const char *dbPath) :
|
||||
// Prepare statement will fail if Config table doesn't exist, which means our DB
|
||||
// needs to be initialized.
|
||||
if (sqlite3_exec(_db,ZT_NETCONF_SCHEMA_SQL"INSERT INTO Config (k,v) VALUES ('schemaVersion',"ZT_NETCONF_SQLITE_SCHEMA_VERSION_STR");",0,0,0) != SQLITE_OK) {
|
||||
//printf("%s\n",sqlite3_errmsg(_db));
|
||||
char err[1024];
|
||||
Utils::snprintf(err,sizeof(err),"SqliteNetworkController cannot initialize database and/or insert schemaVersion into Config table: %s",sqlite3_errmsg(_db));
|
||||
sqlite3_close(_db);
|
||||
throw std::runtime_error("SqliteNetworkController cannot initialize database and/or insert schemaVersion into Config table");
|
||||
throw std::runtime_error(err);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,18 @@ CREATE TABLE Network (
|
||||
memberRevisionCounter integer NOT NULL DEFAULT(1)
|
||||
);
|
||||
|
||||
CREATE TABLE AuthToken (
|
||||
id integer PRIMARY KEY NOT NULL,
|
||||
networkId char(16) NOT NULL REFERENCES Network(id) ON DELETE CASCADE,
|
||||
authMode integer NOT NULL DEFAULT(1),
|
||||
useCount integer NOT NULL DEFAULT(0),
|
||||
maxUses integer NOT NULL DEFAULT(0),
|
||||
expiresAt integer NOT NULL DEFAULT(0),
|
||||
token varchar(256) NOT NULL
|
||||
);
|
||||
|
||||
CREATE INDEX AuthToken_networkId_token ON AuthToken(networkId,token);
|
||||
|
||||
CREATE TABLE Node (
|
||||
id char(10) PRIMARY KEY NOT NULL,
|
||||
identity varchar(4096) NOT NULL
|
||||
@ -70,6 +82,7 @@ CREATE TABLE Log (
|
||||
nodeId char(10) NOT NULL,
|
||||
ts integer NOT NULL,
|
||||
authorized integer NOT NULL,
|
||||
authTokenId integer,
|
||||
version varchar(16),
|
||||
fromAddr varchar(64)
|
||||
);
|
||||
|
@ -18,6 +18,18 @@
|
||||
" memberRevisionCounter integer NOT NULL DEFAULT(1)\n"\
|
||||
");\n"\
|
||||
"\n"\
|
||||
"CREATE TABLE AuthToken (\n"\
|
||||
" id integer PRIMARY KEY NOT NULL,\n"\
|
||||
" networkId char(16) NOT NULL REFERENCES Network(id) ON DELETE CASCADE,\n"\
|
||||
" authMode integer NOT NULL DEFAULT(1),\n"\
|
||||
" useCount integer NOT NULL DEFAULT(0),\n"\
|
||||
" maxUses integer NOT NULL DEFAULT(0),\n"\
|
||||
" expiresAt integer NOT NULL DEFAULT(0),\n"\
|
||||
" token varchar(256) NOT NULL\n"\
|
||||
");\n"\
|
||||
"\n"\
|
||||
"CREATE INDEX AuthToken_networkId_token ON AuthToken(networkId,token);\n"\
|
||||
"\n"\
|
||||
"CREATE TABLE Node (\n"\
|
||||
" id char(10) PRIMARY KEY NOT NULL,\n"\
|
||||
" identity varchar(4096) NOT NULL\n"\
|
||||
@ -71,6 +83,7 @@
|
||||
" nodeId char(10) NOT NULL,\n"\
|
||||
" ts integer NOT NULL,\n"\
|
||||
" authorized integer NOT NULL,\n"\
|
||||
" authTokenId integer,\n"\
|
||||
" version varchar(16),\n"\
|
||||
" fromAddr varchar(64)\n"\
|
||||
");\n"\
|
||||
|
Loading…
x
Reference in New Issue
Block a user