containered launch empty web status
This commit is contained in:
@@ -1,3 +1,18 @@
|
|||||||
[alias]
|
[alias]
|
||||||
check-all = "check --workspace"
|
check-all = "check --workspace"
|
||||||
test-all = "test --workspace"
|
test-all = "test --workspace"
|
||||||
|
|
||||||
|
# Corporate environment: crates.io is replaced with internal Nexus mirror.
|
||||||
|
[registries.nexus]
|
||||||
|
index = "sparse+https://nexus.c68.spacecorp.ru/repository/cargo/"
|
||||||
|
|
||||||
|
[source.crates-io]
|
||||||
|
replace-with = "nexus"
|
||||||
|
|
||||||
|
# MSRV-aware dependency resolution (cargo >= 1.84).
|
||||||
|
# Cargo selects dependency versions compatible with workspace rust-version.
|
||||||
|
[resolver]
|
||||||
|
incompatible-rust-versions = "fallback"
|
||||||
|
|
||||||
|
[net]
|
||||||
|
retry = 3
|
||||||
|
|||||||
Generated
+284
@@ -17,6 +17,78 @@ version = "1.0.104"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470"
|
checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "async-trait"
|
||||||
|
version = "0.1.92"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "82f6aeea286b8eb4dd3431a1be1b59d290ace00f5bfd8e2a159bc2a05e2c1667"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 3.0.10",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "atomic-waker"
|
||||||
|
version = "1.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "axum"
|
||||||
|
version = "0.7.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "edca88bc138befd0323b20752846e6587272d3b03b0343c8ea28a6f819e6e71f"
|
||||||
|
dependencies = [
|
||||||
|
"async-trait",
|
||||||
|
"axum-core",
|
||||||
|
"bytes",
|
||||||
|
"futures-util",
|
||||||
|
"http",
|
||||||
|
"http-body",
|
||||||
|
"http-body-util",
|
||||||
|
"hyper",
|
||||||
|
"hyper-util",
|
||||||
|
"itoa",
|
||||||
|
"matchit",
|
||||||
|
"memchr",
|
||||||
|
"mime",
|
||||||
|
"percent-encoding",
|
||||||
|
"pin-project-lite",
|
||||||
|
"rustversion",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"serde_path_to_error",
|
||||||
|
"serde_urlencoded",
|
||||||
|
"sync_wrapper",
|
||||||
|
"tokio",
|
||||||
|
"tower",
|
||||||
|
"tower-layer",
|
||||||
|
"tower-service",
|
||||||
|
"tracing",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "axum-core"
|
||||||
|
version = "0.4.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "09f2bd6146b97ae3359fa0cc6d6b376d9539582c7b4220f041a33ec24c226199"
|
||||||
|
dependencies = [
|
||||||
|
"async-trait",
|
||||||
|
"bytes",
|
||||||
|
"futures-util",
|
||||||
|
"http",
|
||||||
|
"http-body",
|
||||||
|
"http-body-util",
|
||||||
|
"mime",
|
||||||
|
"pin-project-lite",
|
||||||
|
"rustversion",
|
||||||
|
"sync_wrapper",
|
||||||
|
"tower-layer",
|
||||||
|
"tower-service",
|
||||||
|
"tracing",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bytes"
|
name = "bytes"
|
||||||
version = "1.12.1"
|
version = "1.12.1"
|
||||||
@@ -29,6 +101,118 @@ version = "1.0.5"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"
|
checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "form_urlencoded"
|
||||||
|
version = "1.2.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf"
|
||||||
|
dependencies = [
|
||||||
|
"percent-encoding",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-core"
|
||||||
|
version = "0.3.34"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-task"
|
||||||
|
version = "0.3.34"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-util"
|
||||||
|
version = "0.3.34"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc"
|
||||||
|
dependencies = [
|
||||||
|
"futures-core",
|
||||||
|
"futures-task",
|
||||||
|
"pin-project-lite",
|
||||||
|
"slab",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "http"
|
||||||
|
version = "1.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "918d3568bebf352712bc2ef3d46a8bcf1a75b373be6539de198e9105cbbf9ce0"
|
||||||
|
dependencies = [
|
||||||
|
"bytes",
|
||||||
|
"itoa",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "http-body"
|
||||||
|
version = "1.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ca2a8f2913ee65f60facd6a5905613afaa448497a0230cc41ce022d93290bc2c"
|
||||||
|
dependencies = [
|
||||||
|
"bytes",
|
||||||
|
"http",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "http-body-util"
|
||||||
|
version = "0.1.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "23169fe34a5fbcdd3f3862e78fb9b6fccd5f02a6dc6f732547005d45631ce71c"
|
||||||
|
dependencies = [
|
||||||
|
"bytes",
|
||||||
|
"futures-core",
|
||||||
|
"http",
|
||||||
|
"http-body",
|
||||||
|
"pin-project-lite",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "httparse"
|
||||||
|
version = "1.10.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "httpdate"
|
||||||
|
version = "1.0.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hyper"
|
||||||
|
version = "1.12.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2c3e324da4c95177d6291d4c8730197c0d1822f8a9766814a4a44fa5ab797c9c"
|
||||||
|
dependencies = [
|
||||||
|
"atomic-waker",
|
||||||
|
"bytes",
|
||||||
|
"futures-core",
|
||||||
|
"http",
|
||||||
|
"http-body",
|
||||||
|
"httparse",
|
||||||
|
"httpdate",
|
||||||
|
"itoa",
|
||||||
|
"pin-project-lite",
|
||||||
|
"smallvec",
|
||||||
|
"tokio",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hyper-util"
|
||||||
|
version = "0.1.21"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ddc03d96684f9226b8a787cdb71488417b53ab5ea8fdb1dac946cb9431cc8bff"
|
||||||
|
dependencies = [
|
||||||
|
"bytes",
|
||||||
|
"http",
|
||||||
|
"http-body",
|
||||||
|
"hyper",
|
||||||
|
"pin-project-lite",
|
||||||
|
"tokio",
|
||||||
|
"tower-service",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "itoa"
|
name = "itoa"
|
||||||
version = "1.0.19"
|
version = "1.0.19"
|
||||||
@@ -62,12 +246,24 @@ dependencies = [
|
|||||||
"regex-automata",
|
"regex-automata",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "matchit"
|
||||||
|
version = "0.7.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "memchr"
|
name = "memchr"
|
||||||
version = "2.8.3"
|
version = "2.8.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
|
checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "mime"
|
||||||
|
version = "0.3.18"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d5848f5a9e8117cf94f2f90faac24a87ff81600ff8628c1e3deaab572e76bfa1"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mio"
|
name = "mio"
|
||||||
version = "1.2.5"
|
version = "1.2.5"
|
||||||
@@ -85,6 +281,7 @@ version = "0.1.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"mm-core",
|
"mm-core",
|
||||||
|
"mm-web",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"tokio",
|
"tokio",
|
||||||
@@ -118,7 +315,12 @@ dependencies = [
|
|||||||
name = "mm-web"
|
name = "mm-web"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"axum",
|
||||||
"mm-core",
|
"mm-core",
|
||||||
|
"serde_json",
|
||||||
|
"tokio",
|
||||||
|
"tracing",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -136,6 +338,12 @@ version = "1.21.4"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "percent-encoding"
|
||||||
|
version = "2.3.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pin-project-lite"
|
name = "pin-project-lite"
|
||||||
version = "0.2.17"
|
version = "0.2.17"
|
||||||
@@ -177,6 +385,18 @@ version = "0.8.11"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4"
|
checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustversion"
|
||||||
|
version = "1.0.23"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ryu"
|
||||||
|
version = "1.0.23"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.229"
|
version = "1.0.229"
|
||||||
@@ -220,6 +440,29 @@ dependencies = [
|
|||||||
"zmij",
|
"zmij",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_path_to_error"
|
||||||
|
version = "0.1.20"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "10a9ff822e371bb5403e391ecd83e182e0e77ba7f6fe0160b795797109d1b457"
|
||||||
|
dependencies = [
|
||||||
|
"itoa",
|
||||||
|
"serde",
|
||||||
|
"serde_core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_urlencoded"
|
||||||
|
version = "0.7.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd"
|
||||||
|
dependencies = [
|
||||||
|
"form_urlencoded",
|
||||||
|
"itoa",
|
||||||
|
"ryu",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sharded-slab"
|
name = "sharded-slab"
|
||||||
version = "0.1.7"
|
version = "0.1.7"
|
||||||
@@ -229,6 +472,12 @@ dependencies = [
|
|||||||
"lazy_static",
|
"lazy_static",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "slab"
|
||||||
|
version = "0.4.12"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "smallvec"
|
name = "smallvec"
|
||||||
version = "1.16.5"
|
version = "1.16.5"
|
||||||
@@ -267,6 +516,12 @@ dependencies = [
|
|||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "sync_wrapper"
|
||||||
|
version = "1.0.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror"
|
name = "thiserror"
|
||||||
version = "1.0.69"
|
version = "1.0.69"
|
||||||
@@ -322,12 +577,41 @@ dependencies = [
|
|||||||
"syn 3.0.10",
|
"syn 3.0.10",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tower"
|
||||||
|
version = "0.5.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ebe5ef63511595f1344e2d5cfa636d973292adc0eec1f0ad45fae9f0851ab1d4"
|
||||||
|
dependencies = [
|
||||||
|
"futures-core",
|
||||||
|
"futures-util",
|
||||||
|
"pin-project-lite",
|
||||||
|
"sync_wrapper",
|
||||||
|
"tokio",
|
||||||
|
"tower-layer",
|
||||||
|
"tower-service",
|
||||||
|
"tracing",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tower-layer"
|
||||||
|
version = "0.3.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tower-service"
|
||||||
|
version = "0.3.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tracing"
|
name = "tracing"
|
||||||
version = "0.1.44"
|
version = "0.1.44"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100"
|
checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"log",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"tracing-attributes",
|
"tracing-attributes",
|
||||||
"tracing-core",
|
"tracing-core",
|
||||||
|
|||||||
@@ -11,10 +11,12 @@ members = [
|
|||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
rust-version = "1.90"
|
||||||
license = "GPL-3.0-or-later"
|
license = "GPL-3.0-or-later"
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
|
axum = "0.7"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ name = "mm-bridge"
|
|||||||
version.workspace = true
|
version.workspace = true
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
|
rust-version.workspace = true
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "mm-bridge"
|
name = "mm-bridge"
|
||||||
@@ -11,6 +12,7 @@ path = "src/main.rs"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
mm-core.workspace = true
|
mm-core.workspace = true
|
||||||
|
mm-web.workspace = true
|
||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
tokio.workspace = true
|
tokio.workspace = true
|
||||||
|
|||||||
@@ -3,28 +3,27 @@ use std::env;
|
|||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct BridgeConfig {
|
pub struct BridgeConfig {
|
||||||
pub listen: String,
|
pub listen: String,
|
||||||
|
pub web_listen: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BridgeConfig {
|
impl BridgeConfig {
|
||||||
pub fn from_env() -> anyhow::Result<Self> {
|
pub fn from_env() -> anyhow::Result<Self> {
|
||||||
let listen =
|
let listen = read_addr("MM_BRIDGE_LISTEN", "127.0.0.1:8765")?;
|
||||||
env::var("MM_BRIDGE_LISTEN").unwrap_or_else(|_| "127.0.0.1:8765".to_string());
|
let web_listen = read_addr("MM_WEB_LISTEN", "127.0.0.1:8766")?;
|
||||||
|
|
||||||
validate_listen(&listen)?;
|
Ok(Self { listen, web_listen })
|
||||||
|
|
||||||
Ok(Self { listen })
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn validate_listen(listen: &str) -> anyhow::Result<()> {
|
fn read_addr(name: &str, default: &str) -> anyhow::Result<String> {
|
||||||
anyhow::ensure!(
|
let value = env::var(name).unwrap_or_else(|_| default.to_string());
|
||||||
!listen.trim().is_empty(),
|
validate_listen(name, &value)?;
|
||||||
"MM_BRIDGE_LISTEN must not be empty"
|
Ok(value)
|
||||||
);
|
}
|
||||||
anyhow::ensure!(
|
|
||||||
listen.contains(':'),
|
fn validate_listen(name: &str, listen: &str) -> anyhow::Result<()> {
|
||||||
"MM_BRIDGE_LISTEN must be host:port"
|
anyhow::ensure!(!listen.trim().is_empty(), "{name} must not be empty");
|
||||||
);
|
anyhow::ensure!(listen.contains(':'), "{name} must be host:port");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,11 +33,11 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn rejects_empty_listen() {
|
fn rejects_empty_listen() {
|
||||||
assert!(validate_listen("").is_err());
|
assert!(validate_listen("MM_BRIDGE_LISTEN", "").is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn accepts_host_port() {
|
fn accepts_host_port() {
|
||||||
assert!(validate_listen("127.0.0.1:8765").is_ok());
|
assert!(validate_listen("MM_BRIDGE_LISTEN", "127.0.0.1:8765").is_ok());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn init_tracing() {
|
fn init_tracing() {
|
||||||
let filter = EnvFilter::try_from_default_env()
|
let filter =
|
||||||
.unwrap_or_else(|_| EnvFilter::new("mm_bridge=info,warn"));
|
EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("mm_bridge=info,warn"));
|
||||||
|
|
||||||
tracing_subscriber::fmt()
|
tracing_subscriber::fmt()
|
||||||
.with_env_filter(filter)
|
.with_env_filter(filter)
|
||||||
|
|||||||
@@ -1,14 +1,33 @@
|
|||||||
use crate::{config::BridgeConfig, transport};
|
use crate::{config::BridgeConfig, status, transport};
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
|
use mm_web::state::WebState;
|
||||||
use tokio::net::TcpListener;
|
use tokio::net::TcpListener;
|
||||||
|
|
||||||
pub async fn run(config: BridgeConfig) -> anyhow::Result<()> {
|
pub async fn run(config: BridgeConfig) -> anyhow::Result<()> {
|
||||||
let listener = TcpListener::bind(&config.listen)
|
let tcp_listener = TcpListener::bind(&config.listen)
|
||||||
.await
|
.await
|
||||||
.with_context(|| format!("failed to bind {}", config.listen))?;
|
.with_context(|| format!("failed to bind {}", config.listen))?;
|
||||||
|
|
||||||
tracing::info!(listen = %config.listen, "bridge listening");
|
tracing::info!(listen = %config.listen, "bridge listening");
|
||||||
|
|
||||||
|
let web_state = WebState::new(status::current_status());
|
||||||
|
let web_task = tokio::spawn(mm_web::run(config.web_listen.clone(), web_state));
|
||||||
|
|
||||||
|
tokio::select! {
|
||||||
|
result = accept_loop(tcp_listener) => {
|
||||||
|
result
|
||||||
|
}
|
||||||
|
result = web_task => {
|
||||||
|
match result {
|
||||||
|
Ok(Ok(())) => Ok(()),
|
||||||
|
Ok(Err(error)) => Err(error).context("web status task failed"),
|
||||||
|
Err(error) => Err(error).context("web status task join failed"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn accept_loop(listener: TcpListener) -> anyhow::Result<()> {
|
||||||
loop {
|
loop {
|
||||||
let (stream, peer) = listener.accept().await.context("accept failed")?;
|
let (stream, peer) = listener.accept().await.context("accept failed")?;
|
||||||
tracing::debug!(%peer, "accepted connection");
|
tracing::debug!(%peer, "accepted connection");
|
||||||
|
|||||||
@@ -1,17 +1,21 @@
|
|||||||
use mm_core::{BridgeState, ServerSummary};
|
use mm_core::BridgeStatus;
|
||||||
use serde_json::{json, Value};
|
use serde_json::Value;
|
||||||
|
|
||||||
pub const BRIDGE_VERSION: &str = env!("CARGO_PKG_VERSION");
|
pub const BRIDGE_VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||||
|
|
||||||
pub fn status_result() -> Value {
|
pub fn current_status() -> BridgeStatus {
|
||||||
let servers: Vec<ServerSummary> = Vec::new();
|
BridgeStatus::running(BRIDGE_VERSION)
|
||||||
|
}
|
||||||
|
|
||||||
json!({
|
pub fn status_result() -> Value {
|
||||||
"bridge": {
|
serde_json::to_value(current_status()).unwrap_or_else(|_| {
|
||||||
"version": BRIDGE_VERSION,
|
serde_json::json!({
|
||||||
"state": BridgeState::Running,
|
"bridge": {
|
||||||
},
|
"version": BRIDGE_VERSION,
|
||||||
"servers": servers,
|
"state": "running"
|
||||||
|
},
|
||||||
|
"servers": []
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ name = "mm-client"
|
|||||||
version.workspace = true
|
version.workspace = true
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
|
rust-version.workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
mm-core.workspace = true
|
mm-core.workspace = true
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ name = "mm-core"
|
|||||||
version.workspace = true
|
version.workspace = true
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
|
rust-version.workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
|
|||||||
@@ -8,4 +8,4 @@ pub mod model;
|
|||||||
|
|
||||||
pub use error::{BridgeError, ErrorKind};
|
pub use error::{BridgeError, ErrorKind};
|
||||||
pub use ids::{ChannelId, PostId, ServerId, TeamId, UserId};
|
pub use ids::{ChannelId, PostId, ServerId, TeamId, UserId};
|
||||||
pub use model::{BridgeState, ServerSummary};
|
pub use model::{BridgeInfo, BridgeState, BridgeStatus, ServerSummary};
|
||||||
|
|||||||
@@ -12,3 +12,27 @@ pub struct ServerSummary {
|
|||||||
pub server_id: ServerId,
|
pub server_id: ServerId,
|
||||||
pub state: String,
|
pub state: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize)]
|
||||||
|
pub struct BridgeInfo {
|
||||||
|
pub version: String,
|
||||||
|
pub state: BridgeState,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize)]
|
||||||
|
pub struct BridgeStatus {
|
||||||
|
pub bridge: BridgeInfo,
|
||||||
|
pub servers: Vec<ServerSummary>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl BridgeStatus {
|
||||||
|
pub fn running(version: impl Into<String>) -> Self {
|
||||||
|
Self {
|
||||||
|
bridge: BridgeInfo {
|
||||||
|
version: version.into(),
|
||||||
|
state: BridgeState::Running,
|
||||||
|
},
|
||||||
|
servers: Vec::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ name = "mm-store"
|
|||||||
version.workspace = true
|
version.workspace = true
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
|
rust-version.workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
mm-core.workspace = true
|
mm-core.workspace = true
|
||||||
|
|||||||
@@ -3,6 +3,12 @@ name = "mm-web"
|
|||||||
version.workspace = true
|
version.workspace = true
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
|
rust-version.workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
anyhow.workspace = true
|
||||||
|
axum.workspace = true
|
||||||
mm-core.workspace = true
|
mm-core.workspace = true
|
||||||
|
serde_json.workspace = true
|
||||||
|
tokio.workspace = true
|
||||||
|
tracing.workspace = true
|
||||||
|
|||||||
@@ -1,7 +1,30 @@
|
|||||||
//! Web status UI.
|
//! Web status UI.
|
||||||
//!
|
|
||||||
//! Placeholder crate. Implementation starts at the Docker/status step.
|
|
||||||
|
|
||||||
pub mod routes;
|
pub mod routes;
|
||||||
pub mod state;
|
pub mod state;
|
||||||
pub mod templates;
|
pub mod templates;
|
||||||
|
|
||||||
|
use anyhow::Context;
|
||||||
|
use axum::Router;
|
||||||
|
use state::WebState;
|
||||||
|
use tokio::net::TcpListener;
|
||||||
|
|
||||||
|
pub async fn run(listen: String, state: WebState) -> anyhow::Result<()> {
|
||||||
|
let app = router(state);
|
||||||
|
|
||||||
|
let listener = TcpListener::bind(&listen)
|
||||||
|
.await
|
||||||
|
.with_context(|| format!("failed to bind web listener {}", listen))?;
|
||||||
|
|
||||||
|
tracing::info!(listen = %listen, "web status listening");
|
||||||
|
|
||||||
|
axum::serve(listener, app)
|
||||||
|
.await
|
||||||
|
.context("web status server failed")?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn router(state: WebState) -> Router {
|
||||||
|
routes::router(state)
|
||||||
|
}
|
||||||
|
|||||||
@@ -1 +1,37 @@
|
|||||||
//! routes module placeholder.
|
use crate::{state::WebState, templates};
|
||||||
|
use axum::{
|
||||||
|
extract::State,
|
||||||
|
response::{Html, IntoResponse},
|
||||||
|
routing::get,
|
||||||
|
Json, Router,
|
||||||
|
};
|
||||||
|
use mm_core::BridgeStatus;
|
||||||
|
use serde_json::{json, Value};
|
||||||
|
|
||||||
|
pub fn router(state: WebState) -> Router {
|
||||||
|
Router::new()
|
||||||
|
.route("/", get(index))
|
||||||
|
.route("/health", get(health))
|
||||||
|
.route("/status", get(status))
|
||||||
|
.with_state(state)
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn index(State(state): State<WebState>) -> Html<String> {
|
||||||
|
Html(templates::index_html(&state.status))
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn health() -> impl IntoResponse {
|
||||||
|
Json(json!({
|
||||||
|
"ok": true,
|
||||||
|
"state": "running"
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn status(State(state): State<WebState>) -> Json<BridgeStatus> {
|
||||||
|
Json(state.status)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
fn _value_type_check(value: Value) -> Value {
|
||||||
|
value
|
||||||
|
}
|
||||||
|
|||||||
@@ -1 +1,12 @@
|
|||||||
//! state module placeholder.
|
use mm_core::BridgeStatus;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub struct WebState {
|
||||||
|
pub status: BridgeStatus,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl WebState {
|
||||||
|
pub fn new(status: BridgeStatus) -> Self {
|
||||||
|
Self { status }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1 +1,63 @@
|
|||||||
//! templates module placeholder.
|
use mm_core::BridgeStatus;
|
||||||
|
|
||||||
|
pub fn index_html(status: &BridgeStatus) -> String {
|
||||||
|
let status_json = serde_json::to_string_pretty(status)
|
||||||
|
.unwrap_or_else(|_| "{\"error\":\"failed to encode status\"}".to_string());
|
||||||
|
|
||||||
|
let escaped_json = escape_html(&status_json);
|
||||||
|
let version = escape_html(&status.bridge.version);
|
||||||
|
let server_count = status.servers.len();
|
||||||
|
|
||||||
|
format!(
|
||||||
|
r#"<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>emacs-mattermost bridge</title>
|
||||||
|
<style>
|
||||||
|
body {{
|
||||||
|
font-family: system-ui, sans-serif;
|
||||||
|
margin: 2rem;
|
||||||
|
background: #111827;
|
||||||
|
color: #e5e7eb;
|
||||||
|
}}
|
||||||
|
a {{
|
||||||
|
color: #93c5fd;
|
||||||
|
}}
|
||||||
|
pre {{
|
||||||
|
background: #030712;
|
||||||
|
border: 1px solid #374151;
|
||||||
|
padding: 1rem;
|
||||||
|
overflow: auto;
|
||||||
|
}}
|
||||||
|
.ok {{
|
||||||
|
color: #86efac;
|
||||||
|
font-weight: bold;
|
||||||
|
}}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>emacs-mattermost bridge</h1>
|
||||||
|
<p>Status: <span class="ok">running</span></p>
|
||||||
|
<p>Version: {version}</p>
|
||||||
|
<p>Configured servers: {server_count}</p>
|
||||||
|
<p>
|
||||||
|
<a href="/health">/health</a> |
|
||||||
|
<a href="/status">/status</a>
|
||||||
|
</p>
|
||||||
|
<h2>Status JSON</h2>
|
||||||
|
<pre>{escaped_json}</pre>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
"#
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn escape_html(input: &str) -> String {
|
||||||
|
input
|
||||||
|
.replace('&', "&")
|
||||||
|
.replace('<', "<")
|
||||||
|
.replace('>', ">")
|
||||||
|
.replace('"', """)
|
||||||
|
.replace('\'', "'")
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
[toolchain]
|
[toolchain]
|
||||||
channel = "stable"
|
# MUST exactly match the toolchain preinstalled in the Docker builder image:
|
||||||
|
# docker run --rm --entrypoint sh <builder-image> -c 'ls /usr/local/rustup/toolchains'
|
||||||
|
# Take the directory name and strip the "-x86_64-unknown-linux-gnu" suffix.
|
||||||
|
# Any mismatch makes rustup try to download the toolchain from the internet,
|
||||||
|
# which fails in the corporate build environment.
|
||||||
|
channel = "1.94.0"
|
||||||
components = ["rustfmt", "clippy"]
|
components = ["rustfmt", "clippy"]
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
services:
|
||||||
|
mm-bridge:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: docker/Dockerfile
|
||||||
|
args:
|
||||||
|
RUST_BUILDER_IMAGE: "${RUST_BUILDER_IMAGE:-nexus.spacecorp.ru/rust:1.90-bookworm}"
|
||||||
|
RUNTIME_IMAGE: "${RUNTIME_IMAGE:-nexus.c68.spacecorp.ru/ci/debian:bookworm-ca}"
|
||||||
|
container_name: emacs-mattermost-bridge
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
MM_BRIDGE_LISTEN: "0.0.0.0:8765"
|
||||||
|
MM_WEB_LISTEN: "0.0.0.0:8766"
|
||||||
|
MM_DATA_DIR: "/data"
|
||||||
|
RUST_LOG: "mm_bridge=info,mm_web=info,warn"
|
||||||
|
ports:
|
||||||
|
- "127.0.0.1:8765:8765"
|
||||||
|
- "127.0.0.1:8766:8766"
|
||||||
|
volumes:
|
||||||
|
- ./data:/data
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
ARG RUST_BUILDER_IMAGE=nexus.spacecorp.ru/rust:1.90-bookworm
|
||||||
|
ARG RUNTIME_IMAGE=nexus.spacecorp.ru/ci/debian:bookworm-ca
|
||||||
|
|
||||||
|
FROM ${RUST_BUILDER_IMAGE} AS builder
|
||||||
|
|
||||||
|
# Corporate CA so cargo trusts nexus.local over HTTPS.
|
||||||
|
COPY docker/certs/corporate-ca.crt /usr/local/share/ca-certificates/corporate-ca.crt
|
||||||
|
RUN update-ca-certificates
|
||||||
|
|
||||||
|
WORKDIR /build
|
||||||
|
|
||||||
|
COPY bridge/Cargo.toml bridge/Cargo.lock ./
|
||||||
|
COPY bridge/.cargo ./.cargo
|
||||||
|
COPY bridge/crates ./crates
|
||||||
|
|
||||||
|
# NOTE: bridge/rust-toolchain.toml is intentionally NOT copied into the image.
|
||||||
|
|
||||||
|
RUN TOOLCHAIN="$(ls /usr/local/rustup/toolchains | head -n1)" \
|
||||||
|
&& echo "Using preinstalled toolchain: ${TOOLCHAIN}" \
|
||||||
|
&& RUSTUP_TOOLCHAIN="${TOOLCHAIN}" cargo build --release --locked -p mm-bridge
|
||||||
|
|
||||||
|
FROM ${RUNTIME_IMAGE} AS runtime
|
||||||
|
|
||||||
|
RUN useradd --system --uid 10001 --create-home --home-dir /home/mmbridge mmbridge \
|
||||||
|
&& mkdir -p /data \
|
||||||
|
&& chown -R mmbridge:mmbridge /data /home/mmbridge
|
||||||
|
|
||||||
|
COPY --from=builder /build/target/release/mm-bridge /usr/local/bin/mm-bridge
|
||||||
|
COPY docker/entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||||
|
|
||||||
|
RUN chmod +x /usr/local/bin/entrypoint.sh
|
||||||
|
|
||||||
|
USER mmbridge
|
||||||
|
|
||||||
|
ENV MM_BRIDGE_LISTEN=0.0.0.0:8765
|
||||||
|
ENV MM_WEB_LISTEN=0.0.0.0:8766
|
||||||
|
ENV MM_DATA_DIR=/data
|
||||||
|
ENV RUST_LOG=mm_bridge=info,mm_web=info,warn
|
||||||
|
|
||||||
|
EXPOSE 8765 8766
|
||||||
|
|
||||||
|
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
||||||
|
CMD ["mm-bridge"]
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,19 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
export MM_BRIDGE_LISTEN="${MM_BRIDGE_LISTEN:-0.0.0.0:8765}"
|
||||||
|
export MM_WEB_LISTEN="${MM_WEB_LISTEN:-0.0.0.0:8766}"
|
||||||
|
export MM_DATA_DIR="${MM_DATA_DIR:-/data}"
|
||||||
|
|
||||||
|
mkdir -p "${MM_DATA_DIR}"
|
||||||
|
|
||||||
|
if [[ "$#" -eq 0 ]]; then
|
||||||
|
exec mm-bridge
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$1" == "mm-bridge" ]]; then
|
||||||
|
shift
|
||||||
|
exec mm-bridge "$@"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec "$@"
|
||||||
|
|||||||
+23
-16
@@ -37,24 +37,27 @@
|
|||||||
|
|
||||||
## Phase 1 — minimal Rust bridge
|
## Phase 1 — minimal Rust bridge
|
||||||
|
|
||||||
- [ ] Add Cargo workspace.
|
- [x] Add Cargo workspace.
|
||||||
- [ ] Add crate manifests.
|
- [x] Add crate manifests.
|
||||||
- [ ] Add minimal mm-core types.
|
- [x] Add minimal mm-core types.
|
||||||
- [ ] Add JSONL protocol types.
|
- [x] Add JSONL protocol types.
|
||||||
- [ ] Add TCP listener.
|
- [x] Add TCP listener.
|
||||||
- [ ] Implement ping.
|
- [x] Implement ping.
|
||||||
- [ ] Implement status.
|
- [x] Implement status.
|
||||||
- [ ] Add smoke test for ping.
|
- [x] Add smoke test for ping/status.
|
||||||
|
|
||||||
## Phase 2 — Docker and status web UI
|
## Phase 2 — Docker and status web UI
|
||||||
|
|
||||||
- [ ] Add Dockerfile.
|
- [x] Add Dockerfile.
|
||||||
- [ ] Add compose.yaml.
|
- [x] Add compose.yaml.
|
||||||
- [ ] Add bridge config from environment.
|
- [x] Add bridge config from environment.
|
||||||
- [ ] Add /health.
|
- [x] Add /health.
|
||||||
- [ ] Add /status JSON.
|
- [x] Add /status JSON.
|
||||||
- [ ] Add simple HTML status page.
|
- [x] Add simple HTML status page.
|
||||||
- [ ] Verify bridge runs separately from Emacs.
|
- [x] Add Docker helper scripts.
|
||||||
|
- [x] Add web smoke script.
|
||||||
|
- [ ] Verify local bridge + web smoke.
|
||||||
|
- [ ] Verify Docker Compose bridge + web smoke.
|
||||||
|
|
||||||
## Phase 3 — authentication
|
## Phase 3 — authentication
|
||||||
|
|
||||||
@@ -134,4 +137,8 @@
|
|||||||
|
|
||||||
## Next atomic step
|
## Next atomic step
|
||||||
|
|
||||||
Add Rust workspace and minimal compiling bridge with ping/status over TCP JSONL.
|
Verify Phase 2 locally and in Docker Compose.
|
||||||
|
|
||||||
|
After that:
|
||||||
|
|
||||||
|
Implement authentication foundation: connect, me, login/password, token cache.
|
||||||
|
|||||||
@@ -5,6 +5,12 @@ ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|||||||
|
|
||||||
cd "${ROOT_DIR}/bridge"
|
cd "${ROOT_DIR}/bridge"
|
||||||
|
|
||||||
|
if [[ ! -f Cargo.lock ]]; then
|
||||||
|
echo "Cargo.lock is missing. Generate it first:" >&2
|
||||||
|
echo " cd bridge && cargo generate-lockfile" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
cargo fmt --all -- --check
|
cargo fmt --all -- --check
|
||||||
cargo check --workspace
|
cargo check --workspace --locked
|
||||||
cargo test --workspace
|
cargo test --workspace --locked
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
|
|
||||||
|
cd "${ROOT_DIR}"
|
||||||
|
|
||||||
|
docker compose build mm-bridge
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
|
|
||||||
|
cd "${ROOT_DIR}"
|
||||||
|
|
||||||
|
docker compose down
|
||||||
|
|||||||
Executable
+21
@@ -0,0 +1,21 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
|
CERT_DIR="${ROOT_DIR}/docker/certs"
|
||||||
|
TARGET="${CERT_DIR}/corporate-ca.crt"
|
||||||
|
|
||||||
|
SOURCE="${MM_CORPORATE_CA_FILE:-/etc/ssl/certs/ca-certificates.crt}"
|
||||||
|
|
||||||
|
if [[ ! -f "${SOURCE}" ]]; then
|
||||||
|
echo "CA source not found: ${SOURCE}" >&2
|
||||||
|
echo "Set MM_CORPORATE_CA_FILE to your corporate CA bundle path." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p "${CERT_DIR}"
|
||||||
|
cp "${SOURCE}" "${TARGET}"
|
||||||
|
|
||||||
|
echo "CA bundle copied:"
|
||||||
|
echo " from: ${SOURCE}"
|
||||||
|
echo " to: ${TARGET}"
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
|
|
||||||
|
cd "${ROOT_DIR}"
|
||||||
|
|
||||||
|
mkdir -p data
|
||||||
|
|
||||||
|
./scripts/docker-prepare-ca.sh
|
||||||
|
|
||||||
|
docker compose up -d --build mm-bridge
|
||||||
|
|
||||||
|
echo "Bridge TCP: 127.0.0.1:8765"
|
||||||
|
echo "Web status: http://127.0.0.1:8766/"
|
||||||
|
|||||||
Executable
+38
@@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
BASE_URL="${MM_WEB_URL:-http://127.0.0.1:8766}"
|
||||||
|
|
||||||
|
python3 - "$BASE_URL" <<'PY'
|
||||||
|
import json
|
||||||
|
import sys
|
||||||
|
import urllib.request
|
||||||
|
|
||||||
|
# Ignore system proxy settings: we talk to localhost directly.
|
||||||
|
proxy_handler = urllib.request.ProxyHandler({})
|
||||||
|
opener = urllib.request.build_opener(proxy_handler)
|
||||||
|
urllib.request.install_opener(opener)
|
||||||
|
|
||||||
|
base_url = sys.argv[1].rstrip("/")
|
||||||
|
|
||||||
|
def get_json(path):
|
||||||
|
with urllib.request.urlopen(base_url + path, timeout=5) as response:
|
||||||
|
body = response.read().decode("utf-8")
|
||||||
|
return json.loads(body)
|
||||||
|
|
||||||
|
health = get_json("/health")
|
||||||
|
print(json.dumps(health, ensure_ascii=False))
|
||||||
|
if health.get("ok") is not True:
|
||||||
|
raise SystemExit("/health is not ok")
|
||||||
|
|
||||||
|
status = get_json("/status")
|
||||||
|
print(json.dumps(status, ensure_ascii=False))
|
||||||
|
if status.get("bridge", {}).get("state") != "running":
|
||||||
|
raise SystemExit("/status bridge.state is not running")
|
||||||
|
|
||||||
|
with urllib.request.urlopen(base_url + "/", timeout=5) as response:
|
||||||
|
html = response.read().decode("utf-8")
|
||||||
|
if "emacs-mattermost bridge" not in html:
|
||||||
|
raise SystemExit("index page does not contain expected title")
|
||||||
|
print("index html ok")
|
||||||
|
PY
|
||||||
Reference in New Issue
Block a user