From ae990cf97722a9e74c0a1b2ace327e68453ef8b8 Mon Sep 17 00:00:00 2001 From: core Date: Mon, 9 Oct 2023 20:12:44 -0400 Subject: [PATCH 01/14] cross-platform nebula build process --- nebula-ffi/build.rs | 27 ++++++++++++++++++++++----- tfclient/src/socketworker.rs | 2 ++ 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/nebula-ffi/build.rs b/nebula-ffi/build.rs index bca0dad..f17d04d 100644 --- a/nebula-ffi/build.rs +++ b/nebula-ffi/build.rs @@ -33,7 +33,7 @@ fn main() { let out = out_path.join(out_file); let mut command = process::Command::new(compiler); - command.args(["build", "-buildmode", "c-archive", "-o", out.display().to_string().as_str(), "main.go"]); + command.args(["build", "-buildmode", link_type().as_str(), "-o", out.display().to_string().as_str(), "main.go"]); command.env("CGO_ENABLED", "1"); command.env("CC", c_compiler.path()); command.env("GOARCH", goarch()); @@ -50,7 +50,7 @@ fn main() { println!("Go compile success"); - println!("cargo:rustc-link-lib=static=nebula"); + print_link(); println!("cargo:rustc-link-search=native={}", env::var("OUT_DIR").unwrap()); //let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); @@ -63,7 +63,7 @@ fn main() { println!("Generating bindings"); let bindings = bindgen::Builder::default() - .header(out_path.join("libnebula.h").display().to_string()) + .header(out_path.join(LIBRARY_PREFIX.to_owned() + "nebula.h").display().to_string()) .parse_callbacks(Box::new(CargoCallbacks)) .generate() .expect("Error generating CFFI bindings"); @@ -80,7 +80,7 @@ const LIBRARY_EXTENSION: & str = ".a"; const LIBRARY_PREFIX: & str = "lib"; #[cfg(target_family = "windows")] -const LIBRARY_EXTENSION: &str = ".lib"; +const LIBRARY_EXTENSION: &str = ".dll"; #[cfg(target_family = "windows")] const LIBRARY_PREFIX: &str = ""; @@ -109,4 +109,21 @@ fn goos() -> String { "netbsd" => "netbsd", os => panic!("unsupported operating system {os}") }.to_string() -} \ No newline at end of file +} + +#[cfg(target_family = "unix")] +fn print_link() { + println!("cargo:rustc-link-lib=static=nebula"); +} +#[cfg(target_family = "unix")] +fn link_type() -> String { + "c-archive".to_string() +} +#[cfg(target_family = "windows")] +fn print_link() { + println!("cargo:rustc-link-lib=dylib=nebula"); +} +#[cfg(target_family = "windows")] +fn link_type() -> String { + "c-shared".to_string() +} diff --git a/tfclient/src/socketworker.rs b/tfclient/src/socketworker.rs index 4927b50..9200439 100644 --- a/tfclient/src/socketworker.rs +++ b/tfclient/src/socketworker.rs @@ -124,6 +124,8 @@ fn handle_client( ) -> Result<(), io::Error> { info!("Handling connection from {}", stream.peer_addr()?); + stream.set_nonblocking(false)?; + let mut client = Client { state: ClientState::WaitHello, reader: BufReader::new(&stream), From aadd420f71061e700cc486276c9c4e9a731b1d80 Mon Sep 17 00:00:00 2001 From: core Date: Mon, 9 Oct 2023 21:24:41 -0400 Subject: [PATCH 02/14] i18n rework --- tfweb/src/lib/i18n/locales/en/2fasetup.json | 4 ++-- tfweb/src/lib/i18n/locales/en/common.json | 4 ++-- tfweb/src/lib/i18n/locales/en/hosts.json | 8 ++++---- tfweb/src/lib/i18n/locales/en/itworks.json | 4 ++-- tfweb/src/lib/i18n/locales/en/login.json | 8 ++++---- tfweb/src/lib/i18n/locales/en/networkcreate.json | 6 +++--- tfweb/src/lib/i18n/locales/en/roles.json | 6 +++--- tfweb/src/lib/i18n/locales/en/signup.json | 10 +++++----- tfweb/src/routes/+page.svelte | 4 ++-- tfweb/src/routes/2fa/+page.svelte | 2 +- tfweb/src/routes/2fasetup/+page.svelte | 2 +- tfweb/src/routes/admin/+page.svelte | 4 ++-- tfweb/src/routes/hosts/+page.svelte | 4 ++-- tfweb/src/routes/hosts/[host_id]/delete/+page.svelte | 6 +++--- tfweb/src/routes/hosts/[host_id]/enroll/+page.svelte | 8 ++++---- tfweb/src/routes/hosts/add/+page.svelte | 4 ++-- tfweb/src/routes/lighthouses/+page.svelte | 4 ++-- tfweb/src/routes/login/+page.svelte | 8 ++++---- tfweb/src/routes/magic-link/+page.svelte | 2 +- tfweb/src/routes/networkcreate/+page.svelte | 10 +++++----- tfweb/src/routes/relays/+page.svelte | 4 ++-- tfweb/src/routes/roles/+page.svelte | 4 ++-- tfweb/src/routes/roles/[role_id]/delete/+page.svelte | 6 +++--- tfweb/src/routes/roles/[role_id]/edit/+page.svelte | 6 +++--- tfweb/src/routes/roles/add/+page.svelte | 4 ++-- tfweb/src/routes/signup/+page.svelte | 10 +++++----- 26 files changed, 71 insertions(+), 71 deletions(-) diff --git a/tfweb/src/lib/i18n/locales/en/2fasetup.json b/tfweb/src/lib/i18n/locales/en/2fasetup.json index 257c9d0..941f1c5 100644 --- a/tfweb/src/lib/i18n/locales/en/2fasetup.json +++ b/tfweb/src/lib/i18n/locales/en/2fasetup.json @@ -6,8 +6,8 @@ "verify": "Verify by entering the 6-digit code shown in your authenticator into the box below.", "button": "Enable 2FA", "error": { - "generic": "Unable to enable 2fa: {err}", + "generic": "Unable to enable 2fa: {{err}}", "api": "Unable to contact the server. Try again later.", "ERR_UNAUTHORIZED": "Incorrect 2FA code" } -} \ No newline at end of file +} diff --git a/tfweb/src/lib/i18n/locales/en/common.json b/tfweb/src/lib/i18n/locales/en/common.json index 982510f..1d4c724 100644 --- a/tfweb/src/lib/i18n/locales/en/common.json +++ b/tfweb/src/lib/i18n/locales/en/common.json @@ -1,5 +1,5 @@ { - "title": "{title} | Trifid Web UI", + "title": "{{title}} | Trifid Web UI", "page": { "itworks": "It Works!", "admin": "Admin Panel", @@ -16,4 +16,4 @@ }, "logout": "Log out", "loading": "Dashboard is loading" -} \ No newline at end of file +} diff --git a/tfweb/src/lib/i18n/locales/en/hosts.json b/tfweb/src/lib/i18n/locales/en/hosts.json index ae775ee..1bd2cd3 100644 --- a/tfweb/src/lib/i18n/locales/en/hosts.json +++ b/tfweb/src/lib/i18n/locales/en/hosts.json @@ -23,14 +23,14 @@ } }, "enroll": { - "title": "Enrolling host {host}", + "title": "Enrolling host {{host}}", "explainer": "Enrolling this host will allow it to communicate on your network. You'll need to have compatible client software installed first.", "done": "Done, return me to the hosts page", "cancel": "Nevermind", - "code": "Input {code} as your enrollment code into any trifid-compatible client software to enroll. It will expire in {expires} minutes." + "code": "Input {code} as your enrollment code into any trifid-compatible client software to enroll. It will expire in {{expires}} minutes." }, "delete": { - "title": "Are you sure you want to delete the host {host}?", + "title": "Are you sure you want to delete the host {{host}}?", "explainer": "This action cannot be undone. This host will still be able to connect to the network unless you block it first.", "confirm": "I'm sure", "cancel": "Nevermind", @@ -38,4 +38,4 @@ "ERR_DB_ERROR": "Removal failed" } } -} \ No newline at end of file +} diff --git a/tfweb/src/lib/i18n/locales/en/itworks.json b/tfweb/src/lib/i18n/locales/en/itworks.json index 5006b5b..0f288e9 100644 --- a/tfweb/src/lib/i18n/locales/en/itworks.json +++ b/tfweb/src/lib/i18n/locales/en/itworks.json @@ -1,7 +1,7 @@ { "header": "It works!", "body": "If you're seeing this page, tfweb is installed and (probably) correctly configured.", - "linkbody": "Perhaps you meant to visit the {link0} or {link1}?", + "linkbody": "Perhaps you meant to visit the {{link0}} or {{link1}}?", "linkbody.link0": "admin panel", "linkbody.link1": "create an account" -} \ No newline at end of file +} diff --git a/tfweb/src/lib/i18n/locales/en/login.json b/tfweb/src/lib/i18n/locales/en/login.json index d052a10..b3d8c01 100644 --- a/tfweb/src/lib/i18n/locales/en/login.json +++ b/tfweb/src/lib/i18n/locales/en/login.json @@ -5,13 +5,13 @@ "button": "Log in", "email": "Check your email", "emailbody": "We sent you an email with a link to complete logging in.", - "emailbody2": "Didn't work? Check your junk inbox or click {link0} to try again.", + "emailbody2": "Didn't work? Check your junk inbox or click {{link0}} to try again.", "emailbody2.link0": "here", "error": { "invalidEmail": "That email address isn't valid. Try again.", - "generic": "There was an error logging you in. Try again or contact support with the error code {err}", + "generic": "There was an error logging you in. Try again or contact support with the error code {{err}}", "usermissing": "That user does not exist." }, - "need": "Don't have an account? {link0}", + "need": "Don't have an account? {{link0}}", "need.link0": "Signup" -} \ No newline at end of file +} diff --git a/tfweb/src/lib/i18n/locales/en/networkcreate.json b/tfweb/src/lib/i18n/locales/en/networkcreate.json index 7f3838a..3ec20b5 100644 --- a/tfweb/src/lib/i18n/locales/en/networkcreate.json +++ b/tfweb/src/lib/i18n/locales/en/networkcreate.json @@ -3,10 +3,10 @@ "explain": "This defines what IP addresses will be assigned to your devices. The range you enter below must fall within either the RFC 1918 Private Address Space or the RFC 6598 Shared Address Space. Enter your network via CIDR notation.", "label": "Network range", "button": "Create network", - "valid": "Valid - {numIps} addresses ({start} to {end})", + "valid": "Valid - {{numIps}} addresses ({{start}} to {{end}})", "invalid": "Invalid", "error": { - "generic": "Unable to create network: {err}", + "generic": "Unable to create network: {{err}}", "api": "Unable to contact the server. Try again later." } -} \ No newline at end of file +} diff --git a/tfweb/src/lib/i18n/locales/en/roles.json b/tfweb/src/lib/i18n/locales/en/roles.json index 5e6074e..1772561 100644 --- a/tfweb/src/lib/i18n/locales/en/roles.json +++ b/tfweb/src/lib/i18n/locales/en/roles.json @@ -1,6 +1,6 @@ { "delete": { - "title": "Are you sure you want to delete the role {rule}?", + "title": "Are you sure you want to delete the role {{rule}}?", "explainer": "This action cannot be undone. This role must be removed from all hosts, lighthouses, and relays prior to deleting it.", "confirm": "I'm sure", "cancel": "Nevermind", @@ -46,7 +46,7 @@ } }, "edit": { - "title": "Editing role {rule}", + "title": "Editing role {{rule}}", "any": "Any", "name": "Role name", "desc": "Role description", @@ -74,4 +74,4 @@ "cancel": "Cancel" } } -} \ No newline at end of file +} diff --git a/tfweb/src/lib/i18n/locales/en/signup.json b/tfweb/src/lib/i18n/locales/en/signup.json index 3ddf34a..bc60369 100644 --- a/tfweb/src/lib/i18n/locales/en/signup.json +++ b/tfweb/src/lib/i18n/locales/en/signup.json @@ -5,14 +5,14 @@ "button": "Create account", "email": "Check your email", "emailbody": "We sent you an email with a link to complete signing up.", - "emailbody2": "Didn't work? Check your junk inbox or click {link0} to try again.", + "emailbody2": "Didn't work? Check your junk inbox or click {{link0}} to try again.", "emailbody2.link0": "here", "error": { "invalidEmail": "That email address isn't valid. Try again.", - "generic": "There was an error logging you in. Try again or contact support with the error code {err}", - "userexists": "That user already exists. Try {link0}?", + "generic": "There was an error logging you in. Try again or contact support with the error code {{err}}", + "userexists": "That user already exists. Try {{link0}}?", "userexists.link0": "logging in" }, - "already": "Already have an account? {link0}", + "already": "Already have an account? {{link0}}", "already.link0": "Login" -} \ No newline at end of file +} diff --git a/tfweb/src/routes/+page.svelte b/tfweb/src/routes/+page.svelte index 439e53a..390adaa 100644 --- a/tfweb/src/routes/+page.svelte +++ b/tfweb/src/routes/+page.svelte @@ -14,12 +14,12 @@ - {$t("common.title", {values: {title: $t("common.page.admin")}})} + {$t("common.title", {title: $t("common.page.admin")})}

{$t('itworks.header')}

{$t('itworks.body')}

-

{@html $t('itworks.linkbody', {values:{link0:''+$t('itworks.linkbody.link0')+'',link1:''+$t('itworks.linkbody.link1')+''}})}

+

{@html $t('itworks.linkbody', {link0:''+$t('itworks.linkbody.link0')+'',link1:''+$t('itworks.linkbody.link1')+''})}

diff --git a/tfweb/src/routes/2fa/+page.svelte b/tfweb/src/routes/2fa/+page.svelte index 3d12337..1383d17 100644 --- a/tfweb/src/routes/2fa/+page.svelte +++ b/tfweb/src/routes/2fa/+page.svelte @@ -67,7 +67,7 @@ - {$t("common.title", {values: {title: $t("common.page.2fa")}})} + {$t("common.title", {title: $t("common.page.2fa")})} diff --git a/tfweb/src/routes/2fasetup/+page.svelte b/tfweb/src/routes/2fasetup/+page.svelte index 6100de9..6b3e8dd 100644 --- a/tfweb/src/routes/2fasetup/+page.svelte +++ b/tfweb/src/routes/2fasetup/+page.svelte @@ -102,7 +102,7 @@ - {$t("common.title", {values: {title: $t("common.page.2fasetup")}})} + {$t("common.title", {title: $t("common.page.2fasetup")})} diff --git a/tfweb/src/routes/admin/+page.svelte b/tfweb/src/routes/admin/+page.svelte index c119818..28ff1a5 100644 --- a/tfweb/src/routes/admin/+page.svelte +++ b/tfweb/src/routes/admin/+page.svelte @@ -49,7 +49,7 @@ return; } else { isError = true; - error = $t("networkcreate.error.generic", {values:{err:resp_json.errors[0].code}}); + error = $t("networkcreate.error.generic", {err:resp_json.errors[0].code}); loading = false; return; } @@ -68,7 +68,7 @@ - {$t("common.title", {values: {title: $t("common.page.admin")}})} + {$t("common.title", {title: $t("common.page.admin")})} diff --git a/tfweb/src/routes/hosts/+page.svelte b/tfweb/src/routes/hosts/+page.svelte index 49019c9..6068142 100644 --- a/tfweb/src/routes/hosts/+page.svelte +++ b/tfweb/src/routes/hosts/+page.svelte @@ -56,7 +56,7 @@ return; } else { isError = true; - error = $t("networkcreate.error.generic", {values:{err:resp_json.errors[0].code}}); + error = $t("networkcreate.error.generic", {err:resp_json.errors[0].code}); loading = false; return; } @@ -96,7 +96,7 @@ - {$t("common.title", {values: {title: $t("common.page.hosts")}})} + {$t("common.title", {title: $t("common.page.hosts")})} diff --git a/tfweb/src/routes/hosts/[host_id]/delete/+page.svelte b/tfweb/src/routes/hosts/[host_id]/delete/+page.svelte index 991883f..59f1f08 100644 --- a/tfweb/src/routes/hosts/[host_id]/delete/+page.svelte +++ b/tfweb/src/routes/hosts/[host_id]/delete/+page.svelte @@ -67,7 +67,7 @@ return; } else { isError = true; - error = $t("networkcreate.error.generic", {values:{err:resp_json.errors[0].code}}); + error = $t("networkcreate.error.generic", {err:resp_json.errors[0].code}); loading = false; return; } @@ -116,12 +116,12 @@ - {$t("common.title", {values: {title: $t("common.page.hosts")}})} + {$t("common.title", {title: $t("common.page.hosts")})} -

{$t("hosts.delete.title", {values: {host: host.data.name}})}

+

{$t("hosts.delete.title", {host: host.data.name})}

{$t("hosts.delete.explainer")}

{#if loading} diff --git a/tfweb/src/routes/hosts/[host_id]/enroll/+page.svelte b/tfweb/src/routes/hosts/[host_id]/enroll/+page.svelte index 13a2ca5..2e26504 100644 --- a/tfweb/src/routes/hosts/[host_id]/enroll/+page.svelte +++ b/tfweb/src/routes/hosts/[host_id]/enroll/+page.svelte @@ -68,7 +68,7 @@ return; } else { isError = true; - error = $t("networkcreate.error.generic", {values:{err:resp_json.errors[0].code}}); + error = $t("networkcreate.error.generic", {err:resp_json.errors[0].code}); loading = false; return; } @@ -100,17 +100,17 @@ - {$t("common.title", {values: {title: $t("common.page.hosts")}})} + {$t("common.title", {title: $t("common.page.hosts")})} -

{$t("hosts.enroll.title", {values: {host: host.data.name}})}

+

{$t("hosts.enroll.title", {host: host.data.name})}

{$t("hosts.enroll.explainer")}

{#if loading} {:else} -

{$t("hosts.enroll.code", {values:{code: code.code, expires: code.lifetimeSeconds / 60}})}

+

{$t("hosts.enroll.code", {code: code.code, expires: code.lifetimeSeconds / 60})}

{/if} diff --git a/tfweb/src/routes/hosts/add/+page.svelte b/tfweb/src/routes/hosts/add/+page.svelte index a2e0d20..f820d10 100644 --- a/tfweb/src/routes/hosts/add/+page.svelte +++ b/tfweb/src/routes/hosts/add/+page.svelte @@ -59,7 +59,7 @@ return; } else { isError = true; - error = $t("networkcreate.error.generic", {values:{err:resp_json.errors[0].code}}); + error = $t("networkcreate.error.generic", {err:resp_json.errors[0].code}); loading = false; return; } @@ -164,7 +164,7 @@ - {$t("common.title", {values: {title: $t("common.page.hosts")}})} + {$t("common.title", {title: $t("common.page.hosts")})} diff --git a/tfweb/src/routes/lighthouses/+page.svelte b/tfweb/src/routes/lighthouses/+page.svelte index a550d6f..f2f84cd 100644 --- a/tfweb/src/routes/lighthouses/+page.svelte +++ b/tfweb/src/routes/lighthouses/+page.svelte @@ -51,7 +51,7 @@ return; } else { isError = true; - error = $t("networkcreate.error.generic", {values:{err:resp_json.errors[0].code}}); + error = $t("networkcreate.error.generic", {err:resp_json.errors[0].code}); loading = false; return; } @@ -68,7 +68,7 @@ - {$t("common.title", {values: {title: $t("common.page.lighthouses")}})} + {$t("common.title", {title: $t("common.page.lighthouses")})} diff --git a/tfweb/src/routes/login/+page.svelte b/tfweb/src/routes/login/+page.svelte index fca9858..7f602bb 100644 --- a/tfweb/src/routes/login/+page.svelte +++ b/tfweb/src/routes/login/+page.svelte @@ -55,7 +55,7 @@ if (err.code == "ERR_USER_DOES_NOT_EXIST") { errForm = $t('login.error.usermissing'); } else { - errForm = $t('login.error.generic', {values: {err: (auth_result[1] as APIError).code}}); + errForm = $t('login.error.generic', {err: (auth_result[1] as APIError).code}); } loading = false; @@ -68,7 +68,7 @@ - {$t("common.title", {values: {title: $t("common.page.login")}})} + {$t("common.title", {title: $t("common.page.login")})} @@ -80,7 +80,7 @@

{$t('login.emailbody')}

-

{@html $t('login.emailbody2', {values:{link0:''+$t('login.emailbody2.link0')+''}})}

+

{@html $t('login.emailbody2', {link0:''+$t('login.emailbody2.link0')+''})}

{:else}

{$t('login.title')}

{$t('login.subtitle')}
@@ -99,7 +99,7 @@ {/if} -

{@html $t('login.need', {values:{link0:''+$t('login.need.link0')+''}})}

+

{@html $t('login.need', {link0:''+$t('login.need.link0')+''})}

{/if} diff --git a/tfweb/src/routes/magic-link/+page.svelte b/tfweb/src/routes/magic-link/+page.svelte index 5684231..01b73fc 100644 --- a/tfweb/src/routes/magic-link/+page.svelte +++ b/tfweb/src/routes/magic-link/+page.svelte @@ -45,7 +45,7 @@ - {$t("common.title", {values: {title: $t("common.page.login")}})} + {$t("common.title", {title: $t("common.page.login")})} diff --git a/tfweb/src/routes/networkcreate/+page.svelte b/tfweb/src/routes/networkcreate/+page.svelte index 6bfd48a..6fef866 100644 --- a/tfweb/src/routes/networkcreate/+page.svelte +++ b/tfweb/src/routes/networkcreate/+page.svelte @@ -47,7 +47,7 @@ let resp_json = await e.response.json(); if (resp_json.errors[0].code != "ERR_NO_ORG") { isError = true; - error = $t("networkcreate.error.generic", {values:{err:resp_json.errors[0].code}}); + error = $t("networkcreate.error.generic", {err:resp_json.errors[0].code}); loading = false; return; } @@ -63,7 +63,7 @@ let cidr = "100.100.0.0/22"; let valid = true; - let sub = $t("networkcreate.valid", {values:{numIps:$number(1024), start: "100.64.0.0", end: "100.127.255.255"}}) + let sub = $t("networkcreate.valid", {numIps:$number(1024), start: "100.64.0.0", end: "100.127.255.255"}) const regex = new RegExp(/^([0-9]{1,3}\.){3}[0-9]{1,3}(\/([0-9]|[1-2][0-9]|3[0-2]))?$/im); @@ -138,7 +138,7 @@ let first = [first_num >>> 24 & 0xFF, first_num >>> 16 & 0xFF, first_num >>> 8 & 0xFF, first_num & 0xFF].join("."); let last = [last_num >>> 24 & 0xFF, last_num >>> 16 & 0xFF, last_num >>> 8 & 0xFF, last_num & 0xFF].join("."); - sub = $t("networkcreate.valid", {values:{numIps:$number(addressCount), start: first, end: last}}); + sub = $t("networkcreate.valid", {numIps:$number(addressCount), start: first, end: last}); valid = true; } @@ -161,7 +161,7 @@ return; } - error = $t('networkcreate.error.generic', {values:{err:etext}}); + error = $t('networkcreate.error.generic', {err:etext}); loading = false; return; } @@ -173,7 +173,7 @@ - {$t("common.title", {values: {title: $t("common.page.networkcreate")}})} + {$t("common.title", {title: $t("common.page.networkcreate")})} diff --git a/tfweb/src/routes/relays/+page.svelte b/tfweb/src/routes/relays/+page.svelte index 2f15e96..444f3af 100644 --- a/tfweb/src/routes/relays/+page.svelte +++ b/tfweb/src/routes/relays/+page.svelte @@ -51,7 +51,7 @@ return; } else { isError = true; - error = $t("networkcreate.error.generic", {values:{err:resp_json.errors[0].code}}); + error = $t("networkcreate.error.generic", {err:resp_json.errors[0].code}); loading = false; return; } @@ -68,7 +68,7 @@ - {$t("common.title", {values: {title: $t("common.page.relays")}})} + {$t("common.title", {title: $t("common.page.relays")})} diff --git a/tfweb/src/routes/roles/+page.svelte b/tfweb/src/routes/roles/+page.svelte index 898532d..ad982d2 100644 --- a/tfweb/src/routes/roles/+page.svelte +++ b/tfweb/src/routes/roles/+page.svelte @@ -53,7 +53,7 @@ return; } else { isError = true; - error = $t("networkcreate.error.generic", {values:{err:resp_json.errors[0].code}}); + error = $t("networkcreate.error.generic", {err:resp_json.errors[0].code}); loading = false; return; } @@ -80,7 +80,7 @@ - {$t("common.title", {values: {title: $t("common.page.roles")}})} + {$t("common.title", {title: $t("common.page.roles")})} diff --git a/tfweb/src/routes/roles/[role_id]/delete/+page.svelte b/tfweb/src/routes/roles/[role_id]/delete/+page.svelte index 183acbe..5d13428 100644 --- a/tfweb/src/routes/roles/[role_id]/delete/+page.svelte +++ b/tfweb/src/routes/roles/[role_id]/delete/+page.svelte @@ -68,7 +68,7 @@ return; } else { isError = true; - error = $t("networkcreate.error.generic", {values:{err:resp_json.errors[0].code}}); + error = $t("networkcreate.error.generic", {err:resp_json.errors[0].code}); loading = false; return; } @@ -117,12 +117,12 @@ - {$t("common.title", {values: {title: $t("common.page.roles")}})} + {$t("common.title", {title: $t("common.page.roles")})} -

{$t("roles.delete.title", {values: {rule: role.data.name}})}

+

{$t("roles.delete.title", {rule: role.data.name})}

{$t("roles.delete.explainer")}

{#if loading} diff --git a/tfweb/src/routes/roles/[role_id]/edit/+page.svelte b/tfweb/src/routes/roles/[role_id]/edit/+page.svelte index 625afab..d96f4c9 100644 --- a/tfweb/src/routes/roles/[role_id]/edit/+page.svelte +++ b/tfweb/src/routes/roles/[role_id]/edit/+page.svelte @@ -276,7 +276,7 @@ return; } else { isError = true; - error = $t("networkcreate.error.generic", {values:{err:resp_json.errors[0].code}}); + error = $t("networkcreate.error.generic", {err:resp_json.errors[0].code}); loading = false; return; } @@ -346,12 +346,12 @@ - {$t("common.title", {values: {title: $t("common.page.roles")}})} + {$t("common.title", {title: $t("common.page.roles")})} -

{$t("roles.edit.title", {values: {rule: roleName}})}

+

{$t("roles.edit.title", {rule: roleName})}

diff --git a/tfweb/src/routes/roles/add/+page.svelte b/tfweb/src/routes/roles/add/+page.svelte index 29a8b14..5a28983 100644 --- a/tfweb/src/routes/roles/add/+page.svelte +++ b/tfweb/src/routes/roles/add/+page.svelte @@ -58,7 +58,7 @@ return; } else { isError = true; - error = $t("networkcreate.error.generic", {values:{err:resp_json.errors[0].code}}); + error = $t("networkcreate.error.generic", {err:resp_json.errors[0].code}); loading = false; return; } @@ -306,7 +306,7 @@ - {$t("common.title", {values: {title: $t("common.page.roles")}})} + {$t("common.title", {title: $t("common.page.roles")})} diff --git a/tfweb/src/routes/signup/+page.svelte b/tfweb/src/routes/signup/+page.svelte index 0f4eff5..c425d71 100644 --- a/tfweb/src/routes/signup/+page.svelte +++ b/tfweb/src/routes/signup/+page.svelte @@ -53,9 +53,9 @@ let err = auth_result[1] as APIError; if (err.code == "ERR_USER_EXISTS") { - errForm = $t('signup.error.userexists', {values:{link0:''+$t('signup.error.userexists.link0')+''}}); + errForm = $t('signup.error.userexists', {link0:''+$t('signup.error.userexists.link0')+''}); } else { - errForm = $t('signup.error.generic', {values: {err: (auth_result[1] as APIError).code}}); + errForm = $t('signup.error.generic', {err: (auth_result[1] as APIError).code}); } loading = false; @@ -68,7 +68,7 @@ - {$t("common.title", {values: {title: $t("common.page.signup")}})} + {$t("common.title", {title: $t("common.page.signup")})} @@ -80,7 +80,7 @@

{$t('signup.emailbody')}

-

{@html $t('signup.emailbody2', {values:{link0:''+$t('signup.emailbody2.link0')+''}})}

+

{@html $t('signup.emailbody2', {link0:''+$t('signup.emailbody2.link0')+''})}

{:else}

{$t('signup.title')}

{$t('signup.subtitle')}
@@ -100,7 +100,7 @@ {/if} -

{@html $t('signup.already', {values:{link0:''+$t('signup.already.link0')+''}})}

+

{@html $t('signup.already', {link0:''+$t('signup.already.link0')+''})}

{/if} From 31229a117292a97add092924f4f2236ed653bf2a Mon Sep 17 00:00:00 2001 From: core Date: Mon, 9 Oct 2023 21:30:56 -0400 Subject: [PATCH 03/14] finish i18n & build --- .gitignore | 1 + tfweb/package.json | 1 + tfweb/src/components/AdminLayout.svelte | 3 +- tfweb/src/components/Sidebar.svelte | 2 +- .../lib/i18n/locales/en/networkcreate.json | 2 +- tfweb/src/routes/networkcreate/+page.svelte | 6 +- tfweb/svelte.config.js | 2 +- tfweb/yarn.lock | 159 +++++++++++++++++- 8 files changed, 167 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 52e52a0..26d0056 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ packages/void_amd64_tfclient/work packages/void_amd64_tfclient/*.xbps *.pem *.xbps +tfweb/build diff --git a/tfweb/package.json b/tfweb/package.json index 79fb14c..4cad20e 100644 --- a/tfweb/package.json +++ b/tfweb/package.json @@ -12,6 +12,7 @@ }, "devDependencies": { "@sveltejs/adapter-auto": "^2.0.0", + "@sveltejs/adapter-node": "^1.3.1", "@sveltejs/kit": "^1.5.0", "@typescript-eslint/eslint-plugin": "^5.45.0", "@typescript-eslint/parser": "^5.45.0", diff --git a/tfweb/src/components/AdminLayout.svelte b/tfweb/src/components/AdminLayout.svelte index e5cfada..00f10db 100644 --- a/tfweb/src/components/AdminLayout.svelte +++ b/tfweb/src/components/AdminLayout.svelte @@ -1,5 +1,4 @@ diff --git a/tfweb/src/lib/i18n/locales/en/networkcreate.json b/tfweb/src/lib/i18n/locales/en/networkcreate.json index 3ec20b5..5268d80 100644 --- a/tfweb/src/lib/i18n/locales/en/networkcreate.json +++ b/tfweb/src/lib/i18n/locales/en/networkcreate.json @@ -3,7 +3,7 @@ "explain": "This defines what IP addresses will be assigned to your devices. The range you enter below must fall within either the RFC 1918 Private Address Space or the RFC 6598 Shared Address Space. Enter your network via CIDR notation.", "label": "Network range", "button": "Create network", - "valid": "Valid - {{numIps}} addresses ({{start}} to {{end}})", + "valid": "Valid - {{numIps:number}} addresses ({{start}} to {{end}})", "invalid": "Invalid", "error": { "generic": "Unable to create network: {{err}}", diff --git a/tfweb/src/routes/networkcreate/+page.svelte b/tfweb/src/routes/networkcreate/+page.svelte index 6fef866..b403fe7 100644 --- a/tfweb/src/routes/networkcreate/+page.svelte +++ b/tfweb/src/routes/networkcreate/+page.svelte @@ -1,5 +1,5 @@ diff --git a/tfweb/src/routes/+layout.ts b/tfweb/src/routes/+layout.ts index 5e907ba..e675e5a 100644 --- a/tfweb/src/routes/+layout.ts +++ b/tfweb/src/routes/+layout.ts @@ -1,9 +1,21 @@ import type { LayoutLoad } from './$types' import {loadTranslations} from "$lib/i18n/translations"; +import {browser} from "$app/environment"; export const load: LayoutLoad = async ({url}) => { const { pathname } = url; - const initLocale = 'en'; + + let locale = 'en'; + + // determine locale + if (browser) { + if (window.localStorage.getItem("locale") != null) { + locale = window.localStorage.getItem("locale"); + } + window.localStorage.setItem("locale", locale); + } + + const initLocale = locale; await loadTranslations(initLocale, pathname); return {}; } diff --git a/tfweb/src/routes/hosts/+page.svelte b/tfweb/src/routes/hosts/+page.svelte index 6068142..89fa2d3 100644 --- a/tfweb/src/routes/hosts/+page.svelte +++ b/tfweb/src/routes/hosts/+page.svelte @@ -10,6 +10,7 @@ import type {Host} from "$lib/api/models/Host.ts"; import type {Role} from "$lib/api/models/Role.ts"; import AdminLayout from "$components/AdminLayout.svelte"; + import {updateTooltips} from "$lib/Tooltips"; let loading = true; let isError = false; @@ -83,6 +84,7 @@ roles = (await rolesApi.rolesList()).data!; loading = false; + updateTooltips(); }); function getRoleName(byId: string): string { @@ -118,16 +120,22 @@ {#each hosts as host} {#if !(host.isLighthouse || host.isRelay)} - {host.name} + + {host.name} + {#if host.isBlocked} + Blocked + {/if} + {host.metadata?.lastSeenAt} {host.ipAddress} {getRoleName(host.roleID)}
- - - - + + + + +
diff --git a/tfweb/src/routes/hosts/[host_id]/block/+page.svelte b/tfweb/src/routes/hosts/[host_id]/block/+page.svelte new file mode 100644 index 0000000..8c0c776 --- /dev/null +++ b/tfweb/src/routes/hosts/[host_id]/block/+page.svelte @@ -0,0 +1,136 @@ + + + + {$t("common.title", {title: $t("common.page.hosts")})} + + + + +

{$t("hosts.block.title", {host: host.data.name})}

+

{$t("hosts.block.explainer")}

+ {#if loading} + + {:else} + + {/if} + + {#if hasFormErr} +

{formErr}

+ {/if} +
+
diff --git a/tfweb/src/routes/roles/+page.svelte b/tfweb/src/routes/roles/+page.svelte index ad982d2..d7e2cb5 100644 --- a/tfweb/src/routes/roles/+page.svelte +++ b/tfweb/src/routes/roles/+page.svelte @@ -8,6 +8,7 @@ import {PUBLIC_BASE_URL} from "$env/static/public"; import {Configuration, NetworksApi, RolesApi} from "$lib/api"; import AdminLayout from "$components/AdminLayout.svelte"; + import {updateTooltips} from "$lib/Tooltips"; let loading = true; let isError = false; @@ -71,6 +72,7 @@ console.log(roles); loading = false; + updateTooltips(); }) async function roleAdd() { @@ -115,8 +117,8 @@ {role.description}
- - + +
From 6cebc0cef0c5529ba77bc33a9daade84f3d6deea Mon Sep 17 00:00:00 2001 From: core Date: Tue, 10 Oct 2023 14:54:59 -0400 Subject: [PATCH 11/14] officially the worlds dumbest bug. [trifid-api/0.2.3] --- trifid-api/Cargo.toml | 2 +- trifid-api/src/routes/v1/dnclient.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/trifid-api/Cargo.toml b/trifid-api/Cargo.toml index 27be92e..eae1626 100644 --- a/trifid-api/Cargo.toml +++ b/trifid-api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "trifid-api" -version = "0.2.2" +version = "0.2.3" edition = "2021" description = "Pure-rust Defined Networking compatible management server" license = "GPL-3.0-or-later" diff --git a/trifid-api/src/routes/v1/dnclient.rs b/trifid-api/src/routes/v1/dnclient.rs index 8ed8cfc..828bdd6 100644 --- a/trifid-api/src/routes/v1/dnclient.rs +++ b/trifid-api/src/routes/v1/dnclient.rs @@ -232,7 +232,7 @@ pub async fn dnclient( } }; - let mut config_is_different = current_cfg == cfg; + let mut config_is_different = current_cfg != cfg; if config_is_different { // check if it is a certificate issue From 45c8ad59134e19ea9d980c28d44cc9d61856e444 Mon Sep 17 00:00:00 2001 From: core Date: Tue, 10 Oct 2023 17:42:36 -0400 Subject: [PATCH 12/14] Update .forgejo/workflows/tfclient.yml --- .forgejo/workflows/tfclient.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/tfclient.yml b/.forgejo/workflows/tfclient.yml index 5923600..ab5349e 100644 --- a/.forgejo/workflows/tfclient.yml +++ b/.forgejo/workflows/tfclient.yml @@ -50,7 +50,7 @@ jobs: uses: https://github.com/actions-rs/cargo@v1 with: command: build - args: --release --bin tfclient + args: --release --bin tfclient --target aarch64-unknown-linux-gnu - name: Upload binary run: sshpass -p "${{ secrets.TRIFID_DLCDN_PASSWORD }}" rsync --mkpath -e 'ssh -p ${{ secrets.TRIFID_DLCDN_PORT }} -o StrictHostKeyChecking=no' target/release/tfclient ${{ secrets.TRIFID_DLCDN_USER }}@${{ secrets.TRIFID_DLCDN_IP }}:${{ secrets.TRIFID_DLCDN_PATH }}/tfclient/arm64/$GITHUB_SHA/tfclient build_win64: From e94ad5a5e61c9f8370c20ec7d10494ab2d2807d6 Mon Sep 17 00:00:00 2001 From: core Date: Tue, 10 Oct 2023 17:45:13 -0400 Subject: [PATCH 13/14] Update .forgejo/workflows/tfclient.yml --- .forgejo/workflows/tfclient.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.forgejo/workflows/tfclient.yml b/.forgejo/workflows/tfclient.yml index ab5349e..f125766 100644 --- a/.forgejo/workflows/tfclient.yml +++ b/.forgejo/workflows/tfclient.yml @@ -22,6 +22,8 @@ jobs: override: true - name: Install additional dependencies run: apt update && apt-get install -y libclang-dev clang sshpass rsync + - name: Install aarch64 target + run: rustup target add aarch64-unknown-linux-gnu - name: Compile release binary uses: https://github.com/actions-rs/cargo@v1 with: From d5c0b6461a82ef40b2f85a6c316aae8b7d062c17 Mon Sep 17 00:00:00 2001 From: core Date: Tue, 10 Oct 2023 17:52:55 -0400 Subject: [PATCH 14/14] Update .forgejo/workflows/tfclient.yml --- .forgejo/workflows/tfclient.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.forgejo/workflows/tfclient.yml b/.forgejo/workflows/tfclient.yml index f125766..df04c67 100644 --- a/.forgejo/workflows/tfclient.yml +++ b/.forgejo/workflows/tfclient.yml @@ -22,8 +22,6 @@ jobs: override: true - name: Install additional dependencies run: apt update && apt-get install -y libclang-dev clang sshpass rsync - - name: Install aarch64 target - run: rustup target add aarch64-unknown-linux-gnu - name: Compile release binary uses: https://github.com/actions-rs/cargo@v1 with: @@ -46,6 +44,8 @@ jobs: profile: minimal toolchain: stable override: true + - name: Install aarch64 target + run: rustup target add aarch64-unknown-linux-gnu - name: Install additional dependencies run: apt update && apt-get install -y libclang-dev clang sshpass rsync - name: Compile release binary