Take the link from wg-app-link instead of keeping a second copy
The five modules underneath this backend that were never about AI sessions -- the pinned CA and leaf, QR enrollment and the bearer token, wg0 binding and the certificate's SANs, owner-only files, and the RON house rules -- were written twice, once here and once in dev-updater, and had drifted. They now come from the submodule, as a path dependency so both projects stay locked to one commit. What stayed is what makes this project itself: the routes, the drivers, the config schema, and the auth middleware, which is generic over this server's state. Sharing a transport is worth doing; sharing an API would mean inventing a vocabulary neither project wants. Four dependencies go with the code -- rcgen, qrcode, subtle and if-addrs are no longer named here at all -- and the three that remain are now described by what still uses them rather than by what used to. Verified by running it, not only by building: a fresh server generates its CA, prints an `aiapp://enroll` QR with the scheme now passed as a parameter, covers 127.0.0.1, 10.0.2.2 and wg0's 10.66.0.1 in the leaf, answers an enrolled token and returns 401 without one, and writes config.ron in the house rules with every file owner-only. 36 tests pass, clippy is silent, rustfmt is clean.
This commit is contained in:
1 parent
a83dbcff6a
commit
aa05ff9336
13 files changed
+76
-526
No files matched your search
+11
-19
@@ -8,6 +8,11 @@ name = "ai-server"
|
||||
path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
# The link both this and dev-updater need in order to be reached from a
|
||||
# phone: wg binding, the pinned CA, QR enrollment, owner-only files, and
|
||||
# the RON house rules. Extracted from the two copies that had drifted --
|
||||
# see that repo's README for the evidence and the bug the extraction found.
|
||||
wg-app-link = { path = "../wg-app-link/server" }
|
||||
axum = { version = "0.8", features = ["json", "multipart"] }
|
||||
axum-server = { version = "0.8", features = ["tls-rustls"] }
|
||||
tokio = { version = "1", features = ["rt-multi-thread", "macros", "net", "sync", "time", "process", "io-util", "signal"] }
|
||||
@@ -17,32 +22,19 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
# The config file's format. Not JSON, because this file is written and read
|
||||
# by hand and RON says a sum type as syntax -- the same choice, and the same
|
||||
# house rules, as the sibling dev-updater project's config.
|
||||
# by hand and RON says a sum type as syntax. The two house rules both
|
||||
# projects write it under live in wg-app-link; this is here for the error
|
||||
# types the schema's own signatures name.
|
||||
ron = "0.12.2"
|
||||
clap = { version = "4", features = ["derive"] }
|
||||
anyhow = "1"
|
||||
thiserror = "2"
|
||||
# Token auth: hash for storage, constant-time compare for verification,
|
||||
# CSPRNG-backed generation, base64url for the enrollment string.
|
||||
# Verifying a downloaded model against HuggingFace's published digest.
|
||||
sha2 = "0.11"
|
||||
subtle = "2"
|
||||
# Naming a session directory, and an attachment inside one.
|
||||
rand = "0.10"
|
||||
# Decoding the images a phone attaches, and encoding them for a driver.
|
||||
base64 = "0.23"
|
||||
# Renders the enrollment QR straight to the terminal; no image output needed.
|
||||
qrcode = { version = "0.14", default-features = false }
|
||||
# The wg0-bound listener needs the interface's address; the stdlib has no
|
||||
# getifaddrs. This is the smallest crate that wraps just that.
|
||||
if-addrs = "0.15"
|
||||
# Generates this server's TLS certificates on first start, replacing a
|
||||
# setup script that shelled out to whatever openssl happened to be
|
||||
# installed. In process means one place decides the extensions, the file
|
||||
# modes, and which addresses the leaf covers. x509-parser so the issuer is
|
||||
# read back from the CA actually on disk: reconstructing it from the same
|
||||
# parameters would work only as long as nothing ever changed them, and a
|
||||
# mismatched issuer name yields a chain that fails to validate rather than
|
||||
# anything that looks wrong at generation time.
|
||||
rcgen = { version = "0.14", features = ["pem", "x509-parser"] }
|
||||
# Outbound HTTPS for the usage endpoint. A small blocking client fits an
|
||||
# every-few-minutes poll better than pulling in reqwest's tower stack;
|
||||
# rustls-backed like the rest of the TLS here.
|
||||
|
||||
Reference in new issue
Block a user