GURT protocol (lib, cli, gdextension, Flumi integration)

This commit is contained in:
Face
2025-08-14 20:29:19 +03:00
parent 65f3a21890
commit c117e602fe
46 changed files with 6559 additions and 89 deletions

View File

@@ -1,4 +1,3 @@
-- Create users table
CREATE TABLE IF NOT EXISTS users (
id SERIAL PRIMARY KEY,
username VARCHAR(50) UNIQUE NOT NULL,
@@ -8,7 +7,6 @@ CREATE TABLE IF NOT EXISTS users (
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Create invite codes table
CREATE TABLE IF NOT EXISTS invite_codes (
id SERIAL PRIMARY KEY,
code VARCHAR(32) UNIQUE NOT NULL,
@@ -18,7 +16,6 @@ CREATE TABLE IF NOT EXISTS invite_codes (
used_at TIMESTAMP
);
-- Create domains table
CREATE TABLE IF NOT EXISTS domains (
id SERIAL PRIMARY KEY,
name VARCHAR(100) NOT NULL,
@@ -31,7 +28,6 @@ CREATE TABLE IF NOT EXISTS domains (
UNIQUE(name, tld)
);
-- Create indexes for faster lookups
CREATE INDEX IF NOT EXISTS idx_domains_name_tld ON domains(name, tld);
CREATE INDEX IF NOT EXISTS idx_domains_user_id ON domains(user_id);
CREATE INDEX IF NOT EXISTS idx_domains_status ON domains(status);

View File

@@ -1,5 +1,3 @@
-- Remove email field from users table
ALTER TABLE users DROP COLUMN IF EXISTS email;
-- Drop email index if it exists
DROP INDEX IF EXISTS idx_users_email;

View File

@@ -1,4 +1,3 @@
-- Fix timestamp columns to use TIMESTAMPTZ instead of TIMESTAMP
ALTER TABLE users ALTER COLUMN created_at TYPE TIMESTAMPTZ;
ALTER TABLE invite_codes ALTER COLUMN created_at TYPE TIMESTAMPTZ;
ALTER TABLE invite_codes ALTER COLUMN used_at TYPE TIMESTAMPTZ;

View File

@@ -1,7 +1,5 @@
-- Add domain_invite_codes field to users table
ALTER TABLE users ADD COLUMN domain_invite_codes INTEGER DEFAULT 3;
-- Create domain invite codes table for domain-specific invites
CREATE TABLE IF NOT EXISTS domain_invite_codes (
id SERIAL PRIMARY KEY,
code VARCHAR(32) UNIQUE NOT NULL,
@@ -11,7 +9,6 @@ CREATE TABLE IF NOT EXISTS domain_invite_codes (
used_at TIMESTAMPTZ
);
-- Create indexes for faster lookups
CREATE INDEX IF NOT EXISTS idx_domain_invite_codes_code ON domain_invite_codes(code);
CREATE INDEX IF NOT EXISTS idx_domain_invite_codes_created_by ON domain_invite_codes(created_by);
CREATE INDEX IF NOT EXISTS idx_domain_invite_codes_used_by ON domain_invite_codes(used_by);

View File

@@ -0,0 +1,23 @@
CREATE TABLE dns_records (
id SERIAL PRIMARY KEY,
domain_id INTEGER NOT NULL REFERENCES domains(id) ON DELETE CASCADE,
record_type VARCHAR(10) NOT NULL CHECK (record_type IN ('A', 'AAAA', 'CNAME', 'TXT', 'MX', 'NS', 'SRV')),
name VARCHAR(255) NOT NULL DEFAULT '@', -- @ for root, or subdomain name
value VARCHAR(1000) NOT NULL,
ttl INTEGER DEFAULT 3600,
priority INTEGER, -- For MX records
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
CREATE INDEX idx_dns_records_domain_type ON dns_records(domain_id, record_type);
CREATE INDEX idx_dns_records_name ON dns_records(name);
INSERT INTO dns_records (domain_id, record_type, name, value, ttl)
SELECT id, 'A', '@', ip, 3600
FROM domains
WHERE status = 'approved';
INSERT INTO dns_records (domain_id, record_type, name, value, ttl, priority)
SELECT id, 'SRV', '_gurt._tcp', '0 5 4878 @', 3600, 0
FROM domains
WHERE status = 'approved';