deploy 2.0.0-dev-54

This commit is contained in:
mbecker20
2025-10-13 13:06:23 -07:00
parent 41ce86f6ab
commit 50b9f2e1bf
9 changed files with 79 additions and 62 deletions

40
Cargo.lock generated
View File

@@ -926,7 +926,7 @@ dependencies = [
[[package]]
name = "cache"
version = "2.0.0-dev-53"
version = "2.0.0-dev-54"
dependencies = [
"anyhow",
"tokio",
@@ -1118,7 +1118,7 @@ dependencies = [
[[package]]
name = "command"
version = "2.0.0-dev-53"
version = "2.0.0-dev-54"
dependencies = [
"komodo_client",
"run_command",
@@ -1144,7 +1144,7 @@ checksum = "e47641d3deaf41fb1538ac1f54735925e275eaf3bf4d55c81b137fba797e5cbb"
[[package]]
name = "config"
version = "2.0.0-dev-53"
version = "2.0.0-dev-54"
dependencies = [
"colored",
"indexmap 2.11.4",
@@ -1429,7 +1429,7 @@ checksum = "2a2330da5de22e8a3cb63252ce2abb30116bf5265e89c0e01bc17015ce30a476"
[[package]]
name = "database"
version = "2.0.0-dev-53"
version = "2.0.0-dev-54"
dependencies = [
"anyhow",
"async-compression",
@@ -1707,7 +1707,7 @@ dependencies = [
[[package]]
name = "encoding"
version = "2.0.0-dev-53"
version = "2.0.0-dev-54"
dependencies = [
"anyhow",
"bytes",
@@ -1749,7 +1749,7 @@ dependencies = [
[[package]]
name = "environment"
version = "2.0.0-dev-53"
version = "2.0.0-dev-54"
dependencies = [
"anyhow",
"formatting",
@@ -1759,7 +1759,7 @@ dependencies = [
[[package]]
name = "environment_file"
version = "2.0.0-dev-53"
version = "2.0.0-dev-54"
dependencies = [
"thiserror 2.0.17",
]
@@ -1855,7 +1855,7 @@ dependencies = [
[[package]]
name = "formatting"
version = "2.0.0-dev-53"
version = "2.0.0-dev-54"
dependencies = [
"serror",
]
@@ -2027,7 +2027,7 @@ checksum = "e629b9b98ef3dd8afe6ca2bd0f89306cec16d43d907889945bc5d6687f2f13c7"
[[package]]
name = "git"
version = "2.0.0-dev-53"
version = "2.0.0-dev-54"
dependencies = [
"anyhow",
"cache",
@@ -2615,7 +2615,7 @@ dependencies = [
[[package]]
name = "interpolate"
version = "2.0.0-dev-53"
version = "2.0.0-dev-54"
dependencies = [
"anyhow",
"komodo_client",
@@ -2748,7 +2748,7 @@ dependencies = [
[[package]]
name = "komodo_cli"
version = "2.0.0-dev-53"
version = "2.0.0-dev-54"
dependencies = [
"anyhow",
"chrono",
@@ -2774,7 +2774,7 @@ dependencies = [
[[package]]
name = "komodo_client"
version = "2.0.0-dev-53"
version = "2.0.0-dev-54"
dependencies = [
"anyhow",
"async_timing_util",
@@ -2810,7 +2810,7 @@ dependencies = [
[[package]]
name = "komodo_core"
version = "2.0.0-dev-53"
version = "2.0.0-dev-54"
dependencies = [
"anyhow",
"arc-swap",
@@ -2883,7 +2883,7 @@ dependencies = [
[[package]]
name = "komodo_periphery"
version = "2.0.0-dev-53"
version = "2.0.0-dev-54"
dependencies = [
"anyhow",
"arc-swap",
@@ -3003,7 +3003,7 @@ checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432"
[[package]]
name = "logger"
version = "2.0.0-dev-53"
version = "2.0.0-dev-54"
dependencies = [
"anyhow",
"komodo_client",
@@ -3275,7 +3275,7 @@ dependencies = [
[[package]]
name = "noise"
version = "2.0.0-dev-53"
version = "2.0.0-dev-54"
dependencies = [
"anyhow",
"arc-swap",
@@ -3695,7 +3695,7 @@ checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220"
[[package]]
name = "periphery_client"
version = "2.0.0-dev-53"
version = "2.0.0-dev-54"
dependencies = [
"anyhow",
"derive_variants",
@@ -4170,7 +4170,7 @@ dependencies = [
[[package]]
name = "response"
version = "2.0.0-dev-53"
version = "2.0.0-dev-54"
dependencies = [
"anyhow",
"axum",
@@ -4455,7 +4455,7 @@ dependencies = [
[[package]]
name = "secret_file"
version = "2.0.0-dev-53"
version = "2.0.0-dev-54"
dependencies = [
"tokio",
]
@@ -5457,7 +5457,7 @@ dependencies = [
[[package]]
name = "transport"
version = "2.0.0-dev-53"
version = "2.0.0-dev-54"
dependencies = [
"anyhow",
"axum",

View File

@@ -8,7 +8,7 @@ members = [
]
[workspace.package]
version = "2.0.0-dev-53"
version = "2.0.0-dev-54"
edition = "2024"
authors = ["mbecker20 <becker.maxh@gmail.com>"]
license = "GPL-3.0-or-later"

View File

@@ -99,7 +99,7 @@ pub fn periphery_config() -> &'static PeripheryConfig {
.unwrap_or(config.connect_as),
server_enabled: env
.periphery_server_enabled
.unwrap_or(config.server_enabled),
.or(config.server_enabled),
port: env.periphery_port.unwrap_or(config.port),
bind_ip: env.periphery_bind_ip.unwrap_or(config.bind_ip),
root_directory: env

View File

@@ -58,8 +58,8 @@ async fn app() -> anyhow::Result<()> {
}
}
// Spawn server connection handler
if config.server_enabled {
// Spawn server connection handler.
if config.server_enabled() {
handles.push(tokio::spawn(connection::server::run()));
}

View File

@@ -95,6 +95,14 @@ impl CorePublicKeys {
return;
}
};
// Check equality at path again before trying to rewrite.
match SpkiPublicKey::from_file(path) {
Ok(existing) if existing == public_key => {
self.refresh();
return;
}
_ => {}
}
if let Err(e) = public_key.write_pem_async(path).await {
warn!("Failed to pin incoming public key | {e:#}");
}
@@ -103,17 +111,17 @@ impl CorePublicKeys {
pub fn refresh(&self) {
let config = periphery_config();
let Some(core_public_keys) = config.core_public_keys.as_ref()
let Some(core_public_keys_spec) = config.core_public_keys_spec()
else {
return;
};
let mut to_write = Vec::new();
let core_public_keys = core_public_keys
let core_public_keys = core_public_keys_spec
.iter()
.flat_map(|public_key| {
if let Some(path) = public_key.strip_prefix("file:")
{
match (SpkiPublicKey::from_file(path), config.server_enabled) {
match (SpkiPublicKey::from_file(path), config.server_enabled()) {
(Ok(public_key), _) => Some(public_key),
(Err(e), false) => {
// If only outbound connections, only warn.

View File

@@ -242,6 +242,8 @@ pub struct PeripheryConfig {
///
/// Supports openssl generated pem file, `openssl pkey -in private.key -pubout -out public.key`.
/// To load from file, include `file:/path/to/public.key` in the list.
///
/// If not provided and `core_addresses` are defined, defaults to ["file:${root_directory}/keys/core.pub"]
#[serde(
default,
alias = "core_public_key",
@@ -278,9 +280,11 @@ pub struct PeripheryConfig {
// ======================
// = INBOUND CONNECTION =
// ======================
/// Enable the inbound connection server
#[serde(default = "default_server_enabled")]
pub server_enabled: bool,
/// Enable the inbound connection server.
///
/// - If `core_addresses` set, defaults to `false`.
/// - If `core_addresses` unset, defaults to `true`.
pub server_enabled: Option<bool>,
/// The port periphery will run on.
/// Default: `8120`
@@ -431,10 +435,6 @@ fn default_container_stats_polling_rate() -> Timelength {
Timelength::ThirtySeconds
}
fn default_server_enabled() -> bool {
true
}
fn default_ssl_enabled() -> bool {
true
}
@@ -449,7 +449,7 @@ impl Default for PeripheryConfig {
core_addresses: Default::default(),
core_tls_insecure_skip_verify: Default::default(),
connect_as: Default::default(),
server_enabled: default_server_enabled(),
server_enabled: Default::default(),
port: default_periphery_port(),
bind_ip: default_periphery_bind_ip(),
root_directory: default_root_directory(),
@@ -561,6 +561,32 @@ impl PeripheryConfig {
}
}
/// If `server_enabled` is None, defaults based on
/// whether there are any core_addresses defined.
pub fn server_enabled(&self) -> bool {
self
.server_enabled
.unwrap_or(self.core_addresses.is_empty())
}
pub fn core_public_keys_spec(&self) -> Option<Vec<String>> {
// Return explicitly set public key spec.
if let Some(public_keys) = self.core_public_keys.clone() {
return Some(public_keys);
};
// If server enabled, pass through empty public keys exactly
if self.server_enabled() {
return None;
}
// Defaults to $root_directory/keys/core.pub for Periphery -> Core.
// If it doesn't exist, will be auto written on first connection with Core.
let path = format!(
"file:{}",
self.root_directory.join("keys/core.pub").display()
);
Some(vec![path])
}
pub fn repo_dir(&self) -> PathBuf {
if let Some(dir) = &self.repo_dir {
dir.to_owned()

View File

@@ -130,9 +130,8 @@ KOMODO_PRETTY_STARTUP_CONFIG=false
PERIPHERY_CORE_ADDRESS=ws://core:9120
## Use the same name as KOMODO_FIRST_SERVER_NAME to connect
PERIPHERY_CONNECT_AS=${KOMODO_FIRST_SERVER_NAME}
## Disable inbound Server.
## Not needed for Periphery -> Core connection.
PERIPHERY_SERVER_ENABLED=false
## Use the public key generated by Core.
PERIPHERY_CORE_PUBLIC_KEYS=file:/config/keys/core.pub
## Specify the root directory used by Periphery agent.
## All your compose files and repos need to be inside this directory

View File

@@ -7,35 +7,23 @@
services:
periphery:
image: ghcr.io/moghtech/komodo-periphery:${COMPOSE_KOMODO_IMAGE_TAG:-latest}
image: ghcr.io/moghtech/komodo-periphery:2
restart: unless-stopped
## Full variable list + descriptions are available here:
## 🦎 https://github.com/moghtech/komodo/blob/main/config/periphery.config.toml 🦎
environment:
## You only need to keep the config for one of the
## connection directions.
### ==============================
### PERIPHERY -> CORE CONNECTION
### ==============================
## The address of Komodo Core to connect to.
PERIPHERY_CORE_ADDRESS: komodo.example.com
## The name of the Komodo Server to connect as.
## Must match existing server.
PERIPHERY_CONNECT_AS: server-name
## Create a Server Onboarding Key in the Komodo UI.
## Optional. Create a Server Onboarding Key in the Komodo UI.
## This allows Periphery to create a new Server in the UI with the above name,
## and can be ommitted once the Server exists in Komodo.
PERIPHERY_ONBOARDING_KEY: <your-key>
## Disable the inbound connection server.
PERIPHERY_SERVER_ENABLED: false
### ==============================
### CORE -> PERIPHERY CONNECTION
### ==============================
## List of accepted Core public keys
# PERIPHERY_CORE_PUBLIC_KEYS: sFIibtOSCFLQelO4b4x6VoYIddkRn9Tj1Nas2eR1ME0=
### ================
### GENERAL CONFIG
### ================
PERIPHERY_ONBOARDING_KEY: <your-onboarding-key>
## List of accepted Core public keys.
## File will be auto written if doesn't exist to match first Core it connects to.
PERIPHERY_CORE_PUBLIC_KEYS: file:/config/keys/core.pub
## Specify the root directory used by Periphery agent.
## All your compose files and repos need to be inside this directory
## for Periphery to interact with them.
@@ -66,10 +54,6 @@ services:
- ${PERIPHERY_ROOT_DIRECTORY:-/etc/komodo}:${PERIPHERY_ROOT_DIRECTORY:-/etc/komodo}
## Optionally mount a custom periphery.config.toml
# - /path/to/periphery.config.toml:/config/config.toml
## If Periphery is being run in Core -> Periphery mode,
## the port may need to be exposed.
# ports:
# - 8120:8120
volumes:
keys:

View File

@@ -144,8 +144,8 @@ exclude_disk_mounts = []
## Enable the inbound connection server for
## Core -> Periphery connection.
## Env: PERIHERY_SERVER_ENABLED
## Default: true
server_enabled = true
## Default: If 'core_addresses' are defined, false, otherwise true.
# server_enabled = true
## Optional. The port the server runs on.
## Env: PERIPHERY_PORT