diff --git a/Cargo.lock b/Cargo.lock index ca9393c..9b148b9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3075,7 +3075,7 @@ dependencies = [ [[package]] name = "trifid-api" -version = "0.3.0" +version = "0.3.0-alpha1" dependencies = [ "actix-cors", "actix-web", diff --git a/trifid-api/Cargo.toml b/trifid-api/Cargo.toml index 06d7598..63abcf7 100644 --- a/trifid-api/Cargo.toml +++ b/trifid-api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "trifid-api" -version = "0.3.0" +version = "0.3.0-alpha1" authors = ["core "] edition = "2021" description = "An open-source reimplementation of the Defined Networking API server" diff --git a/trifid-api/migrations/2023-12-24-220412_create_table_roles/down.sql b/trifid-api/migrations/2023-12-24-220412_create_table_roles/down.sql new file mode 100644 index 0000000..2d6fd20 --- /dev/null +++ b/trifid-api/migrations/2023-12-24-220412_create_table_roles/down.sql @@ -0,0 +1 @@ +DROP TABLE roles; \ No newline at end of file diff --git a/trifid-api/migrations/2023-12-24-220412_create_table_roles/up.sql b/trifid-api/migrations/2023-12-24-220412_create_table_roles/up.sql new file mode 100644 index 0000000..f3261b8 --- /dev/null +++ b/trifid-api/migrations/2023-12-24-220412_create_table_roles/up.sql @@ -0,0 +1,6 @@ +CREATE TABLE roles ( + id VARCHAR NOT NULL PRIMARY KEY, + name VARCHAR NOT NULL, + description VARCHAR NOT NULL, + organizationId VARCHAR NOT NULL REFERENCES organizations(id) +); \ No newline at end of file diff --git a/trifid-api/migrations/2023-12-24-220423_create_table_role_firewall_rules/down.sql b/trifid-api/migrations/2023-12-24-220423_create_table_role_firewall_rules/down.sql new file mode 100644 index 0000000..06792cd --- /dev/null +++ b/trifid-api/migrations/2023-12-24-220423_create_table_role_firewall_rules/down.sql @@ -0,0 +1 @@ +DROP TABLE role_firewall_rules; \ No newline at end of file diff --git a/trifid-api/migrations/2023-12-24-220423_create_table_role_firewall_rules/up.sql b/trifid-api/migrations/2023-12-24-220423_create_table_role_firewall_rules/up.sql new file mode 100644 index 0000000..34fd074 --- /dev/null +++ b/trifid-api/migrations/2023-12-24-220423_create_table_role_firewall_rules/up.sql @@ -0,0 +1,9 @@ +CREATE TABLE role_firewall_rules ( + id VARCHAR NOT NULL UNIQUE, + roleId VARCHAR NOT NULL REFERENCES roles(id), + protocol VARCHAR NOT NULL, + description VARCHAR NOT NULL, + allowedRoleId VARCHAR NULL, + allowedTags VARCHAR[], + portRange int4range NULL +); \ No newline at end of file diff --git a/trifid-api/migrations/2023-12-24-220434_create_table_hosts/down.sql b/trifid-api/migrations/2023-12-24-220434_create_table_hosts/down.sql new file mode 100644 index 0000000..a2399b4 --- /dev/null +++ b/trifid-api/migrations/2023-12-24-220434_create_table_hosts/down.sql @@ -0,0 +1 @@ +DROP TABLE hosts; \ No newline at end of file diff --git a/trifid-api/migrations/2023-12-24-220434_create_table_hosts/up.sql b/trifid-api/migrations/2023-12-24-220434_create_table_hosts/up.sql new file mode 100644 index 0000000..bcb58c1 --- /dev/null +++ b/trifid-api/migrations/2023-12-24-220434_create_table_hosts/up.sql @@ -0,0 +1,21 @@ +CREATE TABLE hosts ( + id VARCHAR NOT NULL PRIMARY KEY, + organizationId VARCHAR NOT NULL REFERENCES organizations(id), + networkId VARCHAR NOT NULL REFERENCES networks(id), + roleId VARCHAR NULL REFERENCES roles(id), + name VARCHAR NOT NULL, + ipAddress VARCHAR NOT NULL, + staticAddresses VARCHAR[] NOT NULL, + listenPort int2 NOT NULL, + isLighthouse BOOLEAN NOT NULL, + isRelay BOOLEAN NOT NULL, + createdAt TIMESTAMP NOT NULL, + isBlocked BOOLEAN NOT NULL, + + lastSeenAt TIMESTAMP NULL, + clientVersion VARCHAR NULL, + platform VARCHAR NULL, + updateAvailable BOOLEAN NULL, + + tags VARCHAR[] NOT NULL +); \ No newline at end of file diff --git a/trifid-api/migrations/2023-12-24-222225_create_table_host_overrides/down.sql b/trifid-api/migrations/2023-12-24-222225_create_table_host_overrides/down.sql new file mode 100644 index 0000000..39cebc9 --- /dev/null +++ b/trifid-api/migrations/2023-12-24-222225_create_table_host_overrides/down.sql @@ -0,0 +1 @@ +DROP TABLE host_overrides; \ No newline at end of file diff --git a/trifid-api/migrations/2023-12-24-222225_create_table_host_overrides/up.sql b/trifid-api/migrations/2023-12-24-222225_create_table_host_overrides/up.sql new file mode 100644 index 0000000..9ae401f --- /dev/null +++ b/trifid-api/migrations/2023-12-24-222225_create_table_host_overrides/up.sql @@ -0,0 +1,6 @@ +CREATE TABLE host_overrides ( + id VARCHAR NOT NULL PRIMARY KEY, + hostId VARCHAR NOT NULL REFERENCES hosts(id), + key VARCHAR NOT NULL, + value jsonb NOT NULL +); \ No newline at end of file diff --git a/trifid-api/migrations/2023-12-24-222227_create_table_host_keys/down.sql b/trifid-api/migrations/2023-12-24-222227_create_table_host_keys/down.sql new file mode 100644 index 0000000..d9a93fe --- /dev/null +++ b/trifid-api/migrations/2023-12-24-222227_create_table_host_keys/down.sql @@ -0,0 +1 @@ +-- This file should undo anything in `up.sql` diff --git a/trifid-api/migrations/2023-12-24-222227_create_table_host_keys/up.sql b/trifid-api/migrations/2023-12-24-222227_create_table_host_keys/up.sql new file mode 100644 index 0000000..23c7dbd --- /dev/null +++ b/trifid-api/migrations/2023-12-24-222227_create_table_host_keys/up.sql @@ -0,0 +1,11 @@ +CREATE TABLE host_keys ( + id VARCHAR NOT NULL PRIMARY KEY, + hostId VARCHAR NOT NULL REFERENCES hosts(id), + + counter INT NOT NULL, + client_ed_pub bytea NOT NULL, + client_dh_pub bytea NOT NULL, + client_cert bytea NOT NULL, + + UNIQUE (hostId, counter) +); \ No newline at end of file