forked from github-starred/komodo
tweaks
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -3302,6 +3302,7 @@ dependencies = [
|
|||||||
"serde_json",
|
"serde_json",
|
||||||
"snow",
|
"snow",
|
||||||
"spki",
|
"spki",
|
||||||
|
"tracing",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|||||||
@@ -28,7 +28,10 @@ use crate::{
|
|||||||
config::core_config,
|
config::core_config,
|
||||||
helpers::periphery_client,
|
helpers::periphery_client,
|
||||||
monitor::{alert::check_alerts, record::record_server_stats},
|
monitor::{alert::check_alerts, record::record_server_stats},
|
||||||
state::{db_client, deployment_status_cache, repo_status_cache},
|
state::{
|
||||||
|
db_client, deployment_status_cache, periphery_connections,
|
||||||
|
repo_status_cache,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
use self::helpers::{
|
use self::helpers::{
|
||||||
@@ -174,6 +177,7 @@ pub async fn update_cache_for_server(server: &Server, force: bool) {
|
|||||||
None,
|
None,
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
periphery_connections().remove(&server.id).await;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use database::mungos::mongodb::{Collection, bson::doc};
|
use database::mungos::mongodb::{Collection, bson::doc};
|
||||||
use formatting::format_serror;
|
|
||||||
use indexmap::IndexSet;
|
use indexmap::IndexSet;
|
||||||
use komodo_client::entities::{
|
use komodo_client::entities::{
|
||||||
Operation, ResourceTarget, ResourceTargetVariant, komodo_timestamp,
|
Operation, ResourceTarget, ResourceTargetVariant, komodo_timestamp,
|
||||||
@@ -18,9 +17,7 @@ use komodo_client::entities::{
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
config::core_config,
|
config::core_config,
|
||||||
connection::PeripheryConnectionArgs,
|
|
||||||
monitor::update_cache_for_server,
|
monitor::update_cache_for_server,
|
||||||
periphery::PeripheryClient,
|
|
||||||
state::{
|
state::{
|
||||||
action_states, db_client, periphery_connections,
|
action_states, db_client, periphery_connections,
|
||||||
server_status_cache,
|
server_status_cache,
|
||||||
@@ -164,29 +161,8 @@ impl super::KomodoResource for Server {
|
|||||||
|
|
||||||
async fn post_update(
|
async fn post_update(
|
||||||
updated: &Self,
|
updated: &Self,
|
||||||
update: &mut Update,
|
_update: &mut Update,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
if updated.config.enabled {
|
|
||||||
// Init periphery client to trigger reconnection
|
|
||||||
// if relevant parameters change.
|
|
||||||
if let Err(e) = PeripheryClient::new(
|
|
||||||
PeripheryConnectionArgs::from_server(updated),
|
|
||||||
&updated.config.passkey,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.with_context(|| {
|
|
||||||
format!(
|
|
||||||
"Failed to get client handle after update for Server {}",
|
|
||||||
updated.id
|
|
||||||
)
|
|
||||||
}) {
|
|
||||||
warn!("{e:#}");
|
|
||||||
update
|
|
||||||
.push_simple_log("Post Update", format_serror(&e.into()));
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
periphery_connections().remove(&updated.id).await;
|
|
||||||
}
|
|
||||||
update_cache_for_server(updated, true).await;
|
update_cache_for_server(updated, true).await;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ import { HoverCard, HoverCardContent, HoverCardTrigger } from "@ui/hover-card";
|
|||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogContent,
|
DialogContent,
|
||||||
DialogDescription,
|
|
||||||
DialogFooter,
|
DialogFooter,
|
||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
@@ -435,56 +434,54 @@ export const ServerComponents: RequiredResourceComponents = {
|
|||||||
if (!server?.info.attempted_public_key) return null;
|
if (!server?.info.attempted_public_key) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tooltip>
|
<Dialog open={open} onOpenChange={setOpen}>
|
||||||
<TooltipTrigger>
|
<DialogTrigger disabled={!canWrite}>
|
||||||
<Dialog open={open} onOpenChange={setOpen}>
|
<Card
|
||||||
<DialogTrigger disabled={!canWrite}>
|
className={cn(
|
||||||
<Card className="px-3 py-2 bg-destructive/75 hover:bg-destructive transition-colors cursor-pointer">
|
"px-3 py-2 bg-destructive/75 hover:bg-destructive transition-colors",
|
||||||
<div className="text-sm text-nowrap overflow-hidden overflow-ellipsis">
|
canWrite && "cursor-pointer"
|
||||||
Invalid Pubkey
|
)}
|
||||||
</div>
|
>
|
||||||
</Card>
|
<div className="text-sm text-nowrap overflow-hidden overflow-ellipsis">
|
||||||
</DialogTrigger>
|
Invalid Pubkey
|
||||||
<DialogContent className="w-[90vw] max-w-[700px]">
|
</div>
|
||||||
<DialogHeader>
|
</Card>
|
||||||
<DialogTitle>Confirm {server.name} public key?</DialogTitle>
|
</DialogTrigger>
|
||||||
<DialogDescription>
|
<DialogContent className="w-[90vw] max-w-[700px]">
|
||||||
Public Key: {server.info.attempted_public_key}
|
<DialogHeader>
|
||||||
</DialogDescription>
|
<DialogTitle>Confirm {server.name} public key?</DialogTitle>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
<div></div>
|
<div className="text-muted-foreground text-sm">
|
||||||
<DialogFooter>
|
<div>
|
||||||
<Button
|
Public Key: <span className="text-foreground">{server.info.attempted_public_key}</span>
|
||||||
className="w-[200px]"
|
</div>
|
||||||
variant="secondary"
|
{!server.info.address && (
|
||||||
onClick={() =>
|
<div>Note. May take a few moments for status to update.</div>
|
||||||
mutate({
|
)}
|
||||||
id,
|
|
||||||
config: {
|
|
||||||
periphery_public_key:
|
|
||||||
server.info.attempted_public_key,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
disabled={isPending}
|
|
||||||
>
|
|
||||||
{isPending ? (
|
|
||||||
<Loader2 className="w-4 h-4 animate-spin" />
|
|
||||||
) : (
|
|
||||||
"Confirm"
|
|
||||||
)}
|
|
||||||
</Button>
|
|
||||||
</DialogFooter>
|
|
||||||
</DialogContent>
|
|
||||||
</Dialog>
|
|
||||||
</TooltipTrigger>
|
|
||||||
<TooltipContent>
|
|
||||||
<div className="grid gap-2">
|
|
||||||
Core failed to validate Periphery public key.
|
|
||||||
{canWrite ? " Click to validate." : ""}
|
|
||||||
</div>
|
</div>
|
||||||
</TooltipContent>
|
<DialogFooter>
|
||||||
</Tooltip>
|
<Button
|
||||||
|
className="w-[200px]"
|
||||||
|
variant="secondary"
|
||||||
|
onClick={() =>
|
||||||
|
mutate({
|
||||||
|
id,
|
||||||
|
config: {
|
||||||
|
periphery_public_key: server.info.attempted_public_key,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
disabled={isPending}
|
||||||
|
>
|
||||||
|
{isPending ? (
|
||||||
|
<Loader2 className="w-4 h-4 animate-spin" />
|
||||||
|
) : (
|
||||||
|
"Confirm"
|
||||||
|
)}
|
||||||
|
</Button>
|
||||||
|
</DialogFooter>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ komodo_client.workspace = true
|
|||||||
pem-rfc7468.workspace = true
|
pem-rfc7468.workspace = true
|
||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
colored.workspace = true
|
colored.workspace = true
|
||||||
|
tracing.workspace = true
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
base64.workspace = true
|
base64.workspace = true
|
||||||
pkcs8.workspace = true
|
pkcs8.workspace = true
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ impl Pkcs8PrivateKey {
|
|||||||
path: P,
|
path: P,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
let path = path.as_ref();
|
let path = path.as_ref();
|
||||||
|
tracing::info!("Writing private key to {path:?}");
|
||||||
std::fs::write(path, self.as_pem()).with_context(|| {
|
std::fs::write(path, self.as_pem()).with_context(|| {
|
||||||
format!("Failed to write private key pem to {path:?}")
|
format!("Failed to write private key pem to {path:?}")
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ impl SpkiPublicKey {
|
|||||||
path: P,
|
path: P,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
let path = path.as_ref();
|
let path = path.as_ref();
|
||||||
|
tracing::info!("Writing public key to {path:?}");
|
||||||
std::fs::write(path, self.as_pem()).with_context(|| {
|
std::fs::write(path, self.as_pem()).with_context(|| {
|
||||||
format!("Failed to write private key pem to {path:?}")
|
format!("Failed to write private key pem to {path:?}")
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user