diff --git a/.gitignore b/.gitignore index 92a146e..bb782b7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *target* *.pem -*gurty.toml \ No newline at end of file +gurty.toml +certs \ No newline at end of file diff --git a/dns/Cargo.lock b/dns/Cargo.lock index 2685d98..82947c7 100644 --- a/dns/Cargo.lock +++ b/dns/Cargo.lock @@ -797,6 +797,21 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + [[package]] name = "form_urlencoded" version = "1.2.1" @@ -1545,12 +1560,50 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "openssl" +version = "0.10.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8505734d46c8ab1e19a1dce3aef597ad87dcb4c37e7188231769bd6bd51cebf8" +dependencies = [ + "bitflags 2.9.2", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + [[package]] name = "openssl-probe" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" +[[package]] +name = "openssl-sys" +version = "0.9.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90096e2e47630d78b7d1c20952dc621f957103f8bc2c8359ec81290d75238571" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "parking_lot" version = "0.12.3" @@ -3082,6 +3135,9 @@ name = "uuid" version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" +dependencies = [ + "getrandom", +] [[package]] name = "uwl" @@ -3250,6 +3306,7 @@ name = "webx_dns" version = "0.0.1" dependencies = [ "anyhow", + "base64 0.22.1", "bcrypt", "chrono", "clap", @@ -3260,6 +3317,7 @@ dependencies = [ "jsonwebtoken", "log", "macros-rs", + "openssl", "pretty_env_logger", "prettytable", "rand", @@ -3267,9 +3325,11 @@ dependencies = [ "serde", "serde_json", "serenity", + "sha2", "sqlx", "tokio", "toml", + "uuid", ] [[package]] diff --git a/dns/Cargo.toml b/dns/Cargo.toml index ddd75d3..17c96dc 100644 --- a/dns/Cargo.toml +++ b/dns/Cargo.toml @@ -26,3 +26,7 @@ clap = { version = "4.5.4", features = ["derive"] } rand = { version = "0.8.5", features = ["small_rng"] } serde = { version = "1.0.203", features = ["derive"] } serde_json = "1.0" +sha2 = "0.10" +base64 = "0.22" +uuid = { version = "1.0", features = ["v4"] } +openssl = "0.10" diff --git a/dns/frontend/domain.html b/dns/frontend/domain.html index 1270cc2..43be10e 100644 --- a/dns/frontend/domain.html +++ b/dns/frontend/domain.html @@ -116,7 +116,6 @@ -
@@ -131,7 +130,6 @@ Enter an IPv6 address (e.g., 2001:db8::1) Enter a domain name (e.g., example.com) Enter any text content - Enter a nameserver domain (e.g., ns1.example.com)
diff --git a/dns/frontend/domain.lua b/dns/frontend/domain.lua index 19c49ed..986cc9a 100644 --- a/dns/frontend/domain.lua +++ b/dns/frontend/domain.lua @@ -131,7 +131,7 @@ renderRecords = function(appendOnly) local typeCell = gurt.create('div', { text = record.type, style = 'font-bold' }) local nameCell = gurt.create('div', { text = record.name or '@' }) local valueCell = gurt.create('div', { text = record.value, style = 'font-mono text-sm break-all' }) - local ttlCell = gurt.create('div', { text = record.ttl or '3600' }) + local ttlCell = gurt.create('div', { text = record.ttl or 'none' }) local actionsCell = gurt.create('div') local deleteBtn = gurt.create('button', { @@ -227,16 +227,10 @@ end local function addRecord(type, name, value, ttl) hideError('record-error') - print('Adding DNS record: ' .. type .. ' ' .. name .. ' ' .. value) - print('Network request details:') - print(' URL: gurt://localhost:8877/domain/' .. domainName .. '/records') - print(' Method: POST') - print(' Auth token: ' .. (authToken and 'present' or 'missing')) - print(' Domain name: ' .. (domainName or 'nil')) - + local response = fetch('gurt://localhost:8877/domain/' .. domainName .. '/records', { method = 'POST', - headers = { + headers = { ['Content-Type'] = 'application/json', Authorization = 'Bearer ' .. authToken }, @@ -248,38 +242,24 @@ local function addRecord(type, name, value, ttl) }) }) - print('Response received: ' .. tostring(response)) - if response then - print('Response status: ' .. tostring(response.status)) - print('Response ok: ' .. tostring(response:ok())) - if response:ok() then - print('DNS record added successfully') - - -- Clear form gurt.select('#record-name').value = '' gurt.select('#record-value').value = '' - gurt.select('#record-ttl').value = '3600' + gurt.select('#record-ttl').value = '' - -- Add the new record to existing records array local newRecord = response:json() if newRecord and newRecord.id then - -- Server returned the created record, add it to our local array table.insert(records, newRecord) - -- Check if we had no records before (showing empty message) - local wasEmpty = (#records == 1) -- If this is the first record + local wasEmpty = (#records == 1) if wasEmpty then - -- Full re-render to replace empty message with proper table renderRecords(false) else - -- Just append the new record to existing table renderRecords(true) end else - -- Server didn't return record details, reload to get the actual data loadRecords() end else @@ -288,7 +268,6 @@ local function addRecord(type, name, value, ttl) print('Failed to add DNS record: ' .. error) end else - print('No response received from server') showError('record-error', 'No response from server - connection failed') print('Failed to add DNS record: No response') end @@ -310,7 +289,7 @@ local function updateHelpText() local recordType = gurt.select('#record-type').value -- Hide all help texts - local helpTypes = {'A', 'AAAA', 'CNAME', 'TXT', 'NS'} + local helpTypes = {'A', 'AAAA', 'CNAME', 'TXT'} for _, helpType in ipairs(helpTypes) do local helpElement = gurt.select('#help-' .. helpType) if helpElement then @@ -330,7 +309,7 @@ local function updateHelpText() valueInput.placeholder = '192.168.1.1' elseif recordType == 'AAAA' then valueInput.placeholder = '2001:db8::1' - elseif recordType == 'CNAME' or recordType == 'NS' then + elseif recordType == 'CNAME' then valueInput.placeholder = 'example.com' elseif recordType == 'TXT' then valueInput.placeholder = 'Any text content' @@ -346,7 +325,7 @@ gurt.select('#add-record-btn'):on('click', function() local recordType = gurt.select('#record-type').value local recordName = gurt.select('#record-name').value local recordValue = gurt.select('#record-value').value - local recordTTL = tonumber(gurt.select('#record-ttl').value) or 3600 + local recordTTL = tonumber(gurt.select('#record-ttl').value) or '' if not recordValue or recordValue == '' then showError('record-error', 'Record value is required') diff --git a/dns/frontend/index.html b/dns/frontend/index.html index 49cf136..d97961d 100644 --- a/dns/frontend/index.html +++ b/dns/frontend/index.html @@ -47,7 +47,7 @@ -

Don't have an account? Register here

+

Don't have an account? Register here

diff --git a/dns/frontend/signup.html b/dns/frontend/signup.html new file mode 100644 index 0000000..e86ade0 --- /dev/null +++ b/dns/frontend/signup.html @@ -0,0 +1,68 @@ + + Sign Up + + + + + + + + +