Compare commits

..

7 Commits

Author SHA1 Message Date
Aiden McClelland
bc9db9f2b7 efi fixes 2025-11-15 00:23:04 -07:00
Aiden McClelland
7210f43f50 build and efi fixes 2025-11-14 19:00:33 -07:00
Aiden McClelland
df636b7a78 misc networking fixes 2025-11-14 17:56:24 -07:00
Aiden McClelland
10c14b4d0a fix set-password 2025-11-13 16:36:17 -07:00
Aiden McClelland
1bf610a853 prevent gateways from getting stuck empty 2025-11-13 16:34:14 -07:00
Matt Hill
b4d82b82a9 CA instead of leaf for StartTunnel (#3046)
* updated docs for CA instead of cert

* generate ca instead of self-signed in start-tunnel

* Fix formatting in START-TUNNEL.md installation instructions

* Fix formatting in START-TUNNEL.md

* fix infinite loop

* add success message to install

* hide loopback and bridge gateways

---------

Co-authored-by: Aiden McClelland <me@drbonez.dev>
Co-authored-by: Aiden McClelland <3732071+dr-bonez@users.noreply.github.com>
2025-11-13 15:32:49 -07:00
Aiden McClelland
7c5ba45f6a Include StartTunnel installation command
Added installation instructions for StartTunnel.
2025-11-13 15:32:49 -07:00
400 changed files with 2014 additions and 3751 deletions

View File

@@ -160,7 +160,7 @@ results/$(REGISTRY_BASENAME).deb: dpkg-build.sh $(call ls-files,debian/start-reg
tunnel-deb: results/$(TUNNEL_BASENAME).deb tunnel-deb: results/$(TUNNEL_BASENAME).deb
results/$(TUNNEL_BASENAME).deb: dpkg-build.sh $(call ls-files,debian/start-tunnel) $(TUNNEL_TARGETS) results/$(TUNNEL_BASENAME).deb: dpkg-build.sh $(call ls-files,debian/start-tunnel) $(TUNNEL_TARGETS)
PROJECT=start-tunnel PLATFORM=$(ARCH) REQUIRES=debian DEPENDS=wireguard-tools,iptables ./build/os-compat/run-compat.sh ./dpkg-build.sh PROJECT=start-tunnel PLATFORM=$(ARCH) REQUIRES=debian DEPENDS=wireguard-tools,iptables,conntrack ./build/os-compat/run-compat.sh ./dpkg-build.sh
$(IMAGE_TYPE): results/$(BASENAME).$(IMAGE_TYPE) $(IMAGE_TYPE): results/$(BASENAME).$(IMAGE_TYPE)
@@ -226,7 +226,7 @@ wormhole-squashfs: results/$(BASENAME).squashfs
$(eval SQFS_SIZE := $(shell du -s --bytes results/$(BASENAME).squashfs | awk '{print $$1}')) $(eval SQFS_SIZE := $(shell du -s --bytes results/$(BASENAME).squashfs | awk '{print $$1}'))
@echo "Paste the following command into the shell of your StartOS server:" @echo "Paste the following command into the shell of your StartOS server:"
@echo @echo
@wormhole send results/$(BASENAME).squashfs 2>&1 | awk -Winteractive '/wormhole receive/ { printf "sudo sh -c '"'"'/usr/lib/startos/scripts/prune-images $(SQFS_SIZE) && /usr/lib/startos/scripts/prune-boot && cd /media/startos/images && wormhole receive --accept-file %s && CHECKSUM=$(SQFS_SUM) /usr/lib/startos/scripts/use-img ./$(BASENAME).squashfs'"'"'\n", $$3 }' @wormhole send results/$(BASENAME).squashfs 2>&1 | awk -Winteractive '/wormhole receive/ { printf "sudo sh -c '"'"'/usr/lib/startos/scripts/prune-images $(SQFS_SIZE) && /usr/lib/startos/scripts/prune-boot && cd /media/startos/images && wormhole receive --accept-file %s && CHECKSUM=$(SQFS_SUM) /usr/lib/startos/scripts/upgrade ./$(BASENAME).squashfs'"'"'\n", $$3 }'
update: $(STARTOS_TARGETS) update: $(STARTOS_TARGETS)
@if [ -z "$(REMOTE)" ]; then >&2 echo "Must specify REMOTE" && false; fi @if [ -z "$(REMOTE)" ]; then >&2 echo "Must specify REMOTE" && false; fi
@@ -254,7 +254,7 @@ update-squashfs: results/$(BASENAME).squashfs
$(call ssh,'/usr/lib/startos/scripts/prune-images $(SQFS_SIZE)') $(call ssh,'/usr/lib/startos/scripts/prune-images $(SQFS_SIZE)')
$(call ssh,'/usr/lib/startos/scripts/prune-boot') $(call ssh,'/usr/lib/startos/scripts/prune-boot')
$(call cp,results/$(BASENAME).squashfs,/media/startos/images/next.rootfs) $(call cp,results/$(BASENAME).squashfs,/media/startos/images/next.rootfs)
$(call ssh,'sudo CHECKSUM=$(SQFS_SUM) /usr/lib/startos/scripts/use-img /media/startos/images/next.rootfs') $(call ssh,'sudo CHECKSUM=$(SQFS_SUM) /usr/lib/startos/scripts/upgrade /media/startos/images/next.rootfs')
emulate-reflash: $(STARTOS_TARGETS) emulate-reflash: $(STARTOS_TARGETS)
@if [ -z "$(REMOTE)" ]; then >&2 echo "Must specify REMOTE" && false; fi @if [ -z "$(REMOTE)" ]; then >&2 echo "Must specify REMOTE" && false; fi
@@ -283,7 +283,10 @@ sdk/base/lib/osBindings/index.ts: $(shell if [ "$(REBUILD_TYPES)" -ne 0 ]; then
touch sdk/base/lib/osBindings/index.ts touch sdk/base/lib/osBindings/index.ts
core/startos/bindings/index.ts: $(call ls-files, core) $(ENVIRONMENT_FILE) core/startos/bindings/index.ts: $(call ls-files, core) $(ENVIRONMENT_FILE)
rm -rf core/startos/bindings
./core/build-ts.sh ./core/build-ts.sh
ls core/startos/bindings/*.ts | sed 's/core\/startos\/bindings\/\([^.]*\)\.ts/export { \1 } from ".\/\1";/g' | grep -v '"./index"' | tee core/startos/bindings/index.ts
npm --prefix sdk exec -- prettier --config ./sdk/base/package.json -w ./core/startos/bindings/*.ts
touch core/startos/bindings/index.ts touch core/startos/bindings/index.ts
sdk/dist/package.json sdk/baseDist/package.json: $(call ls-files, sdk) sdk/base/lib/osBindings/index.ts sdk/dist/package.json sdk/baseDist/package.json: $(call ls-files, sdk) sdk/base/lib/osBindings/index.ts

View File

@@ -7,6 +7,7 @@ bmon
btrfs-progs btrfs-progs
ca-certificates ca-certificates
cifs-utils cifs-utils
conntrack
cryptsetup cryptsetup
curl curl
dmidecode dmidecode
@@ -19,7 +20,6 @@ flashrom
fuse3 fuse3
grub-common grub-common
grub-efi grub-efi
grub2-common
htop htop
httpdirfs httpdirfs
iotop iotop

View File

@@ -1,6 +1,5 @@
- grub-common - grub-common
- grub-efi - grub-efi
- grub2-common
+ parted + parted
+ raspberrypi-net-mods + raspberrypi-net-mods
+ raspberrypi-sys-mods + raspberrypi-sys-mods

View File

@@ -10,24 +10,24 @@ fi
POSITIONAL_ARGS=() POSITIONAL_ARGS=()
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
case $1 in case $1 in
--no-sync) --no-sync)
NO_SYNC=1 NO_SYNC=1
shift shift
;; ;;
--create) --create)
ONLY_CREATE=1 ONLY_CREATE=1
shift shift
;; ;;
-*|--*) -*|--*)
echo "Unknown option $1" echo "Unknown option $1"
exit 1 exit 1
;; ;;
*) *)
POSITIONAL_ARGS+=("$1") # save positional arg POSITIONAL_ARGS+=("$1") # save positional arg
shift # past argument shift # past argument
;; ;;
esac esac
done done
set -- "${POSITIONAL_ARGS[@]}" # restore positional parameters set -- "${POSITIONAL_ARGS[@]}" # restore positional parameters
@@ -35,7 +35,7 @@ set -- "${POSITIONAL_ARGS[@]}" # restore positional parameters
if [ -z "$NO_SYNC" ]; then if [ -z "$NO_SYNC" ]; then
echo 'Syncing...' echo 'Syncing...'
umount -R /media/startos/next 2> /dev/null umount -R /media/startos/next 2> /dev/null
umount -R /media/startos/upper 2> /dev/null umount /media/startos/upper 2> /dev/null
rm -rf /media/startos/upper /media/startos/next rm -rf /media/startos/upper /media/startos/next
mkdir /media/startos/upper mkdir /media/startos/upper
mount -t tmpfs tmpfs /media/startos/upper mount -t tmpfs tmpfs /media/startos/upper
@@ -43,8 +43,6 @@ if [ -z "$NO_SYNC" ]; then
mount -t overlay \ mount -t overlay \
-olowerdir=/media/startos/current,upperdir=/media/startos/upper/data,workdir=/media/startos/upper/work \ -olowerdir=/media/startos/current,upperdir=/media/startos/upper/data,workdir=/media/startos/upper/work \
overlay /media/startos/next overlay /media/startos/next
mkdir -p /media/startos/next/media/startos/root
mount --bind /media/startos/root /media/startos/next/media/startos/root
fi fi
if [ -n "$ONLY_CREATE" ]; then if [ -n "$ONLY_CREATE" ]; then
@@ -56,12 +54,18 @@ mkdir -p /media/startos/next/dev
mkdir -p /media/startos/next/sys mkdir -p /media/startos/next/sys
mkdir -p /media/startos/next/proc mkdir -p /media/startos/next/proc
mkdir -p /media/startos/next/boot mkdir -p /media/startos/next/boot
mkdir -p /media/startos/next/media/startos/root
mount --bind /run /media/startos/next/run mount --bind /run /media/startos/next/run
mount --bind /tmp /media/startos/next/tmp mount --bind /tmp /media/startos/next/tmp
mount --bind /dev /media/startos/next/dev mount --bind /dev /media/startos/next/dev
mount --bind /sys /media/startos/next/sys mount --bind /sys /media/startos/next/sys
mount --bind /proc /media/startos/next/proc mount --bind /proc /media/startos/next/proc
mount --bind /boot /media/startos/next/boot mount --bind /boot /media/startos/next/boot
mount --bind /media/startos/root /media/startos/next/media/startos/root
if mountpoint /sys/firmware/efi/efivars 2> /dev/null; then
mount --bind /sys/firmware/efi/efivars /media/startos/next/sys/firmware/efi/efivars
fi
if [ -z "$*" ]; then if [ -z "$*" ]; then
chroot /media/startos/next chroot /media/startos/next
@@ -71,6 +75,10 @@ else
CHROOT_RES=$? CHROOT_RES=$?
fi fi
if mountpoint /media/startos/next/sys/firmware/efi/efivars 2> /dev/null; then
umount /media/startos/next/sys/firmware/efi/efivars
fi
umount /media/startos/next/run umount /media/startos/next/run
umount /media/startos/next/tmp umount /media/startos/next/tmp
umount /media/startos/next/dev umount /media/startos/next/dev
@@ -88,10 +96,10 @@ if [ "$CHROOT_RES" -eq 0 ]; then
echo 'Upgrading...' echo 'Upgrading...'
if ! time mksquashfs /media/startos/next /media/startos/images/next.squashfs -b 4096 -comp gzip; then if ! time mksquashfs /media/startos/next /media/startos/images/next.squashfs -b 4096 -comp gzip; then
umount -R /media/startos/next umount -l /media/startos/next
umount -R /media/startos/upper umount -l /media/startos/upper
rm -rf /media/startos/upper /media/startos/next rm -rf /media/startos/upper /media/startos/next
exit 1 exit 1
fi fi
hash=$(b3sum /media/startos/images/next.squashfs | head -c 32) hash=$(b3sum /media/startos/images/next.squashfs | head -c 32)
mv /media/startos/images/next.squashfs /media/startos/images/${hash}.rootfs mv /media/startos/images/next.squashfs /media/startos/images/${hash}.rootfs
@@ -103,5 +111,5 @@ if [ "$CHROOT_RES" -eq 0 ]; then
fi fi
umount -R /media/startos/next umount -R /media/startos/next
umount -R /media/startos/upper umount /media/startos/upper
rm -rf /media/startos/upper /media/startos/next rm -rf /media/startos/upper /media/startos/next

View File

@@ -5,34 +5,25 @@ if [ -z "$sip" ] || [ -z "$dip" ] || [ -z "$sport" ] || [ -z "$dport" ]; then
exit 1 exit 1
fi fi
# Helper function to check if a rule exists rule_exists() {
nat_rule_exists() {
iptables -t nat -C "$@" 2>/dev/null iptables -t nat -C "$@" 2>/dev/null
} }
# Helper function to add or delete a rule idempotently apply_rule() {
# Usage: apply_rule [add|del] <iptables args...> if [ "$UNDO" = "1" ]; then
apply_nat_rule() {
local action="$1"
shift
if [ "$action" = "add" ]; then
# Only add if rule doesn't exist
if ! rule_exists "$@"; then
iptables -t nat -A "$@"
fi
elif [ "$action" = "del" ]; then
if rule_exists "$@"; then if rule_exists "$@"; then
iptables -t nat -D "$@" iptables -t nat -D "$@"
fi fi
else
if ! rule_exists "$@"; then
iptables -t nat -A "$@"
fi
fi fi
} }
if [ "$UNDO" = 1 ]; then apply_rule PREROUTING -p tcp -d $sip --dport $sport -j DNAT --to-destination $dip:$dport
action="del" apply_rule OUTPUT -p tcp -d $sip --dport $sport -j DNAT --to-destination $dip:$dport
else
action="add"
fi
apply_nat_rule "$action" PREROUTING -p tcp -d $sip --dport $sport -j DNAT --to-destination $dip:$dport if [ "$UNDO" = 1 ]; then
apply_nat_rule "$action" OUTPUT -p tcp -d $sip --dport $sport -j DNAT --to-destination $dip:$dport conntrack -D -p tcp -d $sip --dport $sport
fi

82
build/lib/scripts/upgrade Executable file
View File

@@ -0,0 +1,82 @@
#!/bin/bash
set -e
SOURCE_DIR="$(dirname $(realpath "${BASH_SOURCE[0]}"))"
if [ "$UID" -ne 0 ]; then
>&2 echo 'Must be run as root'
exit 1
fi
if ! [ -f "$1" ]; then
>&2 echo "usage: $0 <SQUASHFS>"
exit 1
fi
echo 'Upgrading...'
hash=$(b3sum $1 | head -c 32)
if [ -n "$2" ] && [ "$hash" != "$CHECKSUM" ]; then
>&2 echo 'Checksum mismatch'
exit 2
fi
unsquashfs -f -d / $1 boot
umount -R /media/startos/next 2> /dev/null || true
umount /media/startos/upper 2> /dev/null || true
umount /media/startos/lower 2> /dev/null || true
mkdir -p /media/startos/upper
mount -t tmpfs tmpfs /media/startos/upper
mkdir -p /media/startos/lower /media/startos/upper/data /media/startos/upper/work /media/startos/next
mount $1 /media/startos/lower
mount -t overlay \
-olowerdir=/media/startos/lower,upperdir=/media/startos/upper/data,workdir=/media/startos/upper/work \
overlay /media/startos/next
mkdir -p /media/startos/next/run
mkdir -p /media/startos/next/dev
mkdir -p /media/startos/next/sys
mkdir -p /media/startos/next/proc
mkdir -p /media/startos/next/boot
mkdir -p /media/startos/next/media/startos/root
mount --bind /run /media/startos/next/run
mount --bind /tmp /media/startos/next/tmp
mount --bind /dev /media/startos/next/dev
mount --bind /sys /media/startos/next/sys
mount --bind /proc /media/startos/next/proc
mount --bind /boot /media/startos/next/boot
mount --bind /media/startos/root /media/startos/next/media/startos/root
if mountpoint /boot/efi 2> /dev/null; then
mkdir -p /media/startos/next/boot/efi
mount --bind /boot/efi /media/startos/next/boot/efi
fi
if mountpoint /sys/firmware/efi/efivars 2> /dev/null; then
mount --bind /sys/firmware/efi/efivars /media/startos/next/sys/firmware/efi/efivars
fi
chroot /media/startos/next bash -e << "EOF"
if dpkg -s grub-common 2>&1 > /dev/null; then
grub-install /dev/$(eval $(lsblk -o MOUNTPOINT,PKNAME -P | grep 'MOUNTPOINT="/media/startos/root"') && echo $PKNAME)
update-grub
fi
EOF
sync
umount -R /media/startos/next
umount /media/startos/upper
umount /media/startos/lower
mv $1 /media/startos/images/${hash}.rootfs
ln -rsf /media/startos/images/${hash}.rootfs /media/startos/config/current.rootfs
sync
echo 'System upgrade complete. Reboot to apply changes...'

View File

@@ -1,61 +0,0 @@
#!/bin/bash
set -e
if [ "$UID" -ne 0 ]; then
>&2 echo 'Must be run as root'
exit 1
fi
if [ -z "$1" ]; then
>&2 echo "usage: $0 <SQUASHFS>"
exit 1
fi
VERSION=$(unsquashfs -cat $1 /usr/lib/startos/VERSION.txt)
GIT_HASH=$(unsquashfs -cat $1 /usr/lib/startos/GIT_HASH.txt)
B3SUM=$(b3sum $1 | head -c 32)
if [ -n "$CHECKSUM" ] && [ "$CHECKSUM" != "$B3SUM" ]; then
>&2 echo "CHECKSUM MISMATCH"
exit 2
fi
mv $1 /media/startos/images/${B3SUM}.rootfs
ln -rsf /media/startos/images/${B3SUM}.rootfs /media/startos/config/current.rootfs
unsquashfs -n -f -d / /media/startos/images/${B3SUM}.rootfs boot
umount -R /media/startos/next 2> /dev/null || true
umount -R /media/startos/lower 2> /dev/null || true
umount -R /media/startos/upper 2> /dev/null || true
rm -rf /media/startos/lower /media/startos/upper /media/startos/next
mkdir /media/startos/upper
mount -t tmpfs tmpfs /media/startos/upper
mkdir -p /media/startos/lower /media/startos/upper/data /media/startos/upper/work /media/startos/next
mount /media/startos/images/${B3SUM}.rootfs /media/startos/lower
mount -t overlay \
-olowerdir=/media/startos/lower,upperdir=/media/startos/upper/data,workdir=/media/startos/upper/work \
overlay /media/startos/next
mkdir -p /media/startos/next/media/startos/root
mount --bind /media/startos/root /media/startos/next/media/startos/root
mkdir -p /media/startos/next/dev
mkdir -p /media/startos/next/sys
mkdir -p /media/startos/next/proc
mkdir -p /media/startos/next/boot
mount --bind /dev /media/startos/next/dev
mount --bind /sys /media/startos/next/sys
mount --bind /proc /media/startos/next/proc
mount --bind /boot /media/startos/next/boot
chroot /media/startos/next update-grub2
umount -R /media/startos/next
umount -R /media/startos/upper
umount -R /media/startos/lower
rm -rf /media/startos/lower /media/startos/upper /media/startos/next
sync
reboot

View File

@@ -9,7 +9,7 @@ if [ "$ARCH" = "riscv64" ]; then
RUST_ARCH="riscv64gc" RUST_ARCH="riscv64gc"
fi fi
if mountpoint -q tmp/combined; then sudo umount -R tmp/combined; fi if mountpoint -q tmp/combined; then sudo umount -l tmp/combined; fi
if mountpoint -q tmp/lower; then sudo umount tmp/lower; fi if mountpoint -q tmp/lower; then sudo umount tmp/lower; fi
sudo rm -rf tmp sudo rm -rf tmp
mkdir -p tmp/lower tmp/upper tmp/work tmp/combined mkdir -p tmp/lower tmp/upper tmp/work tmp/combined

300
core/Cargo.lock generated
View File

@@ -270,7 +270,7 @@ source = "git+https://github.com/Start9Labs/arti.git?branch=patch%2Fdisable-exit
dependencies = [ dependencies = [
"async-trait", "async-trait",
"cfg-if", "cfg-if",
"derive-deftly", "derive-deftly 1.2.0",
"derive_builder_fork_arti", "derive_builder_fork_arti",
"derive_more 2.0.1", "derive_more 2.0.1",
"educe", "educe",
@@ -367,7 +367,7 @@ checksum = "965c2d33e53cb6b267e148a4cb0760bc01f4904c1cd4bb4002a085bb016d1490"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
"synstructure", "synstructure",
] ]
@@ -379,7 +379,7 @@ checksum = "3109e49b1e4909e9db6515a30c633684d68cdeaa252f215214cb4fa1a5bfee2c"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
"synstructure", "synstructure",
] ]
@@ -391,7 +391,7 @@ checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -459,9 +459,9 @@ dependencies = [
[[package]] [[package]]
name = "async-compression" name = "async-compression"
version = "0.4.33" version = "0.4.32"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93c1f86859c1af3d514fa19e8323147ff10ea98684e6c7b307912509f50e67b2" checksum = "5a89bce6054c720275ac2432fbba080a66a2106a44a1b804553930ca6909f4e0"
dependencies = [ dependencies = [
"compression-codecs", "compression-codecs",
"compression-core", "compression-core",
@@ -567,7 +567,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -634,7 +634,7 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -651,7 +651,7 @@ checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -989,7 +989,7 @@ dependencies = [
"regex", "regex",
"rustc-hash", "rustc-hash",
"shlex", "shlex",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -1107,7 +1107,7 @@ checksum = "e0b121a9fe0df916e362fb3271088d071159cdf11db0e4182d02152850756eff"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -1247,9 +1247,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5"
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.2.45" version = "1.2.44"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "35900b6c8d709fb1d854671ae27aeaa9eec2f8b01b364e1619a40da3e6fe2afe" checksum = "37521ac7aabe3d13122dc382493e20c9416f299d2ccd5b3a5340a2570cdeb0f3"
dependencies = [ dependencies = [
"find-msvc-tools", "find-msvc-tools",
"jobserver", "jobserver",
@@ -1404,7 +1404,7 @@ dependencies = [
"heck 0.5.0", "heck 0.5.0",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -1497,9 +1497,9 @@ dependencies = [
[[package]] [[package]]
name = "compression-codecs" name = "compression-codecs"
version = "0.4.32" version = "0.4.31"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "680dc087785c5230f8e8843e2e57ac7c1c90488b6a91b88caa265410568f441b" checksum = "ef8a506ec4b81c460798f572caead636d57d3d7e940f998160f52bd254bf2d23"
dependencies = [ dependencies = [
"brotli", "brotli",
"compression-core", "compression-core",
@@ -1512,9 +1512,9 @@ dependencies = [
[[package]] [[package]]
name = "compression-core" name = "compression-core"
version = "0.4.30" version = "0.4.29"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a9b614a5787ef0c8802a55766480563cb3a93b435898c422ed2a359cf811582" checksum = "e47641d3deaf41fb1538ac1f54735925e275eaf3bf4d55c81b137fba797e5cbb"
[[package]] [[package]]
name = "concurrent-queue" name = "concurrent-queue"
@@ -2011,7 +2011,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -2059,7 +2059,7 @@ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"strsim 0.11.1", "strsim 0.11.1",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -2081,7 +2081,7 @@ checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81"
dependencies = [ dependencies = [
"darling_core 0.21.3", "darling_core 0.21.3",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -2138,7 +2138,7 @@ checksum = "8034092389675178f570469e6c3b0465d3d30b4505c294a6550db47f3c17ad18"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -2151,16 +2151,44 @@ dependencies = [
"serde_core", "serde_core",
] ]
[[package]]
name = "derive-deftly"
version = "0.14.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8ea84d0109517cc2253d4a679bdda1e8989e9bd86987e9e4f75ffdda0095fd1"
dependencies = [
"derive-deftly-macros 0.14.6",
"heck 0.5.0",
]
[[package]] [[package]]
name = "derive-deftly" name = "derive-deftly"
version = "1.2.0" version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "957bb73a3a9c0bbcac67e129b81954661b3cfcb9e28873d8441f91b54852e77a" checksum = "957bb73a3a9c0bbcac67e129b81954661b3cfcb9e28873d8441f91b54852e77a"
dependencies = [ dependencies = [
"derive-deftly-macros", "derive-deftly-macros 1.2.0",
"heck 0.5.0", "heck 0.5.0",
] ]
[[package]]
name = "derive-deftly-macros"
version = "0.14.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "357422a457ccb850dc8f1c1680e0670079560feaad6c2e247e3f345c4fab8a3f"
dependencies = [
"heck 0.5.0",
"indexmap 2.12.0",
"itertools 0.14.0",
"proc-macro-crate",
"proc-macro2",
"quote",
"sha3 0.10.8",
"strum",
"syn 2.0.108",
"void",
]
[[package]] [[package]]
name = "derive-deftly-macros" name = "derive-deftly-macros"
version = "1.2.0" version = "1.2.0"
@@ -2175,7 +2203,7 @@ dependencies = [
"quote", "quote",
"sha3 0.10.8", "sha3 0.10.8",
"strum", "strum",
"syn 2.0.110", "syn 2.0.108",
"void", "void",
] ]
@@ -2187,7 +2215,7 @@ checksum = "1e567bd82dcff979e4b03460c307b3cdc9e96fde3d73bed1496d2bc75d9dd62a"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -2231,7 +2259,7 @@ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"rustc_version", "rustc_version",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -2252,7 +2280,7 @@ dependencies = [
"convert_case 0.7.1", "convert_case 0.7.1",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
"unicode-xid", "unicode-xid",
] ]
@@ -2342,7 +2370,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -2423,7 +2451,7 @@ dependencies = [
"proc-macro-error2", "proc-macro-error2",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -2617,7 +2645,7 @@ dependencies = [
"heck 0.5.0", "heck 0.5.0",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -2630,7 +2658,7 @@ dependencies = [
"num-traits", "num-traits",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -2651,7 +2679,7 @@ checksum = "67c78a4d8fdf9953a5c9d458f9efe940fd97a0cab0941c075a813ac594733827"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -3085,7 +3113,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -3430,7 +3458,7 @@ dependencies = [
"lazy_async_pool", "lazy_async_pool",
"models", "models",
"pin-project", "pin-project",
"rpc-toolkit", "rpc-toolkit 0.3.2 (git+https://github.com/Start9Labs/rpc-toolkit.git?branch=master)",
"serde", "serde",
"serde_json", "serde_json",
"tokio", "tokio",
@@ -3851,9 +3879,9 @@ dependencies = [
[[package]] [[package]]
name = "iddqd" name = "iddqd"
version = "0.3.16" version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dda610d939ea51890ca6c827c8365acf0a44b4b53d2ed6f371e8e7e47bc75d25" checksum = "bac5efd33e0c5eb0ac45cbd210541a214dac576896ca97ba08e16e3b1079cdd8"
dependencies = [ dependencies = [
"allocator-api2", "allocator-api2",
"equivalent", "equivalent",
@@ -4739,7 +4767,7 @@ checksum = "db5b29714e950dbb20d5e6f74f9dcec4edbcc1067bb7f8ed198c097b8c1a818b"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -4807,7 +4835,7 @@ dependencies = [
"rand 0.9.2", "rand 0.9.2",
"regex", "regex",
"reqwest", "reqwest",
"rpc-toolkit", "rpc-toolkit 0.3.2 (git+https://github.com/Start9Labs/rpc-toolkit.git?branch=master)",
"rustls 0.23.35", "rustls 0.23.35",
"serde", "serde",
"serde_json", "serde_json",
@@ -5122,7 +5150,7 @@ dependencies = [
"proc-macro-crate", "proc-macro-crate",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -5285,9 +5313,9 @@ dependencies = [
[[package]] [[package]]
name = "openssl" name = "openssl"
version = "0.10.75" version = "0.10.74"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08838db121398ad17ab8531ce9de97b244589089e290a384c900cb9ff7434328" checksum = "24ad14dd45412269e1a30f52ad8f0664f0f4f4a89ee8fe28c3b3527021ebb654"
dependencies = [ dependencies = [
"bitflags 2.10.0", "bitflags 2.10.0",
"cfg-if", "cfg-if",
@@ -5306,7 +5334,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -5326,9 +5354,9 @@ dependencies = [
[[package]] [[package]]
name = "openssl-sys" name = "openssl-sys"
version = "0.9.111" version = "0.9.110"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "82cab2d520aa75e3c58898289429321eb788c3106963d0dc886ec7a5f4adc321" checksum = "0a9f0075ba3c21b09f8e8b2026584b1d18d49388648f2fbbf3c97ea8deced8e2"
dependencies = [ dependencies = [
"cc", "cc",
"libc", "libc",
@@ -5490,7 +5518,7 @@ dependencies = [
"nix 0.30.1", "nix 0.30.1",
"patch-db-macro", "patch-db-macro",
"serde", "serde",
"serde_cbor 0.11.1", "serde_cbor",
"thiserror 2.0.17", "thiserror 2.0.17",
"tokio", "tokio",
"tracing", "tracing",
@@ -5581,7 +5609,7 @@ dependencies = [
"pest_meta", "pest_meta",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -5655,7 +5683,7 @@ dependencies = [
"phf_shared 0.11.3", "phf_shared 0.11.3",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -5668,7 +5696,7 @@ dependencies = [
"phf_shared 0.13.1", "phf_shared 0.13.1",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -5712,7 +5740,7 @@ checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -5919,7 +5947,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -5984,7 +6012,7 @@ dependencies = [
"proc-macro-error-attr2", "proc-macro-error-attr2",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -6048,7 +6076,7 @@ checksum = "4ee1c9ac207483d5e7db4940700de86a9aae46ef90c48b57f99fe7edb8345e49"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -6071,7 +6099,7 @@ dependencies = [
"itertools 0.14.0", "itertools 0.14.0",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -6120,14 +6148,14 @@ dependencies = [
[[package]] [[package]]
name = "pwd-grp" name = "pwd-grp"
version = "1.0.2" version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e2023f41b5fcb7c30eb5300a5733edfaa9e0e0d502d51b586f65633fd39e40c" checksum = "b94fdf3867b7f2889a736f0022ea9386766280d2cca4bdbe41629ada9e4f3b8f"
dependencies = [ dependencies = [
"derive-deftly", "derive-deftly 0.14.6",
"libc", "libc",
"paste", "paste",
"thiserror 2.0.17", "thiserror 1.0.69",
] ]
[[package]] [[package]]
@@ -6220,9 +6248,9 @@ dependencies = [
[[package]] [[package]]
name = "quote" name = "quote"
version = "1.0.42" version = "1.0.41"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f" checksum = "ce25767e7b499d1b604768e7cde645d14cc8584231ea6b295e9c9eb22c02e1d1"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
] ]
@@ -6549,7 +6577,7 @@ checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -6691,7 +6719,35 @@ dependencies = [
[[package]] [[package]]
name = "rpc-toolkit" name = "rpc-toolkit"
version = "0.3.2" version = "0.3.2"
source = "git+https://github.com/Start9Labs/rpc-toolkit.git?branch=master#2dd2832e043eb5380c91cf80f3e78a700d204be3" source = "git+https://github.com/Start9Labs/rpc-toolkit.git?branch=master#068db905ee38a7da97cc4a43b806409204e73723"
dependencies = [
"async-stream",
"async-trait",
"axum 0.8.6",
"clap",
"futures",
"http",
"http-body-util",
"imbl-value 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"itertools 0.14.0",
"lazy_format",
"lazy_static",
"openssl",
"pin-project",
"reqwest",
"serde",
"serde_json",
"thiserror 2.0.17",
"tokio",
"tokio-stream",
"url",
"yajrc",
]
[[package]]
name = "rpc-toolkit"
version = "0.3.2"
source = "git+https://github.com/Start9Labs/rpc-toolkit.git?rev=068db90#068db905ee38a7da97cc4a43b806409204e73723"
dependencies = [ dependencies = [
"async-stream", "async-stream",
"async-trait", "async-trait",
@@ -6708,12 +6764,10 @@ dependencies = [
"pin-project", "pin-project",
"reqwest", "reqwest",
"serde", "serde",
"serde_cbor 0.11.2",
"serde_json", "serde_json",
"thiserror 2.0.17", "thiserror 2.0.17",
"tokio", "tokio",
"tokio-stream", "tokio-stream",
"ts-rs",
"url", "url",
"yajrc", "yajrc",
] ]
@@ -7019,9 +7073,9 @@ dependencies = [
[[package]] [[package]]
name = "schemars" name = "schemars"
version = "1.1.0" 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 = "9558e172d4e8533736ba97870c4b2cd63f84b382a3d6eb063da41b91cce17289" checksum = "1317c3bf3e7df961da95b0a56a172a02abead31276215a0497241a7624b487ce"
dependencies = [ dependencies = [
"dyn-clone", "dyn-clone",
"ref-cast", "ref-cast",
@@ -7148,16 +7202,6 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "serde_cbor"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5"
dependencies = [
"half 1.8.3",
"serde",
]
[[package]] [[package]]
name = "serde_core" name = "serde_core"
version = "1.0.228" version = "1.0.228"
@@ -7175,7 +7219,7 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -7232,7 +7276,7 @@ checksum = "175ee3e80ae9982737ca543e96133087cbd9a485eecc3bc4de9c1a37b47ea59c"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -7277,7 +7321,7 @@ dependencies = [
"indexmap 1.9.3", "indexmap 1.9.3",
"indexmap 2.12.0", "indexmap 2.12.0",
"schemars 0.9.0", "schemars 0.9.0",
"schemars 1.1.0", "schemars 1.0.5",
"serde_core", "serde_core",
"serde_json", "serde_json",
"serde_with_macros", "serde_with_macros",
@@ -7293,7 +7337,7 @@ dependencies = [
"darling 0.21.3", "darling 0.21.3",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -7711,7 +7755,7 @@ dependencies = [
"quote", "quote",
"sqlx-core", "sqlx-core",
"sqlx-macros-core", "sqlx-macros-core",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -7732,7 +7776,7 @@ dependencies = [
"sha2 0.10.9", "sha2 0.10.9",
"sqlx-core", "sqlx-core",
"sqlx-postgres", "sqlx-postgres",
"syn 2.0.110", "syn 2.0.108",
"tokio", "tokio",
"url", "url",
] ]
@@ -7797,7 +7841,7 @@ dependencies = [
"quote", "quote",
"regex-syntax 0.6.29", "regex-syntax 0.6.29",
"strsim 0.11.1", "strsim 0.11.1",
"syn 2.0.110", "syn 2.0.108",
"unicode-width 0.1.14", "unicode-width 0.1.14",
] ]
@@ -7872,7 +7916,6 @@ dependencies = [
"async-compression", "async-compression",
"async-stream", "async-stream",
"async-trait", "async-trait",
"aws-lc-sys",
"axum 0.8.6", "axum 0.8.6",
"backtrace-on-stack-overflow", "backtrace-on-stack-overflow",
"barrage", "barrage",
@@ -7965,7 +8008,7 @@ dependencies = [
"reqwest", "reqwest",
"reqwest_cookie_store", "reqwest_cookie_store",
"rpassword", "rpassword",
"rpc-toolkit", "rpc-toolkit 0.3.2 (git+https://github.com/Start9Labs/rpc-toolkit.git?rev=068db90)",
"rust-argon2", "rust-argon2",
"safelog", "safelog",
"semver", "semver",
@@ -8098,7 +8141,7 @@ dependencies = [
"heck 0.5.0", "heck 0.5.0",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -8141,9 +8184,9 @@ dependencies = [
[[package]] [[package]]
name = "syn" name = "syn"
version = "2.0.110" version = "2.0.108"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a99801b5bd34ede4cf3fc688c5919368fea4e4814a4664359503e6015b280aea" checksum = "da58917d35242480a05c2897064da0a80589a2a0476c9a3f2fdc83b53502e917"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@@ -8167,7 +8210,7 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -8335,7 +8378,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -8346,7 +8389,7 @@ checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -8471,7 +8514,7 @@ checksum = "af407857209536a95c8e56f8231ef2c2e2aff839b22e07a1ffcbc617e9db9fa5"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -8707,7 +8750,7 @@ name = "tor-async-utils"
version = "0.33.0" version = "0.33.0"
source = "git+https://github.com/Start9Labs/arti.git?branch=patch%2Fdisable-exit#24730694701a83432d791d80802db8bda0699700" source = "git+https://github.com/Start9Labs/arti.git?branch=patch%2Fdisable-exit#24730694701a83432d791d80802db8bda0699700"
dependencies = [ dependencies = [
"derive-deftly", "derive-deftly 1.2.0",
"educe", "educe",
"futures", "futures",
"oneshot-fused-workaround", "oneshot-fused-workaround",
@@ -8741,7 +8784,7 @@ version = "0.33.0"
source = "git+https://github.com/Start9Labs/arti.git?branch=patch%2Fdisable-exit#24730694701a83432d791d80802db8bda0699700" source = "git+https://github.com/Start9Labs/arti.git?branch=patch%2Fdisable-exit#24730694701a83432d791d80802db8bda0699700"
dependencies = [ dependencies = [
"bytes", "bytes",
"derive-deftly", "derive-deftly 1.2.0",
"digest 0.10.7", "digest 0.10.7",
"educe", "educe",
"getrandom 0.3.4", "getrandom 0.3.4",
@@ -8761,7 +8804,7 @@ dependencies = [
"bitflags 2.10.0", "bitflags 2.10.0",
"bytes", "bytes",
"caret", "caret",
"derive-deftly", "derive-deftly 1.2.0",
"derive_more 2.0.1", "derive_more 2.0.1",
"educe", "educe",
"itertools 0.14.0", "itertools 0.14.0",
@@ -8852,7 +8895,7 @@ dependencies = [
"async-trait", "async-trait",
"bounded-vec-deque", "bounded-vec-deque",
"cfg-if", "cfg-if",
"derive-deftly", "derive-deftly 1.2.0",
"derive_builder_fork_arti", "derive_builder_fork_arti",
"derive_more 2.0.1", "derive_more 2.0.1",
"downcast-rs 2.0.2", "downcast-rs 2.0.2",
@@ -8899,7 +8942,7 @@ source = "git+https://github.com/Start9Labs/arti.git?branch=patch%2Fdisable-exit
dependencies = [ dependencies = [
"amplify", "amplify",
"cfg-if", "cfg-if",
"derive-deftly", "derive-deftly 1.2.0",
"derive_builder_fork_arti", "derive_builder_fork_arti",
"educe", "educe",
"either", "either",
@@ -9062,7 +9105,7 @@ source = "git+https://github.com/Start9Labs/arti.git?branch=patch%2Fdisable-exit
dependencies = [ dependencies = [
"amplify", "amplify",
"base64ct", "base64ct",
"derive-deftly", "derive-deftly 1.2.0",
"derive_builder_fork_arti", "derive_builder_fork_arti",
"derive_more 2.0.1", "derive_more 2.0.1",
"dyn-clone", "dyn-clone",
@@ -9102,7 +9145,7 @@ version = "0.33.0"
source = "git+https://github.com/Start9Labs/arti.git?branch=patch%2Fdisable-exit#24730694701a83432d791d80802db8bda0699700" source = "git+https://github.com/Start9Labs/arti.git?branch=patch%2Fdisable-exit#24730694701a83432d791d80802db8bda0699700"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"derive-deftly", "derive-deftly 1.2.0",
"derive_more 2.0.1", "derive_more 2.0.1",
"educe", "educe",
"either", "either",
@@ -9146,7 +9189,7 @@ source = "git+https://github.com/Start9Labs/arti.git?branch=patch%2Fdisable-exit
dependencies = [ dependencies = [
"cipher 0.4.4", "cipher 0.4.4",
"data-encoding", "data-encoding",
"derive-deftly", "derive-deftly 1.2.0",
"derive_more 2.0.1", "derive_more 2.0.1",
"digest 0.10.7", "digest 0.10.7",
"equix", "equix",
@@ -9180,7 +9223,7 @@ dependencies = [
"async-trait", "async-trait",
"base64ct", "base64ct",
"cfg-if", "cfg-if",
"derive-deftly", "derive-deftly 1.2.0",
"derive_builder_fork_arti", "derive_builder_fork_arti",
"derive_more 2.0.1", "derive_more 2.0.1",
"digest 0.10.7", "digest 0.10.7",
@@ -9233,7 +9276,7 @@ name = "tor-key-forge"
version = "0.33.0" version = "0.33.0"
source = "git+https://github.com/Start9Labs/arti.git?branch=patch%2Fdisable-exit#24730694701a83432d791d80802db8bda0699700" source = "git+https://github.com/Start9Labs/arti.git?branch=patch%2Fdisable-exit#24730694701a83432d791d80802db8bda0699700"
dependencies = [ dependencies = [
"derive-deftly", "derive-deftly 1.2.0",
"derive_more 2.0.1", "derive_more 2.0.1",
"downcast-rs 2.0.2", "downcast-rs 2.0.2",
"paste", "paste",
@@ -9256,7 +9299,7 @@ dependencies = [
"amplify", "amplify",
"arrayvec 0.7.6", "arrayvec 0.7.6",
"cfg-if", "cfg-if",
"derive-deftly", "derive-deftly 1.2.0",
"derive_builder_fork_arti", "derive_builder_fork_arti",
"derive_more 2.0.1", "derive_more 2.0.1",
"downcast-rs 2.0.2", "downcast-rs 2.0.2",
@@ -9295,7 +9338,7 @@ dependencies = [
"base64ct", "base64ct",
"by_address", "by_address",
"caret", "caret",
"derive-deftly", "derive-deftly 1.2.0",
"derive_builder_fork_arti", "derive_builder_fork_arti",
"derive_more 2.0.1", "derive_more 2.0.1",
"hex", "hex",
@@ -9323,7 +9366,7 @@ dependencies = [
"ctr 0.9.2", "ctr 0.9.2",
"curve25519-dalek 4.1.3", "curve25519-dalek 4.1.3",
"der-parser 10.0.0", "der-parser 10.0.0",
"derive-deftly", "derive-deftly 1.2.0",
"derive_more 2.0.1", "derive_more 2.0.1",
"digest 0.10.7", "digest 0.10.7",
"ed25519-dalek 2.2.0", "ed25519-dalek 2.2.0",
@@ -9371,7 +9414,7 @@ version = "0.33.0"
source = "git+https://github.com/Start9Labs/arti.git?branch=patch%2Fdisable-exit#24730694701a83432d791d80802db8bda0699700" source = "git+https://github.com/Start9Labs/arti.git?branch=patch%2Fdisable-exit#24730694701a83432d791d80802db8bda0699700"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"derive-deftly", "derive-deftly 1.2.0",
"derive_more 2.0.1", "derive_more 2.0.1",
"dyn-clone", "dyn-clone",
"educe", "educe",
@@ -9435,7 +9478,7 @@ dependencies = [
"base64ct", "base64ct",
"bitflags 2.10.0", "bitflags 2.10.0",
"cipher 0.4.4", "cipher 0.4.4",
"derive-deftly", "derive-deftly 1.2.0",
"derive_builder_fork_arti", "derive_builder_fork_arti",
"derive_more 2.0.1", "derive_more 2.0.1",
"digest 0.10.7", "digest 0.10.7",
@@ -9478,7 +9521,7 @@ version = "0.33.0"
source = "git+https://github.com/Start9Labs/arti.git?branch=patch%2Fdisable-exit#24730694701a83432d791d80802db8bda0699700" source = "git+https://github.com/Start9Labs/arti.git?branch=patch%2Fdisable-exit#24730694701a83432d791d80802db8bda0699700"
dependencies = [ dependencies = [
"amplify", "amplify",
"derive-deftly", "derive-deftly 1.2.0",
"derive_more 2.0.1", "derive_more 2.0.1",
"filetime", "filetime",
"fs-mistrust", "fs-mistrust",
@@ -9514,7 +9557,7 @@ dependencies = [
"cipher 0.4.4", "cipher 0.4.4",
"coarsetime", "coarsetime",
"criterion-cycles-per-byte", "criterion-cycles-per-byte",
"derive-deftly", "derive-deftly 1.2.0",
"derive_builder_fork_arti", "derive_builder_fork_arti",
"derive_more 2.0.1", "derive_more 2.0.1",
"digest 0.10.7", "digest 0.10.7",
@@ -9629,7 +9672,7 @@ dependencies = [
"amplify", "amplify",
"assert_matches", "assert_matches",
"async-trait", "async-trait",
"derive-deftly", "derive-deftly 1.2.0",
"derive_more 2.0.1", "derive_more 2.0.1",
"educe", "educe",
"futures", "futures",
@@ -9656,7 +9699,7 @@ source = "git+https://github.com/Start9Labs/arti.git?branch=patch%2Fdisable-exit
dependencies = [ dependencies = [
"amplify", "amplify",
"caret", "caret",
"derive-deftly", "derive-deftly 1.2.0",
"educe", "educe",
"safelog", "safelog",
"subtle", "subtle",
@@ -9670,7 +9713,7 @@ name = "tor-units"
version = "0.33.0" version = "0.33.0"
source = "git+https://github.com/Start9Labs/arti.git?branch=patch%2Fdisable-exit#24730694701a83432d791d80802db8bda0699700" source = "git+https://github.com/Start9Labs/arti.git?branch=patch%2Fdisable-exit#24730694701a83432d791d80802db8bda0699700"
dependencies = [ dependencies = [
"derive-deftly", "derive-deftly 1.2.0",
"derive_more 2.0.1", "derive_more 2.0.1",
"serde", "serde",
"thiserror 2.0.17", "thiserror 2.0.17",
@@ -9795,7 +9838,7 @@ checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -9886,7 +9929,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04659ddb06c87d233c566112c1c9c5b9e98256d9af50ec3bc9c8327f873a7568" checksum = "04659ddb06c87d233c566112c1c9c5b9e98256d9af50ec3bc9c8327f873a7568"
dependencies = [ dependencies = [
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -9901,7 +9944,6 @@ version = "9.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b44017f9f875786e543595076374b9ef7d13465a518dd93d6ccdbf5b432dde8c" checksum = "b44017f9f875786e543595076374b9ef7d13465a518dd93d6ccdbf5b432dde8c"
dependencies = [ dependencies = [
"chrono",
"thiserror 1.0.69", "thiserror 1.0.69",
"ts-rs-macros", "ts-rs-macros",
] ]
@@ -9914,7 +9956,7 @@ checksum = "c88cc88fd23b5a04528f3a8436024f20010a16ec18eb23c164b1242f65860130"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
"termcolor", "termcolor",
] ]
@@ -9971,7 +10013,7 @@ checksum = "1ecb9ecf7799210407c14a8cfdfe0173365780968dc57973ed082211958e0b18"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -10199,7 +10241,7 @@ checksum = "d674d135b4a8c1d7e813e2f8d1c9a58308aee4a680323066025e53132218bd91"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -10222,7 +10264,7 @@ checksum = "de41688745bbd6ed24e2f4923026911b523f0c057e10f86f44652a20e65555ce"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -10349,7 +10391,7 @@ dependencies = [
"bumpalo", "bumpalo",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
"wasm-bindgen-shared", "wasm-bindgen-shared",
] ]
@@ -10630,7 +10672,7 @@ checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -10641,7 +10683,7 @@ checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -11230,7 +11272,7 @@ checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
"synstructure", "synstructure",
] ]
@@ -11277,7 +11319,7 @@ dependencies = [
"proc-macro-crate", "proc-macro-crate",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
"zbus_names", "zbus_names",
"zvariant", "zvariant",
"zvariant_utils", "zvariant_utils",
@@ -11312,7 +11354,7 @@ checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -11332,7 +11374,7 @@ checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
"synstructure", "synstructure",
] ]
@@ -11353,7 +11395,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -11387,7 +11429,7 @@ checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
] ]
[[package]] [[package]]
@@ -11441,7 +11483,7 @@ dependencies = [
"proc-macro-crate", "proc-macro-crate",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.110", "syn 2.0.108",
"zvariant_utils", "zvariant_utils",
] ]
@@ -11454,6 +11496,6 @@ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"serde", "serde",
"syn 2.0.110", "syn 2.0.108",
"winnow", "winnow",
] ]

View File

@@ -1,5 +1,2 @@
[build] [build]
pre-build = ["apt-get update && apt-get install -y rsync"] pre-build = ["apt-get update && apt-get install -y rsync"]
[build.env]
passthrough = ["RUST_BACKTRACE"]

View File

@@ -2,6 +2,8 @@
cd "$(dirname "${BASH_SOURCE[0]}")" cd "$(dirname "${BASH_SOURCE[0]}")"
source ./builder-alias.sh
set -ea set -ea
shopt -s expand_aliases shopt -s expand_aliases
@@ -18,15 +20,20 @@ if [ "$ARCH" = "arm64" ]; then
ARCH="aarch64" ARCH="aarch64"
fi fi
RUST_ARCH="$ARCH"
if [ "$ARCH" = "riscv64" ]; then
RUST_ARCH="riscv64gc"
fi
if [ -z "${KERNEL_NAME:-}" ]; then if [ -z "${KERNEL_NAME:-}" ]; then
KERNEL_NAME=$(uname -s) KERNEL_NAME=$(uname -s)
fi fi
if [ -z "${TARGET:-}" ]; then if [ -z "${TARGET:-}" ]; then
if [ "$KERNEL_NAME" = "Linux" ]; then if [ "$KERNEL_NAME" = "Linux" ]; then
TARGET="$ARCH-unknown-linux-musl" TARGET="$RUST_ARCH-unknown-linux-musl"
elif [ "$KERNEL_NAME" = "Darwin" ]; then elif [ "$KERNEL_NAME" = "Darwin" ]; then
TARGET="$ARCH-apple-darwin" TARGET="$RUST_ARCH-apple-darwin"
else else
>&2 echo "unknown kernel $KERNEL_NAME" >&2 echo "unknown kernel $KERNEL_NAME"
exit 1 exit 1
@@ -53,4 +60,7 @@ fi
echo "FEATURES=\"$FEATURES\"" echo "FEATURES=\"$FEATURES\""
echo "RUSTFLAGS=\"$RUSTFLAGS\"" echo "RUSTFLAGS=\"$RUSTFLAGS\""
cross build --manifest-path=./core/Cargo.toml $BUILD_FLAGS --no-default-features --features $FEATURE_ARGS --locked --bin start-cli --target=$TARGET rust-zig-builder cargo zigbuild --manifest-path=./core/Cargo.toml $BUILD_FLAGS --no-default-features --features $FEATURE_ARGS --locked --bin start-cli --target=$TARGET
if [ "$(ls -nd "core/target/$TARGET/release/start-cli" | awk '{ print $3 }')" != "$UID" ]; then
rust-zig-builder sh -c "cd core && chown -R $UID:$UID target && chown -R $UID:$UID /root/.cargo"
fi

View File

@@ -2,6 +2,8 @@
cd "$(dirname "${BASH_SOURCE[0]}")" cd "$(dirname "${BASH_SOURCE[0]}")"
source ./builder-alias.sh
set -ea set -ea
shopt -s expand_aliases shopt -s expand_aliases
@@ -33,4 +35,7 @@ fi
echo "FEATURES=\"$FEATURES\"" echo "FEATURES=\"$FEATURES\""
echo "RUSTFLAGS=\"$RUSTFLAGS\"" echo "RUSTFLAGS=\"$RUSTFLAGS\""
cross build --manifest-path=./core/Cargo.toml $BUILD_FLAGS --no-default-features --features cli-container,$FEATURES --locked --bin containerbox --target=$RUST_ARCH-unknown-linux-musl rust-zig-builder cargo zigbuild --manifest-path=./core/Cargo.toml $BUILD_FLAGS --no-default-features --features cli-container,$FEATURES --locked --bin containerbox --target=$RUST_ARCH-unknown-linux-musl
if [ "$(ls -nd "core/target/$RUST_ARCH-unknown-linux-musl/release/containerbox" | awk '{ print $3 }')" != "$UID" ]; then
rust-zig-builder sh -c "chown -R $UID:$UID core/target && chown -R $UID:$UID /root/.cargo"
fi

View File

@@ -2,6 +2,8 @@
cd "$(dirname "${BASH_SOURCE[0]}")" cd "$(dirname "${BASH_SOURCE[0]}")"
source ./builder-alias.sh
set -ea set -ea
shopt -s expand_aliases shopt -s expand_aliases
@@ -33,4 +35,7 @@ fi
echo "FEATURES=\"$FEATURES\"" echo "FEATURES=\"$FEATURES\""
echo "RUSTFLAGS=\"$RUSTFLAGS\"" echo "RUSTFLAGS=\"$RUSTFLAGS\""
cross build --manifest-path=./core/Cargo.toml $BUILD_FLAGS --no-default-features --features cli-registry,registry,$FEATURES --locked --bin registrybox --target=$RUST_ARCH-unknown-linux-musl rust-zig-builder cargo zigbuild --manifest-path=./core/Cargo.toml $BUILD_FLAGS --no-default-features --features cli-registry,registry,$FEATURES --locked --bin registrybox --target=$RUST_ARCH-unknown-linux-musl
if [ "$(ls -nd "core/target/$RUST_ARCH-unknown-linux-musl/release/registrybox" | awk '{ print $3 }')" != "$UID" ]; then
rust-zig-builder sh -c "chown -R $UID:$UID core/target && chown -R $UID:$UID /root/.cargo"
fi

View File

@@ -2,6 +2,8 @@
cd "$(dirname "${BASH_SOURCE[0]}")" cd "$(dirname "${BASH_SOURCE[0]}")"
source ./builder-alias.sh
set -ea set -ea
shopt -s expand_aliases shopt -s expand_aliases
@@ -33,4 +35,7 @@ fi
echo "FEATURES=\"$FEATURES\"" echo "FEATURES=\"$FEATURES\""
echo "RUSTFLAGS=\"$RUSTFLAGS\"" echo "RUSTFLAGS=\"$RUSTFLAGS\""
cross build --manifest-path=./core/Cargo.toml $BUILD_FLAGS --no-default-features --features cli,startd,$FEATURES --locked --bin startbox --target=$RUST_ARCH-unknown-linux-musl rust-zig-builder cargo zigbuild --manifest-path=./core/Cargo.toml $BUILD_FLAGS --no-default-features --features cli,startd,$FEATURES --locked --bin startbox --target=$RUST_ARCH-unknown-linux-musl
if [ "$(ls -nd "core/target/$RUST_ARCH-unknown-linux-musl/release/startbox" | awk '{ print $3 }')" != "$UID" ]; then
rust-zig-builder sh -c "chown -R $UID:$UID core/target && chown -R $UID:$UID /root/.cargo"
fi

View File

@@ -2,6 +2,8 @@
cd "$(dirname "${BASH_SOURCE[0]}")" cd "$(dirname "${BASH_SOURCE[0]}")"
source ./builder-alias.sh
set -ea set -ea
shopt -s expand_aliases shopt -s expand_aliases
@@ -24,9 +26,6 @@ if [ "$ARCH" = "riscv64" ]; then
fi fi
cd .. cd ..
rm -rf core/startos/bindings/
FEATURES="$(echo $ENVIRONMENT | sed 's/-/,/g')" FEATURES="$(echo $ENVIRONMENT | sed 's/-/,/g')"
RUSTFLAGS="" RUSTFLAGS=""
if [[ "${ENVIRONMENT}" =~ (^|-)console($|-) ]]; then if [[ "${ENVIRONMENT}" =~ (^|-)console($|-) ]]; then
@@ -34,16 +33,7 @@ if [[ "${ENVIRONMENT}" =~ (^|-)console($|-) ]]; then
fi fi
echo "FEATURES=\"$FEATURES\"" echo "FEATURES=\"$FEATURES\""
echo "RUSTFLAGS=\"$RUSTFLAGS\"" echo "RUSTFLAGS=\"$RUSTFLAGS\""
cross test --manifest-path=./core/Cargo.toml $BUILD_FLAGS --no-default-features --features test,$FEATURES --locked 'export_bindings_' rust-zig-builder cargo test --manifest-path=./core/Cargo.toml $BUILD_FLAGS --no-default-features --features test,$FEATURES --locked 'export_bindings_'
if [ "$(ls -nd "core/startos/bindings" | awk '{ print $3 }')" != "$UID" ]; then
cd core/startos/bindings rust-zig-builder sh -c "chown -R $UID:$UID core/target && chown -R $UID:$UID core/startos/bindings && chown -R $UID:$UID /root/.cargo"
fi
for folder in $(find . -type d); do
(
cd $folder
find . -name '*.ts' -maxdepth 1 | sed 's/\.\/\([^.]*\)\.ts/export * from ".\/\1";/g' | grep -v '"./index"' | tee ./index.ts
find . -mindepth 1 -maxdepth 1 -type d | sed 's/\.\/\([^.]*\)/export * as \1 from ".\/\1";/g' | grep -v '"./index"' | tee -a ./index.ts
)
done
find . -name '*.ts' | xargs -P $(nproc) -I % npm --prefix ../../../sdk exec -- prettier --config ../../../sdk/base/package.json -w %

View File

@@ -2,6 +2,8 @@
cd "$(dirname "${BASH_SOURCE[0]}")" cd "$(dirname "${BASH_SOURCE[0]}")"
source ./builder-alias.sh
set -ea set -ea
shopt -s expand_aliases shopt -s expand_aliases
@@ -33,4 +35,7 @@ fi
echo "FEATURES=\"$FEATURES\"" echo "FEATURES=\"$FEATURES\""
echo "RUSTFLAGS=\"$RUSTFLAGS\"" echo "RUSTFLAGS=\"$RUSTFLAGS\""
cross build --manifest-path=./core/Cargo.toml $BUILD_FLAGS --no-default-features --features cli-tunnel,tunnel,$FEATURES --locked --bin tunnelbox --target=$RUST_ARCH-unknown-linux-musl rust-zig-builder cargo zigbuild --manifest-path=./core/Cargo.toml $BUILD_FLAGS --no-default-features --features cli-tunnel,tunnel,$FEATURES --locked --bin tunnelbox --target=$RUST_ARCH-unknown-linux-musl
if [ "$(ls -nd "core/target/$RUST_ARCH-unknown-linux-musl/release/tunnelbox" | awk '{ print $3 }')" != "$UID" ]; then
rust-zig-builder sh -c "chown -R $UID:$UID core/target && chown -R $UID:$UID /root/.cargo"
fi

View File

@@ -1,3 +1,8 @@
#!/bin/bash #!/bin/bash
alias 'rust-musl-builder'='docker run $USE_TTY --rm -e "RUSTFLAGS=$RUSTFLAGS" -e SCCACHE_GHA_ENABLED -e SCCACHE_GHA_VERSION -e ACTIONS_RESULTS_URL -e ACTIONS_RUNTIME_TOKEN -v "$HOME/.cargo/registry":/root/.cargo/registry -v "$HOME/.cargo/git":/root/.cargo/git -v "$HOME/.cache/sccache":/root/.cache/sccache -v "$(pwd)":/home/rust/src -w /home/rust/src -P start9/rust-musl-cross:$ARCH-musl' USE_TTY=
if tty -s; then
USE_TTY="-it"
fi
alias 'rust-zig-builder'='docker run '"$USE_TTY"' --rm -e "RUSTFLAGS=$RUSTFLAGS" -e "CFLAGS=-D_FORTIFY_SOURCE=2" -e "CXXFLAGS=-D_FORTIFY_SOURCE=2" -e SCCACHE_GHA_ENABLED -e SCCACHE_GHA_VERSION -e ACTIONS_RESULTS_URL -e ACTIONS_RUNTIME_TOKEN -v "$HOME/.cargo/registry":/usr/local/cargo/registry -v "$HOME/.cargo/git":/root/.cargo/git -v "$HOME/.cache/sccache":/root/.cache/sccache -v "$(pwd)":/workdir -w /workdir -P start9/cargo-zigbuild'

View File

@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type ServiceInterfaceId = string;

View File

@@ -8,7 +8,7 @@ use ts_rs::TS;
use crate::{FromStrParser, Id}; use crate::{FromStrParser, Id};
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, TS)] #[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, TS)]
#[ts(type = "string")] #[ts(export, type = "string")]
pub struct ServiceInterfaceId(Id); pub struct ServiceInterfaceId(Id);
impl From<Id> for ServiceInterfaceId { impl From<Id> for ServiceInterfaceId {
fn from(id: Id) -> Self { fn from(id: Id) -> Self {

View File

@@ -93,7 +93,6 @@ async-compression = { version = "0.4.32", features = [
] } ] }
async-stream = "0.3.5" async-stream = "0.3.5"
async-trait = "0.1.74" async-trait = "0.1.74"
aws-lc-sys = { version = "0.32", features = ["bindgen"] }
axum = { version = "0.8.4", features = ["ws"] } axum = { version = "0.8.4", features = ["ws"] }
backtrace-on-stack-overflow = { version = "0.3.0", optional = true } backtrace-on-stack-overflow = { version = "0.3.0", optional = true }
barrage = "0.2.3" barrage = "0.2.3"
@@ -223,7 +222,7 @@ regex = "1.10.2"
reqwest = { version = "0.12.4", features = ["json", "socks", "stream"] } reqwest = { version = "0.12.4", features = ["json", "socks", "stream"] }
reqwest_cookie_store = "0.8.0" reqwest_cookie_store = "0.8.0"
rpassword = "7.2.0" rpassword = "7.2.0"
rpc-toolkit = { git = "https://github.com/Start9Labs/rpc-toolkit.git", branch = "master" } rpc-toolkit = { git = "https://github.com/Start9Labs/rpc-toolkit.git", rev = "068db90" }
rust-argon2 = "2.0.0" rust-argon2 = "2.0.0"
safelog = { version = "0.4.8", git = "https://github.com/Start9Labs/arti.git", branch = "patch/disable-exit", optional = true } safelog = { version = "0.4.8", git = "https://github.com/Start9Labs/arti.git", branch = "patch/disable-exit", optional = true }
semver = { version = "1.0.20", features = ["serde"] } semver = { version = "1.0.20", features = ["serde"] }
@@ -252,7 +251,7 @@ termion = "4.0.5"
textwrap = "0.16.1" textwrap = "0.16.1"
thiserror = "2.0.12" thiserror = "2.0.12"
tokio = { version = "1.38.1", features = ["full"] } tokio = { version = "1.38.1", features = ["full"] }
tokio-rustls = "0.26.0" tokio-rustls = "0.26.4"
tokio-stream = { version = "0.1.14", features = ["io-util", "net", "sync"] } tokio-stream = { version = "0.1.14", features = ["io-util", "net", "sync"] }
tokio-tar = { git = "https://github.com/dr-bonez/tokio-tar.git" } tokio-tar = { git = "https://github.com/dr-bonez/tokio-tar.git" }
tokio-tungstenite = { version = "0.26.2", features = ["native-tls", "url"] } tokio-tungstenite = { version = "0.26.2", features = ["native-tls", "url"] }
@@ -280,7 +279,7 @@ tracing-error = "0.2.0"
tracing-futures = "0.2.5" tracing-futures = "0.2.5"
tracing-journald = "0.3.0" tracing-journald = "0.3.0"
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] } tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
ts-rs = { version = "9.0.1", features = ["chrono-impl"] } ts-rs = "9.0.1"
typed-builder = "0.21.0" typed-builder = "0.21.0"
unix-named-pipe = "0.2.0" unix-named-pipe = "0.2.0"
url = { version = "2.4.1", features = ["serde"] } url = { version = "2.4.1", features = ["serde"] }

View File

@@ -4,7 +4,7 @@ use clap::{CommandFactory, FromArgMatches, Parser};
pub use models::ActionId; pub use models::ActionId;
use models::{PackageId, ReplayId}; use models::{PackageId, ReplayId};
use qrcode::QrCode; use qrcode::QrCode;
use rpc_toolkit::{from_fn_async, Context, HandlerExt, ParentHandler}; use rpc_toolkit::{Context, HandlerExt, ParentHandler, from_fn_async};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use tracing::instrument; use tracing::instrument;
use ts_rs::TS; use ts_rs::TS;
@@ -14,22 +14,9 @@ use crate::db::model::package::TaskSeverity;
use crate::prelude::*; use crate::prelude::*;
use crate::rpc_continuations::Guid; use crate::rpc_continuations::Guid;
use crate::util::serde::{ use crate::util::serde::{
display_serializable, HandlerExtSerde, StdinDeserializable, WithIoFormat, HandlerExtSerde, StdinDeserializable, WithIoFormat, display_serializable,
}; };
#[test]
fn export_bindings_action() {
use crate::db::model::package::{ActionMetadata, Task};
const OUT_DIR: &str = "./bindings/action";
ActionId::export_all_to(OUT_DIR).unwrap();
ActionInput::export_all_to(OUT_DIR).unwrap();
ActionResult::export_all_to(OUT_DIR).unwrap();
ActionMetadata::export_all_to(OUT_DIR).unwrap();
Task::export_all_to(OUT_DIR).unwrap();
}
pub fn action_api<C: Context>() -> ParentHandler<C> { pub fn action_api<C: Context>() -> ParentHandler<C> {
ParentHandler::new() ParentHandler::new()
.subcommand( .subcommand(
@@ -62,6 +49,7 @@ pub fn action_api<C: Context>() -> ParentHandler<C> {
} }
#[derive(Debug, Clone, Deserialize, Serialize, TS)] #[derive(Debug, Clone, Deserialize, Serialize, TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct ActionInput { pub struct ActionInput {
#[serde(default)] #[serde(default)]
@@ -98,6 +86,7 @@ pub async fn get_action_input(
#[derive(Debug, Serialize, Deserialize, TS)] #[derive(Debug, Serialize, Deserialize, TS)]
#[serde(tag = "version")] #[serde(tag = "version")]
#[ts(export)]
pub enum ActionResult { pub enum ActionResult {
#[serde(rename = "0")] #[serde(rename = "0")]
V0(ActionResultV0), V0(ActionResultV0),

View File

@@ -70,6 +70,7 @@ pub async fn write_shadow(password: &str) -> Result<(), Error> {
#[derive(Clone, Serialize, Deserialize, TS)] #[derive(Clone, Serialize, Deserialize, TS)]
#[serde(untagged)] #[serde(untagged)]
#[ts(export)]
pub enum PasswordType { pub enum PasswordType {
EncryptedWire(EncryptedWire), EncryptedWire(EncryptedWire),
String(String), String(String),
@@ -148,6 +149,14 @@ where
.no_display() .no_display()
.with_about("Reset password"), .with_about("Reset password"),
) )
.subcommand(
"get-pubkey",
from_fn_async(get_pubkey)
.with_metadata("authenticated", Value::Bool(false))
.no_display()
.with_about("Get public key derived from server private key")
.with_call_remote::<CliContext>(),
)
} }
#[test] #[test]
@@ -207,6 +216,7 @@ pub fn check_password(hash: &str, password: &str) -> Result<(), Error> {
#[derive(Deserialize, Serialize, TS)] #[derive(Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct LoginParams { pub struct LoginParams {
password: String, password: String,
#[ts(skip)] #[ts(skip)]
@@ -284,6 +294,7 @@ pub async fn logout<C: AuthContext>(
#[derive(Debug, Clone, Deserialize, Serialize, TS)] #[derive(Debug, Clone, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct Session { pub struct Session {
#[ts(type = "string")] #[ts(type = "string")]
pub logged_in: DateTime<Utc>, pub logged_in: DateTime<Utc>,
@@ -294,6 +305,7 @@ pub struct Session {
#[derive(Deserialize, Serialize, TS)] #[derive(Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct SessionList { pub struct SessionList {
#[ts(type = "string | null")] #[ts(type = "string | null")]
current: Option<InternedString>, current: Option<InternedString>,
@@ -383,7 +395,7 @@ pub async fn list<C: AuthContext>(
}) })
} }
#[derive(Debug, Clone, Serialize, Deserialize, TS)] #[derive(Debug, Clone, Serialize, Deserialize)]
struct KillSessionId(InternedString); struct KillSessionId(InternedString);
impl KillSessionId { impl KillSessionId {

View File

@@ -36,7 +36,7 @@ impl Map for CifsTargets {
} }
} }
#[derive(Debug, Deserialize, Serialize, TS)] #[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct CifsBackupTarget { pub struct CifsBackupTarget {
hostname: String, hostname: String,

View File

@@ -34,11 +34,11 @@ use crate::util::serde::{
pub mod cifs; pub mod cifs;
#[derive(Debug, Deserialize, Serialize, TS)] #[derive(Debug, Deserialize, Serialize)]
#[serde(tag = "type")] #[serde(tag = "type")]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[serde(rename_all_fields = "camelCase")]
pub enum BackupTarget { pub enum BackupTarget {
#[serde(rename_all = "camelCase")]
Disk { Disk {
vendor: Option<String>, vendor: Option<String>,
model: Option<String>, model: Option<String>,
@@ -210,21 +210,19 @@ pub async fn list(ctx: RpcContext) -> Result<BTreeMap<BackupTargetId, BackupTarg
.collect()) .collect())
} }
#[derive(Clone, Debug, Default, Deserialize, Serialize, TS)] #[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct BackupInfo { pub struct BackupInfo {
#[ts(type = "string")]
pub version: Version, pub version: Version,
pub timestamp: Option<DateTime<Utc>>, pub timestamp: Option<DateTime<Utc>>,
pub package_backups: BTreeMap<PackageId, PackageBackupInfo>, pub package_backups: BTreeMap<PackageId, PackageBackupInfo>,
} }
#[derive(Clone, Debug, Deserialize, Serialize, TS)] #[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct PackageBackupInfo { pub struct PackageBackupInfo {
pub title: InternedString, pub title: InternedString,
pub version: VersionString, pub version: VersionString,
#[ts(type = "string")]
pub os_version: Version, pub os_version: Version,
pub timestamp: DateTime<Utc>, pub timestamp: DateTime<Utc>,
} }

View File

@@ -22,7 +22,7 @@ use crate::tunnel::tunnel_router;
use crate::tunnel::web::TunnelCertHandler; use crate::tunnel::web::TunnelCertHandler;
use crate::util::logger::LOGGER; use crate::util::logger::LOGGER;
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
enum WebserverListener { enum WebserverListener {
Http, Http,
Https(SocketAddr), Https(SocketAddr),

View File

@@ -40,6 +40,7 @@ lazy_static::lazy_static! {
#[derive(Debug, Clone, Deserialize, Serialize, TS)] #[derive(Debug, Clone, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct SetupResult { pub struct SetupResult {
pub tor_addresses: Vec<String>, pub tor_addresses: Vec<String>,
#[ts(type = "string")] #[ts(type = "string")]

View File

@@ -1,6 +1,7 @@
pub mod model; pub mod model;
pub mod prelude; pub mod prelude;
use std::panic::UnwindSafe;
use std::path::PathBuf; use std::path::PathBuf;
use std::sync::Arc; use std::sync::Arc;
use std::time::Duration; use std::time::Duration;
@@ -55,18 +56,9 @@ pub fn db<C: Context>() -> ParentHandler<C> {
"dump", "dump",
from_fn_async(cli_dump) from_fn_async(cli_dump)
.with_display_serializable() .with_display_serializable()
.no_ts()
.with_about("Filter/query db to display tables and records"), .with_about("Filter/query db to display tables and records"),
) )
.subcommand( .subcommand("dump", from_fn_async(dump).no_cli())
"dump",
from_fn_async(dump)
.custom_ts(
DumpParams::inline_flattened(),
format!("{{ id: number; value: unknown }}"),
)
.no_cli(),
)
.subcommand( .subcommand(
"subscribe", "subscribe",
from_fn_async(subscribe) from_fn_async(subscribe)
@@ -81,7 +73,6 @@ pub fn db<C: Context>() -> ParentHandler<C> {
"apply", "apply",
from_fn_async(cli_apply) from_fn_async(cli_apply)
.no_display() .no_display()
.no_ts()
.with_about("Update a db record"), .with_about("Update a db record"),
) )
.subcommand("apply", from_fn_async(apply).no_cli()) .subcommand("apply", from_fn_async(apply).no_cli())

View File

@@ -20,6 +20,7 @@ use crate::status::MainStatus;
use crate::util::serde::{Pem, is_partial_of}; use crate::util::serde::{Pem, is_partial_of};
#[derive(Debug, Default, Deserialize, Serialize, TS)] #[derive(Debug, Default, Deserialize, Serialize, TS)]
#[ts(export)]
pub struct AllPackageData(pub BTreeMap<PackageId, PackageDataEntry>); pub struct AllPackageData(pub BTreeMap<PackageId, PackageDataEntry>);
impl Map for AllPackageData { impl Map for AllPackageData {
type Key = PackageId; type Key = PackageId;
@@ -42,6 +43,7 @@ pub enum ManifestPreference {
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[serde(tag = "state")] #[serde(tag = "state")]
#[model = "Model<Self>"] #[model = "Model<Self>"]
#[ts(export)]
pub enum PackageState { pub enum PackageState {
Installing(InstallingState), Installing(InstallingState),
Restoring(InstallingState), Restoring(InstallingState),
@@ -275,6 +277,7 @@ impl Model<PackageState> {
#[derive(Debug, Deserialize, Serialize, HasModel, TS)] #[derive(Debug, Deserialize, Serialize, HasModel, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[model = "Model<Self>"] #[model = "Model<Self>"]
#[ts(export)]
pub struct InstallingState { pub struct InstallingState {
pub installing_info: InstallingInfo, pub installing_info: InstallingInfo,
} }
@@ -282,6 +285,7 @@ pub struct InstallingState {
#[derive(Debug, Deserialize, Serialize, HasModel, TS)] #[derive(Debug, Deserialize, Serialize, HasModel, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[model = "Model<Self>"] #[model = "Model<Self>"]
#[ts(export)]
pub struct UpdatingState { pub struct UpdatingState {
pub manifest: Manifest, pub manifest: Manifest,
pub s9pk: PathBuf, pub s9pk: PathBuf,
@@ -291,6 +295,7 @@ pub struct UpdatingState {
#[derive(Debug, Deserialize, Serialize, HasModel, TS)] #[derive(Debug, Deserialize, Serialize, HasModel, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[model = "Model<Self>"] #[model = "Model<Self>"]
#[ts(export)]
pub struct InstalledState { pub struct InstalledState {
pub manifest: Manifest, pub manifest: Manifest,
} }
@@ -298,11 +303,13 @@ pub struct InstalledState {
#[derive(Debug, Deserialize, Serialize, HasModel, TS)] #[derive(Debug, Deserialize, Serialize, HasModel, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[model = "Model<Self>"] #[model = "Model<Self>"]
#[ts(export)]
pub struct InstallingInfo { pub struct InstallingInfo {
pub new_manifest: Manifest, pub new_manifest: Manifest,
pub progress: FullProgress, pub progress: FullProgress,
} }
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, TS)] #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, TS)]
#[ts(export)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "kebab-case")]
pub enum AllowedStatuses { pub enum AllowedStatuses {
OnlyRunning, OnlyRunning,
@@ -337,6 +344,7 @@ pub struct ActionMetadata {
} }
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, TS)] #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, TS)]
#[ts(export)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "kebab-case")]
#[serde(rename_all_fields = "camelCase")] #[serde(rename_all_fields = "camelCase")]
pub enum ActionVisibility { pub enum ActionVisibility {
@@ -353,6 +361,7 @@ impl Default for ActionVisibility {
#[derive(Debug, Deserialize, Serialize, HasModel, TS)] #[derive(Debug, Deserialize, Serialize, HasModel, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[model = "Model<Self>"] #[model = "Model<Self>"]
#[ts(export)]
pub struct PackageDataEntry { pub struct PackageDataEntry {
pub state_info: PackageState, pub state_info: PackageState,
pub s9pk: PathBuf, pub s9pk: PathBuf,
@@ -379,6 +388,7 @@ impl AsRef<PackageDataEntry> for PackageDataEntry {
} }
#[derive(Debug, Clone, Default, Deserialize, Serialize, TS)] #[derive(Debug, Clone, Default, Deserialize, Serialize, TS)]
#[ts(export)]
pub struct CurrentDependencies(pub BTreeMap<PackageId, CurrentDependencyInfo>); pub struct CurrentDependencies(pub BTreeMap<PackageId, CurrentDependencyInfo>);
impl CurrentDependencies { impl CurrentDependencies {
pub fn map( pub fn map(
@@ -430,6 +440,7 @@ pub enum CurrentDependencyKind {
#[derive(Clone, Debug, Deserialize, Serialize, TS, HasModel)] #[derive(Clone, Debug, Deserialize, Serialize, TS, HasModel)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
#[model = "Model<Self>"] #[model = "Model<Self>"]
pub struct TaskEntry { pub struct TaskEntry {
pub task: Task, pub task: Task,
@@ -438,6 +449,7 @@ pub struct TaskEntry {
#[derive(Clone, Debug, Deserialize, Serialize, TS, HasModel)] #[derive(Clone, Debug, Deserialize, Serialize, TS, HasModel)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
#[model = "Model<Self>"] #[model = "Model<Self>"]
pub struct Task { pub struct Task {
pub package_id: PackageId, pub package_id: PackageId,
@@ -454,6 +466,7 @@ pub struct Task {
#[derive(Clone, Debug, Deserialize, Serialize, TS, PartialEq, Eq, PartialOrd, Ord)] #[derive(Clone, Debug, Deserialize, Serialize, TS, PartialEq, Eq, PartialOrd, Ord)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "kebab-case")]
#[ts(export)]
pub enum TaskSeverity { pub enum TaskSeverity {
Optional, Optional,
Important, Important,
@@ -467,6 +480,7 @@ impl Default for TaskSeverity {
#[derive(Clone, Debug, Deserialize, Serialize, TS)] #[derive(Clone, Debug, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct TaskTrigger { pub struct TaskTrigger {
#[serde(default)] #[serde(default)]
pub once: bool, pub once: bool,
@@ -475,6 +489,7 @@ pub struct TaskTrigger {
#[derive(Clone, Debug, Deserialize, Serialize, TS)] #[derive(Clone, Debug, Deserialize, Serialize, TS)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "kebab-case")]
#[ts(export)]
pub enum TaskCondition { pub enum TaskCondition {
InputNotMatches, InputNotMatches,
} }

View File

@@ -16,12 +16,12 @@ use serde::{Deserialize, Serialize};
use ts_rs::TS; use ts_rs::TS;
use crate::account::AccountInfo; use crate::account::AccountInfo;
use crate::db::model::package::AllPackageData;
use crate::db::model::Database;
use crate::db::DbAccessByKey; use crate::db::DbAccessByKey;
use crate::db::model::Database;
use crate::db::model::package::AllPackageData;
use crate::net::acme::AcmeProvider; use crate::net::acme::AcmeProvider;
use crate::net::host::binding::{AddSslOptions, BindInfo, BindOptions, NetInfo};
use crate::net::host::Host; use crate::net::host::Host;
use crate::net::host::binding::{AddSslOptions, BindInfo, BindOptions, NetInfo};
use crate::net::utils::ipv6_is_local; use crate::net::utils::ipv6_is_local;
use crate::net::vhost::AlpnInfo; use crate::net::vhost::AlpnInfo;
use crate::prelude::*; use crate::prelude::*;
@@ -33,14 +33,10 @@ use crate::util::serde::MaybeUtf8String;
use crate::version::{Current, VersionT}; use crate::version::{Current, VersionT};
use crate::{ARCH, PLATFORM}; use crate::{ARCH, PLATFORM};
#[test]
fn export_bindings_database() {
Public::export_all_to("./bindings/database/startos").unwrap();
}
#[derive(Debug, Deserialize, Serialize, HasModel, TS)] #[derive(Debug, Deserialize, Serialize, HasModel, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[model = "Model<Self>"] #[model = "Model<Self>"]
#[ts(export)]
pub struct Public { pub struct Public {
pub server_info: ServerInfo, pub server_info: ServerInfo,
pub package_data: AllPackageData, pub package_data: AllPackageData,
@@ -156,6 +152,7 @@ fn get_platform() -> InternedString {
#[derive(Debug, Deserialize, Serialize, HasModel, TS)] #[derive(Debug, Deserialize, Serialize, HasModel, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[model = "Model<Self>"] #[model = "Model<Self>"]
#[ts(export)]
pub struct ServerInfo { pub struct ServerInfo {
#[serde(default = "get_arch")] #[serde(default = "get_arch")]
#[ts(type = "string")] #[ts(type = "string")]
@@ -197,6 +194,7 @@ pub struct ServerInfo {
#[derive(Debug, Default, Deserialize, Serialize, HasModel, TS)] #[derive(Debug, Default, Deserialize, Serialize, HasModel, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[model = "Model<Self>"] #[model = "Model<Self>"]
#[ts(export)]
pub struct NetworkInfo { pub struct NetworkInfo {
pub wifi: WifiInfo, pub wifi: WifiInfo,
pub host: Host, pub host: Host,
@@ -212,6 +210,7 @@ pub struct NetworkInfo {
#[derive(Debug, Default, Deserialize, Serialize, HasModel, TS)] #[derive(Debug, Default, Deserialize, Serialize, HasModel, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[model = "Model<Self>"] #[model = "Model<Self>"]
#[ts(export)]
pub struct DnsSettings { pub struct DnsSettings {
#[ts(type = "string[]")] #[ts(type = "string[]")]
pub dhcp_servers: VecDeque<SocketAddr>, pub dhcp_servers: VecDeque<SocketAddr>,
@@ -222,6 +221,7 @@ pub struct DnsSettings {
#[derive(Clone, Debug, Default, Deserialize, Serialize, HasModel, TS)] #[derive(Clone, Debug, Default, Deserialize, Serialize, HasModel, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[model = "Model<Self>"] #[model = "Model<Self>"]
#[ts(export)]
pub struct NetworkInterfaceInfo { pub struct NetworkInterfaceInfo {
pub name: Option<InternedString>, pub name: Option<InternedString>,
pub public: Option<bool>, pub public: Option<bool>,
@@ -269,6 +269,7 @@ impl NetworkInterfaceInfo {
} }
#[derive(Clone, Debug, Default, PartialEq, Eq, Deserialize, Serialize, TS, HasModel)] #[derive(Clone, Debug, Default, PartialEq, Eq, Deserialize, Serialize, TS, HasModel)]
#[ts(export)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[model = "Model<Self>"] #[model = "Model<Self>"]
pub struct IpInfo { pub struct IpInfo {
@@ -288,6 +289,7 @@ pub struct IpInfo {
} }
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize, TS)] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize, TS)]
#[ts(export)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "kebab-case")]
pub enum NetworkInterfaceType { pub enum NetworkInterfaceType {
Ethernet, Ethernet,
@@ -300,6 +302,7 @@ pub enum NetworkInterfaceType {
#[derive(Debug, Deserialize, Serialize, HasModel, TS)] #[derive(Debug, Deserialize, Serialize, HasModel, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[model = "Model<Self>"] #[model = "Model<Self>"]
#[ts(export)]
pub struct AcmeSettings { pub struct AcmeSettings {
pub contact: Vec<String>, pub contact: Vec<String>,
} }
@@ -320,12 +323,14 @@ impl DbAccessByKey<AcmeSettings> for Database {
#[derive(Debug, Deserialize, Serialize, HasModel, TS)] #[derive(Debug, Deserialize, Serialize, HasModel, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[model = "Model<Self>"] #[model = "Model<Self>"]
#[ts(export)]
pub struct DomainSettings { pub struct DomainSettings {
pub gateway: GatewayId, pub gateway: GatewayId,
} }
#[derive(Debug, Default, Deserialize, Serialize, HasModel, TS)] #[derive(Debug, Default, Deserialize, Serialize, HasModel, TS)]
#[model = "Model<Self>"] #[model = "Model<Self>"]
#[ts(export)]
pub struct BackupProgress { pub struct BackupProgress {
pub complete: bool, pub complete: bool,
} }
@@ -333,6 +338,7 @@ pub struct BackupProgress {
#[derive(Debug, Default, Deserialize, Serialize, HasModel, TS)] #[derive(Debug, Default, Deserialize, Serialize, HasModel, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[model = "Model<Self>"] #[model = "Model<Self>"]
#[ts(export)]
pub struct ServerStatus { pub struct ServerStatus {
pub backup_progress: Option<BTreeMap<PackageId, BackupProgress>>, pub backup_progress: Option<BTreeMap<PackageId, BackupProgress>>,
pub updated: bool, pub updated: bool,
@@ -346,6 +352,7 @@ pub struct ServerStatus {
#[derive(Debug, Default, Deserialize, Serialize, HasModel, TS)] #[derive(Debug, Default, Deserialize, Serialize, HasModel, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[model = "Model<Self>"] #[model = "Model<Self>"]
#[ts(export)]
pub struct WifiInfo { pub struct WifiInfo {
pub enabled: bool, pub enabled: bool,
pub interface: Option<String>, pub interface: Option<String>,
@@ -357,6 +364,7 @@ pub struct WifiInfo {
#[derive(Debug, Deserialize, Serialize, TS)] #[derive(Debug, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct ServerSpecs { pub struct ServerSpecs {
pub cpu: String, pub cpu: String,
pub disk: String, pub disk: String,

View File

@@ -10,7 +10,6 @@ use patch_db::value::InternedString;
pub use patch_db::{HasModel, MutateResult, PatchDb}; pub use patch_db::{HasModel, MutateResult, PatchDb};
use serde::de::DeserializeOwned; use serde::de::DeserializeOwned;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use ts_rs::TS;
use crate::prelude::*; use crate::prelude::*;
@@ -480,24 +479,6 @@ impl<'de, T: DeserializeOwned> Deserialize<'de> for JsonKey<T> {
)) ))
} }
} }
impl<T> TS for JsonKey<T> {
type WithoutGenerics = JsonKey<ts_rs::Dummy>;
fn decl() -> String {
format!("type {} = string", Self::name())
}
fn decl_concrete() -> String {
Self::decl()
}
fn name() -> String {
"JsonKey".into()
}
fn inline() -> String {
"string".into()
}
fn inline_flattened() -> String {
Self::inline()
}
}
#[derive(Debug, Clone, Deserialize, Serialize)] #[derive(Debug, Clone, Deserialize, Serialize)]
pub struct WithTimeData<T> { pub struct WithTimeData<T> {

View File

@@ -6,23 +6,13 @@ use models::PackageId;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use ts_rs::TS; use ts_rs::TS;
use crate::Error;
use crate::prelude::*; use crate::prelude::*;
use crate::util::PathOrUrl; use crate::util::PathOrUrl;
use crate::Error;
#[test]
fn export_bindings_dependencies() {
use crate::service::effects::dependency::{CheckDependenciesResult, DependencyRequirement};
const OUT_DIR: &str = "./bindings/dependencies";
PackageId::export_all_to(OUT_DIR).unwrap();
DependencyRequirement::export_all_to(OUT_DIR).unwrap();
CheckDependenciesResult::export_all_to(OUT_DIR).unwrap();
}
#[derive(Clone, Debug, Default, Deserialize, Serialize, HasModel, TS)] #[derive(Clone, Debug, Default, Deserialize, Serialize, HasModel, TS)]
#[model = "Model<Self>"] #[model = "Model<Self>"]
#[ts(export)]
pub struct Dependencies(pub BTreeMap<PackageId, DepInfo>); pub struct Dependencies(pub BTreeMap<PackageId, DepInfo>);
impl Map for Dependencies { impl Map for Dependencies {
type Key = PackageId; type Key = PackageId;
@@ -47,7 +37,7 @@ pub struct DepInfo {
impl TS for DepInfo { impl TS for DepInfo {
type WithoutGenerics = Self; type WithoutGenerics = Self;
fn decl() -> String { fn decl() -> String {
format!("type {} = {}", Self::name(), Self::inline_flattened()) format!("type {} = {}", Self::name(), Self::inline())
} }
fn decl_concrete() -> String { fn decl_concrete() -> String {
Self::decl() Self::decl()
@@ -74,6 +64,7 @@ impl TS for DepInfo {
#[derive(Clone, Debug, Deserialize, Serialize, TS)] #[derive(Clone, Debug, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub enum MetadataSrc { pub enum MetadataSrc {
Metadata(Metadata), Metadata(Metadata),
S9pk(Option<PathOrUrl>), // backwards compatibility S9pk(Option<PathOrUrl>), // backwards compatibility
@@ -81,6 +72,7 @@ pub enum MetadataSrc {
#[derive(Clone, Debug, Deserialize, Serialize, TS)] #[derive(Clone, Debug, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct Metadata { pub struct Metadata {
pub title: InternedString, pub title: InternedString,
pub icon: PathOrUrl, pub icon: PathOrUrl,

View File

@@ -2,7 +2,7 @@ use std::sync::Arc;
use rpc_toolkit::yajrc::RpcError; use rpc_toolkit::yajrc::RpcError;
use rpc_toolkit::{ use rpc_toolkit::{
from_fn, from_fn_async, CallRemoteHandler, Context, Empty, HandlerExt, ParentHandler, CallRemoteHandler, Context, Empty, HandlerExt, ParentHandler, from_fn, from_fn_async,
}; };
use crate::context::{CliContext, DiagnosticContext, RpcContext}; use crate::context::{CliContext, DiagnosticContext, RpcContext};
@@ -17,7 +17,6 @@ pub fn diagnostic<C: Context>() -> ParentHandler<C> {
.subcommand( .subcommand(
"error", "error",
from_fn(error) from_fn(error)
.unknown_ts() // TODO: TS
.with_about("Display diagnostic error") .with_about("Display diagnostic error")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
@@ -29,7 +28,6 @@ pub fn diagnostic<C: Context>() -> ParentHandler<C> {
"logs", "logs",
from_fn_async(crate::logs::cli_logs::<DiagnosticContext, Empty>) from_fn_async(crate::logs::cli_logs::<DiagnosticContext, Empty>)
.no_display() .no_display()
.no_ts()
.with_about("Display OS logs"), .with_about("Display OS logs"),
) )
.subcommand( .subcommand(
@@ -40,7 +38,6 @@ pub fn diagnostic<C: Context>() -> ParentHandler<C> {
"kernel-logs", "kernel-logs",
from_fn_async(crate::logs::cli_logs::<DiagnosticContext, Empty>) from_fn_async(crate::logs::cli_logs::<DiagnosticContext, Empty>)
.no_display() .no_display()
.no_ts()
.with_about("Display kernal logs"), .with_about("Display kernal logs"),
) )
.subcommand( .subcommand(

View File

@@ -2,7 +2,6 @@ use std::path::Path;
use color_eyre::eyre::eyre; use color_eyre::eyre::eyre;
use tokio::process::Command; use tokio::process::Command;
use ts_rs::TS;
use crate::Error; use crate::Error;
use crate::disk::fsck::btrfs::{btrfs_check_readonly, btrfs_check_repair}; use crate::disk::fsck::btrfs::{btrfs_check_readonly, btrfs_check_repair};
@@ -12,7 +11,7 @@ use crate::util::Invoke;
pub mod btrfs; pub mod btrfs;
pub mod ext4; pub mod ext4;
#[derive(Debug, Clone, Copy, serde::Serialize, serde::Deserialize, TS)] #[derive(Debug, Clone, Copy, serde::Serialize, serde::Deserialize)]
#[must_use] #[must_use]
pub struct RequiresReboot(pub bool); pub struct RequiresReboot(pub bool);
impl std::ops::BitOrAssign for RequiresReboot { impl std::ops::BitOrAssign for RequiresReboot {

View File

@@ -12,6 +12,7 @@ use crate::prelude::*;
use crate::util::io::create_file; use crate::util::io::create_file;
#[derive(Debug, Clone, Serialize, Deserialize, TS)] #[derive(Debug, Clone, Serialize, Deserialize, TS)]
#[ts(export)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "kebab-case")]
pub enum FileType { pub enum FileType {
File, File,

View File

@@ -48,7 +48,6 @@ pub async fn bind<P0: AsRef<Path>, P1: AsRef<Path>>(
pub async fn unmount<P: AsRef<Path>>(mountpoint: P, lazy: bool) -> Result<(), Error> { pub async fn unmount<P: AsRef<Path>>(mountpoint: P, lazy: bool) -> Result<(), Error> {
tracing::debug!("Unmounting {}.", mountpoint.as_ref().display()); tracing::debug!("Unmounting {}.", mountpoint.as_ref().display());
let mut cmd = tokio::process::Command::new("umount"); let mut cmd = tokio::process::Command::new("umount");
cmd.arg("-R");
if lazy { if lazy {
cmd.arg("-l"); cmd.arg("-l");
} }

View File

@@ -13,7 +13,6 @@ use regex::Regex;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use tokio::process::Command; use tokio::process::Command;
use tracing::instrument; use tracing::instrument;
use ts_rs::TS;
use super::mount::filesystem::ReadOnly; use super::mount::filesystem::ReadOnly;
use super::mount::filesystem::block_dev::BlockDev; use super::mount::filesystem::block_dev::BlockDev;
@@ -25,14 +24,14 @@ use crate::util::Invoke;
use crate::util::serde::IoFormat; use crate::util::serde::IoFormat;
use crate::{Error, ResultExt as _}; use crate::{Error, ResultExt as _};
#[derive(Clone, Copy, Debug, Deserialize, Serialize, TS)] #[derive(Clone, Copy, Debug, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "camelCase")]
pub enum PartitionTable { pub enum PartitionTable {
Mbr, Mbr,
Gpt, Gpt,
} }
#[derive(Clone, Debug, Deserialize, Serialize, TS)] #[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct DiskInfo { pub struct DiskInfo {
pub logicalname: PathBuf, pub logicalname: PathBuf,
@@ -44,7 +43,7 @@ pub struct DiskInfo {
pub guid: Option<String>, pub guid: Option<String>,
} }
#[derive(Clone, Debug, Deserialize, Serialize, TS)] #[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct PartitionInfo { pub struct PartitionInfo {
pub logicalname: PathBuf, pub logicalname: PathBuf,
@@ -55,11 +54,10 @@ pub struct PartitionInfo {
pub guid: Option<String>, pub guid: Option<String>,
} }
#[derive(Clone, Debug, Default, Deserialize, Serialize, TS)] #[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct StartOsRecoveryInfo { pub struct StartOsRecoveryInfo {
pub hostname: Hostname, pub hostname: Hostname,
#[ts(type = "string")]
pub version: exver::Version, pub version: exver::Version,
pub timestamp: DateTime<Utc>, pub timestamp: DateTime<Utc>,
pub password_hash: Option<String>, pub password_hash: Option<String>,
@@ -282,6 +280,9 @@ pub async fn list(os: &OsPartitionInfo) -> Result<Vec<DiskInfo>, Error> {
.try_fold( .try_fold(
BTreeMap::<PathBuf, DiskIndex>::new(), BTreeMap::<PathBuf, DiskIndex>::new(),
|mut disks, dir_entry| async move { |mut disks, dir_entry| async move {
if dir_entry.file_type().await?.is_dir() {
return Ok(disks);
}
if let Some(disk_path) = dir_entry.path().file_name().and_then(|s| s.to_str()) { if let Some(disk_path) = dir_entry.path().file_name().and_then(|s| s.to_str()) {
let (disk_path, part_path) = if let Some(end) = PARTITION_REGEX.find(disk_path) { let (disk_path, part_path) = if let Some(end) = PARTITION_REGEX.find(disk_path) {
( (

View File

@@ -1,14 +1,12 @@
use imbl_value::InternedString; use imbl_value::InternedString;
use lazy_format::lazy_format; use lazy_format::lazy_format;
use rand::{Rng, rng}; use rand::{Rng, rng};
use serde::{Deserialize, Serialize};
use tokio::process::Command; use tokio::process::Command;
use tracing::instrument; use tracing::instrument;
use ts_rs::TS;
use crate::util::Invoke; use crate::util::Invoke;
use crate::{Error, ErrorKind}; use crate::{Error, ErrorKind};
#[derive(Clone, Debug, Default, Deserialize, Serialize, TS)] #[derive(Clone, Debug, Default, serde::Deserialize, serde::Serialize)]
pub struct Hostname(pub InternedString); pub struct Hostname(pub InternedString);
lazy_static::lazy_static! { lazy_static::lazy_static! {

View File

@@ -8,7 +8,7 @@ use const_format::formatcp;
use futures::{StreamExt, TryStreamExt}; use futures::{StreamExt, TryStreamExt};
use itertools::Itertools; use itertools::Itertools;
use models::ResultExt; use models::ResultExt;
use rpc_toolkit::{from_fn_async, Context, Empty, HandlerArgs, HandlerExt, ParentHandler}; use rpc_toolkit::{Context, Empty, HandlerArgs, HandlerExt, ParentHandler, from_fn_async};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use tokio::process::Command; use tokio::process::Command;
use tracing::instrument; use tracing::instrument;
@@ -17,8 +17,8 @@ use ts_rs::TS;
use crate::account::AccountInfo; use crate::account::AccountInfo;
use crate::context::config::ServerConfig; use crate::context::config::ServerConfig;
use crate::context::{CliContext, InitContext, RpcContext}; use crate::context::{CliContext, InitContext, RpcContext};
use crate::db::model::public::ServerStatus;
use crate::db::model::Database; use crate::db::model::Database;
use crate::db::model::public::ServerStatus;
use crate::developer::OS_DEVELOPER_KEY_PATH; use crate::developer::OS_DEVELOPER_KEY_PATH;
use crate::hostname::Hostname; use crate::hostname::Hostname;
use crate::middleware::auth::AuthContext; use crate::middleware::auth::AuthContext;
@@ -35,10 +35,10 @@ use crate::rpc_continuations::{Guid, RpcContinuation};
use crate::s9pk::v2::pack::{CONTAINER_DATADIR, CONTAINER_TOOL}; use crate::s9pk::v2::pack::{CONTAINER_DATADIR, CONTAINER_TOOL};
use crate::ssh::SSH_DIR; use crate::ssh::SSH_DIR;
use crate::system::{get_mem_info, sync_kiosk}; use crate::system::{get_mem_info, sync_kiosk};
use crate::util::io::{open_file, IOHook}; use crate::util::io::{IOHook, open_file};
use crate::util::lshw::lshw; use crate::util::lshw::lshw;
use crate::util::net::WebSocketExt; use crate::util::net::WebSocketExt;
use crate::util::{cpupower, Invoke}; use crate::util::{Invoke, cpupower};
use crate::{Error, MAIN_DATA, PACKAGE_DATA}; use crate::{Error, MAIN_DATA, PACKAGE_DATA};
pub const SYSTEM_REBUILD_PATH: &str = "/media/startos/config/system-rebuild"; pub const SYSTEM_REBUILD_PATH: &str = "/media/startos/config/system-rebuild";
@@ -425,7 +425,6 @@ pub fn init_api<C: Context>() -> ParentHandler<C> {
"logs", "logs",
from_fn_async(crate::logs::cli_logs::<InitContext, Empty>) from_fn_async(crate::logs::cli_logs::<InitContext, Empty>)
.no_display() .no_display()
.no_ts()
.with_about("Display OS logs"), .with_about("Display OS logs"),
) )
.subcommand( .subcommand(
@@ -436,7 +435,6 @@ pub fn init_api<C: Context>() -> ParentHandler<C> {
"kernel-logs", "kernel-logs",
from_fn_async(crate::logs::cli_logs::<InitContext, Empty>) from_fn_async(crate::logs::cli_logs::<InitContext, Empty>)
.no_display() .no_display()
.no_ts()
.with_about("Display kernel logs"), .with_about("Display kernel logs"),
) )
.subcommand("subscribe", from_fn_async(init_progress).no_cli()) .subcommand("subscribe", from_fn_async(init_progress).no_cli())
@@ -450,6 +448,7 @@ pub fn init_api<C: Context>() -> ParentHandler<C> {
#[derive(Debug, Deserialize, Serialize, TS)] #[derive(Debug, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct InitProgressRes { pub struct InitProgressRes {
pub progress: FullProgress, pub progress: FullProgress,
pub guid: Guid, pub guid: Guid,

View File

@@ -112,6 +112,7 @@ impl std::fmt::Display for MinMax {
#[derive(Deserialize, Serialize, TS)] #[derive(Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct InstallParams { pub struct InstallParams {
#[ts(type = "string")] #[ts(type = "string")]
registry: Url, registry: Url,
@@ -353,6 +354,7 @@ impl FromArgMatches for CliInstallParams {
} }
#[derive(Deserialize, Serialize, Parser, TS)] #[derive(Deserialize, Serialize, Parser, TS)]
#[ts(export)]
pub struct InstalledVersionParams { pub struct InstalledVersionParams {
id: PackageId, id: PackageId,
} }

View File

@@ -79,8 +79,8 @@ pub use error::{Error, ErrorKind, ResultExt};
use imbl_value::Value; use imbl_value::Value;
use rpc_toolkit::yajrc::RpcError; use rpc_toolkit::yajrc::RpcError;
use rpc_toolkit::{ use rpc_toolkit::{
from_fn, from_fn_async, from_fn_async_local, from_fn_blocking, CallRemoteHandler, Context, CallRemoteHandler, Context, Empty, HandlerExt, ParentHandler, from_fn, from_fn_async,
Empty, HandlerExt, ParentHandler, from_fn_async_local, from_fn_blocking,
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use ts_rs::TS; use ts_rs::TS;
@@ -90,11 +90,12 @@ use crate::disk::fsck::RequiresReboot;
use crate::registry::context::{RegistryContext, RegistryUrlParams}; use crate::registry::context::{RegistryContext, RegistryUrlParams};
use crate::system::kiosk; use crate::system::kiosk;
use crate::tunnel::context::TunnelUrlParams; use crate::tunnel::context::TunnelUrlParams;
use crate::util::serde::{display_serializable, HandlerExtSerde, WithIoFormat}; use crate::util::serde::{HandlerExtSerde, WithIoFormat, display_serializable};
#[derive(Deserialize, Serialize, Parser, TS)] #[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")] #[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct EchoParams { pub struct EchoParams {
message: String, message: String,
} }
@@ -105,6 +106,7 @@ pub fn echo<C: Context>(_: C, EchoParams { message }: EchoParams) -> Result<Stri
#[derive(Debug, Deserialize, Serialize, TS)] #[derive(Debug, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub enum ApiState { pub enum ApiState {
Error, Error,
Initializing, Initializing,
@@ -116,70 +118,6 @@ impl std::fmt::Display for ApiState {
} }
} }
#[test]
fn export_bindings_api_helper() {
std::fs::create_dir_all("./bindings").unwrap();
std::fs::write(
"./bindings/api-helpers.ts",
rpc_toolkit::type_helpers().as_bytes(),
)
.unwrap();
}
#[test]
fn export_bindings_main_apis() {
use rpc_toolkit::HandlerTS;
use crate::context::{InstallContext, SetupContext};
std::fs::create_dir_all("./bindings").unwrap();
std::fs::write(
"./bindings/main-api.ts",
format!(
"export type MainApi = {}",
main_api::<RpcContext>().type_info().unwrap()
)
.as_bytes(),
)
.unwrap();
std::fs::write(
"./bindings/init-api.ts",
format!(
"export type InitApi = {}",
main_api::<InitContext>().type_info().unwrap()
)
.as_bytes(),
)
.unwrap();
std::fs::write(
"./bindings/diagnostic-api.ts",
format!(
"export type DiagnosticApi = {}",
main_api::<DiagnosticContext>().type_info().unwrap()
)
.as_bytes(),
)
.unwrap();
std::fs::write(
"./bindings/setup-api.ts",
format!(
"export type SetupApi = {}",
main_api::<SetupContext>().type_info().unwrap()
)
.as_bytes(),
)
.unwrap();
std::fs::write(
"./bindings/os-install-api.ts",
format!(
"export type OsInstallApi = {}",
main_api::<InstallContext>().type_info().unwrap()
)
.as_bytes(),
)
.unwrap();
}
pub fn main_api<C: Context>() -> ParentHandler<C> { pub fn main_api<C: Context>() -> ParentHandler<C> {
let mut api = ParentHandler::new() let mut api = ParentHandler::new()
.subcommand( .subcommand(
@@ -339,7 +277,7 @@ pub fn server<C: Context>() -> ParentHandler<C> {
) )
.subcommand( .subcommand(
"logs", "logs",
from_fn_async(logs::cli_logs::<RpcContext, Empty>).no_display().no_ts().with_about("Display OS logs"), from_fn_async(logs::cli_logs::<RpcContext, Empty>).no_display().with_about("Display OS logs"),
) )
.subcommand( .subcommand(
"kernel-logs", "kernel-logs",
@@ -347,7 +285,7 @@ pub fn server<C: Context>() -> ParentHandler<C> {
) )
.subcommand( .subcommand(
"kernel-logs", "kernel-logs",
from_fn_async(logs::cli_logs::<RpcContext, Empty>).no_display().no_ts().with_about("Display Kernel logs"), from_fn_async(logs::cli_logs::<RpcContext, Empty>).no_display().with_about("Display Kernel logs"),
) )
.subcommand( .subcommand(
"metrics", "metrics",
@@ -359,7 +297,7 @@ pub fn server<C: Context>() -> ParentHandler<C> {
.with_call_remote::<CliContext>() .with_call_remote::<CliContext>()
) )
.subcommand( .subcommand(
"follow", "follow",
from_fn_async(system::metrics_follow) from_fn_async(system::metrics_follow)
.no_cli() .no_cli()
) )
@@ -456,7 +394,6 @@ pub fn package<C: Context>() -> ParentHandler<C> {
"install", "install",
from_fn_async_local(install::cli_install) from_fn_async_local(install::cli_install)
.no_display() .no_display()
.no_ts()
.with_about("Install a package from a marketplace or via sideloading"), .with_about("Install a package from a marketplace or via sideloading"),
) )
.subcommand( .subcommand(
@@ -560,6 +497,7 @@ pub fn package<C: Context>() -> ParentHandler<C> {
.with_about("List information related to the lxc containers i.e. CPU, Memory, Disk") .with_about("List information related to the lxc containers i.e. CPU, Memory, Disk")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
.subcommand("logs", logs::package_logs())
.subcommand( .subcommand(
"logs", "logs",
logs::package_logs().with_about("Display package logs"), logs::package_logs().with_about("Display package logs"),
@@ -568,7 +506,6 @@ pub fn package<C: Context>() -> ParentHandler<C> {
"logs", "logs",
from_fn_async(logs::cli_logs::<RpcContext, logs::PackageIdParams>) from_fn_async(logs::cli_logs::<RpcContext, logs::PackageIdParams>)
.no_display() .no_display()
.no_ts()
.with_about("Display package logs"), .with_about("Display package logs"),
) )
.subcommand( .subcommand(
@@ -583,16 +520,7 @@ pub fn package<C: Context>() -> ParentHandler<C> {
.with_about("Execute commands within a service container") .with_about("Execute commands within a service container")
.no_cli(), .no_cli(),
) )
.subcommand( .subcommand("attach", from_fn_async(service::cli_attach).no_display())
"attach",
from_fn_async(service::cli_attach).no_display().no_ts(),
)
.subcommand(
"list-subcontainers",
from_fn_async(service::list_subcontainers)
.with_about("List all subcontainers for a package")
.no_cli(),
)
.subcommand( .subcommand(
"host", "host",
net::host::host_api::<C>().with_about("Manage network hosts for a package"), net::host::host_api::<C>().with_about("Manage network hosts for a package"),

View File

@@ -15,8 +15,7 @@ use itertools::Itertools;
use models::{FromStrParser, PackageId}; use models::{FromStrParser, PackageId};
use rpc_toolkit::yajrc::RpcError; use rpc_toolkit::yajrc::RpcError;
use rpc_toolkit::{ use rpc_toolkit::{
from_fn_async, CallRemote, Context, Empty, HandlerArgs, HandlerExt, HandlerFor, LeafHandler, CallRemote, Context, Empty, HandlerArgs, HandlerExt, HandlerFor, ParentHandler, from_fn_async,
ParentHandler, UnknownTS,
}; };
use serde::de::{self, DeserializeOwned}; use serde::de::{self, DeserializeOwned};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@@ -25,16 +24,15 @@ use tokio::process::{Child, Command};
use tokio_stream::wrappers::LinesStream; use tokio_stream::wrappers::LinesStream;
use tokio_tungstenite::tungstenite::Message; use tokio_tungstenite::tungstenite::Message;
use tracing::instrument; use tracing::instrument;
use ts_rs::TS;
use crate::context::{CliContext, RpcContext}; use crate::context::{CliContext, RpcContext};
use crate::error::ResultExt; use crate::error::ResultExt;
use crate::lxc::ContainerId; use crate::lxc::ContainerId;
use crate::prelude::*; use crate::prelude::*;
use crate::rpc_continuations::{Guid, RpcContinuation, RpcContinuations}; use crate::rpc_continuations::{Guid, RpcContinuation, RpcContinuations};
use crate::util::Invoke;
use crate::util::net::WebSocketExt; use crate::util::net::WebSocketExt;
use crate::util::serde::Reversible; use crate::util::serde::Reversible;
use crate::util::Invoke;
#[pin_project::pin_project] #[pin_project::pin_project]
pub struct LogStream { pub struct LogStream {
@@ -111,21 +109,21 @@ async fn ws_handler(
} }
} }
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, TS)] #[derive(serde::Serialize, serde::Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct LogResponse { pub struct LogResponse {
pub entries: Reversible<LogEntry>, pub entries: Reversible<LogEntry>,
start_cursor: Option<String>, start_cursor: Option<String>,
end_cursor: Option<String>, end_cursor: Option<String>,
} }
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, TS)] #[derive(serde::Serialize, serde::Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct LogFollowResponse { pub struct LogFollowResponse {
start_cursor: Option<String>, start_cursor: Option<String>,
guid: Guid, guid: Guid,
} }
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, TS)] #[derive(serde::Serialize, serde::Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct LogEntry { pub struct LogEntry {
timestamp: DateTime<Utc>, timestamp: DateTime<Utc>,
@@ -144,7 +142,7 @@ impl std::fmt::Display for LogEntry {
} }
} }
#[derive(Serialize, Deserialize, Debug, TS)] #[derive(Serialize, Deserialize, Debug)]
pub struct JournalctlEntry { pub struct JournalctlEntry {
#[serde(rename = "__REALTIME_TIMESTAMP")] #[serde(rename = "__REALTIME_TIMESTAMP")]
pub timestamp: String, pub timestamp: String,
@@ -230,15 +228,14 @@ pub enum LogSource {
pub const SYSTEM_UNIT: &str = "startd"; pub const SYSTEM_UNIT: &str = "startd";
#[derive(Deserialize, Serialize, Parser, TS)] #[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")] #[command(rename_all = "kebab-case")]
pub struct PackageIdParams { pub struct PackageIdParams {
id: PackageId, id: PackageId,
} }
#[derive(Debug, Clone, TS)] #[derive(Debug, Clone)]
#[ts(type = "number | string")]
pub enum BootIdentifier { pub enum BootIdentifier {
Index(i32), Index(i32),
Id(String), Id(String),
@@ -341,11 +338,6 @@ pub struct LogsParams<Extra: FromArgMatches + Args = Empty> {
#[serde(default)] #[serde(default)]
before: bool, before: bool,
} }
impl<Extra: FromArgMatches + Args + TS> LogsParams<Extra> {
pub fn inline_ty() -> String {
format!("{} & {{ limit: number | null; cursor: string | null; boot: string | number | null; before: boolean }}", Extra::inline_flattened())
}
}
#[derive(Deserialize, Serialize, Parser)] #[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
@@ -362,30 +354,18 @@ pub struct CliLogsParams<Extra: FromArgMatches + Args = Empty> {
#[allow(private_bounds)] #[allow(private_bounds)]
pub fn logs< pub fn logs<
C: Context + AsRef<RpcContinuations>, C: Context + AsRef<RpcContinuations>,
Extra: FromArgMatches + Serialize + DeserializeOwned + Args + TS + Send + Sync + 'static, Extra: FromArgMatches + Serialize + DeserializeOwned + Args + Send + Sync + 'static,
>( >(
source: impl for<'a> LogSourceFn<'a, C, Extra>, source: impl for<'a> LogSourceFn<'a, C, Extra>,
) -> UnknownTS<ParentHandler<C, LogsParams<Extra>>> { ) -> ParentHandler<C, LogsParams<Extra>> {
ParentHandler::new() ParentHandler::new()
.root_handler( .root_handler(logs_nofollow::<C, Extra>(source.clone()).no_cli())
logs_nofollow::<C, Extra>(source.clone())
.no_cli()
.custom_ts(
LogsParams::<Extra>::inline_ty(),
LogResponse::inline_flattened(),
),
)
.subcommand( .subcommand(
"follow", "follow",
logs_follow::<C, Extra>(source) logs_follow::<C, Extra>(source)
.with_inherited(|params, _| params) .with_inherited(|params, _| params)
.no_cli() .no_cli(),
.custom_ts(
LogsParams::<Extra>::inline_ty(),
LogFollowResponse::inline_flattened(),
),
) )
.unknown_ts()
} }
pub async fn cli_logs<RemoteContext, Extra>( pub async fn cli_logs<RemoteContext, Extra>(
@@ -399,7 +379,7 @@ pub async fn cli_logs<RemoteContext, Extra>(
) -> Result<(), RpcError> ) -> Result<(), RpcError>
where where
CliContext: CallRemote<RemoteContext>, CliContext: CallRemote<RemoteContext>,
Extra: FromArgMatches + Args + TS + Serialize + Send + Sync, Extra: FromArgMatches + Args + Serialize + Send + Sync,
{ {
let method = parent_method let method = parent_method
.into_iter() .into_iter()
@@ -451,16 +431,10 @@ where
fn logs_nofollow<C, Extra>( fn logs_nofollow<C, Extra>(
f: impl for<'a> LogSourceFn<'a, C, Extra>, f: impl for<'a> LogSourceFn<'a, C, Extra>,
) -> impl HandlerFor< ) -> impl HandlerFor<C, Params = LogsParams<Extra>, InheritedParams = Empty, Ok = LogResponse, Err = Error>
C,
Params = LogsParams<Extra>,
InheritedParams = Empty,
Ok = LogResponse,
Err = Error,
> + LeafHandler
where where
C: Context, C: Context,
Extra: FromArgMatches + Args + TS + Send + Sync + 'static, Extra: FromArgMatches + Args + Send + Sync + 'static,
{ {
from_fn_async( from_fn_async(
move |HandlerArgs { move |HandlerArgs {
@@ -492,7 +466,7 @@ where
fn logs_follow< fn logs_follow<
C: Context + AsRef<RpcContinuations>, C: Context + AsRef<RpcContinuations>,
Extra: FromArgMatches + Args + TS + Send + Sync + 'static, Extra: FromArgMatches + Args + Send + Sync + 'static,
>( >(
f: impl for<'a> LogSourceFn<'a, C, Extra>, f: impl for<'a> LogSourceFn<'a, C, Extra>,
) -> impl HandlerFor< ) -> impl HandlerFor<
@@ -501,7 +475,7 @@ fn logs_follow<
InheritedParams = LogsParams<Extra>, InheritedParams = LogsParams<Extra>,
Ok = LogFollowResponse, Ok = LogFollowResponse,
Err = Error, Err = Error,
> + LeafHandler { > {
from_fn_async( from_fn_async(
move |HandlerArgs { move |HandlerArgs {
context, context,
@@ -543,7 +517,7 @@ async fn get_package_id(
Ok(LogSource::Container(container_id)) Ok(LogSource::Container(container_id))
} }
pub fn package_logs() -> UnknownTS<ParentHandler<RpcContext, LogsParams<PackageIdParams>>> { pub fn package_logs() -> ParentHandler<RpcContext, LogsParams<PackageIdParams>> {
logs::<RpcContext, PackageIdParams>(get_package_id) logs::<RpcContext, PackageIdParams>(get_package_id)
} }

View File

@@ -24,7 +24,6 @@ use sha2::Sha256;
use tokio::io::AsyncWriteExt; use tokio::io::AsyncWriteExt;
use tokio::process::Command; use tokio::process::Command;
use tokio::sync::Mutex; use tokio::sync::Mutex;
use ts_rs::TS;
use crate::auth::{Sessions, check_password, write_shadow}; use crate::auth::{Sessions, check_password, write_shadow};
use crate::context::RpcContext; use crate::context::RpcContext;
@@ -90,7 +89,7 @@ impl AuthContext for RpcContext {
} }
} }
#[derive(Deserialize, Serialize, TS)] #[derive(Deserialize, Serialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct LoginRes { pub struct LoginRes {
pub session: InternedString, pub session: InternedString,
@@ -101,7 +100,7 @@ pub trait AsLogoutSessionId {
} }
/// Will need to know when we have logged out from a route /// Will need to know when we have logged out from a route
#[derive(Serialize, Deserialize, TS)] #[derive(Serialize, Deserialize)]
pub struct HasLoggedOutSessions(()); pub struct HasLoggedOutSessions(());
impl HasLoggedOutSessions { impl HasLoggedOutSessions {

View File

@@ -460,7 +460,7 @@ impl ValueParserFactory for AcmeProvider {
} }
} }
#[derive(Deserialize, Serialize, Parser, TS)] #[derive(Deserialize, Serialize, Parser)]
pub struct InitAcmeParams { pub struct InitAcmeParams {
#[arg(long)] #[arg(long)]
pub provider: AcmeProvider, pub provider: AcmeProvider,
@@ -485,7 +485,7 @@ pub async fn init(
Ok(()) Ok(())
} }
#[derive(Deserialize, Serialize, Parser, TS)] #[derive(Deserialize, Serialize, Parser)]
pub struct RemoveAcmeParams { pub struct RemoveAcmeParams {
#[arg(long)] #[arg(long)]
pub provider: AcmeProvider, pub provider: AcmeProvider,

View File

@@ -32,7 +32,6 @@ use rpc_toolkit::{
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use tokio::net::{TcpListener, UdpSocket}; use tokio::net::{TcpListener, UdpSocket};
use tracing::instrument; use tracing::instrument;
use ts_rs::TS;
use crate::context::{CliContext, RpcContext}; use crate::context::{CliContext, RpcContext};
use crate::db::model::Database; use crate::db::model::Database;
@@ -100,7 +99,7 @@ pub fn dns_api<C: Context>() -> ParentHandler<C> {
) )
} }
#[derive(Deserialize, Serialize, Parser, TS)] #[derive(Deserialize, Serialize, Parser)]
pub struct QueryDnsParams { pub struct QueryDnsParams {
pub fqdn: InternedString, pub fqdn: InternedString,
} }
@@ -139,7 +138,7 @@ pub fn query_dns<C: Context>(
.map_err(Error::from) .map_err(Error::from)
} }
#[derive(Deserialize, Serialize, Parser, TS)] #[derive(Deserialize, Serialize, Parser)]
pub struct SetStaticDnsParams { pub struct SetStaticDnsParams {
pub servers: Option<Vec<String>>, pub servers: Option<Vec<String>>,
} }

View File

@@ -13,7 +13,6 @@ use rpc_toolkit::{Context, HandlerArgs, HandlerExt, ParentHandler, from_fn_async
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use tokio::process::Command; use tokio::process::Command;
use tokio::sync::mpsc; use tokio::sync::mpsc;
use ts_rs::TS;
use crate::context::{CliContext, RpcContext}; use crate::context::{CliContext, RpcContext};
use crate::db::model::public::NetworkInterfaceInfo; use crate::db::model::public::NetworkInterfaceInfo;
@@ -438,7 +437,8 @@ impl InterfaceForwardState {
for mut entry in self.state.iter_mut() { for mut entry in self.state.iter_mut() {
entry.gc(ip_info, &self.port_forward).await?; entry.gc(ip_info, &self.port_forward).await?;
} }
Ok(())
self.port_forward.gc().await
} }
} }
@@ -449,10 +449,10 @@ fn err_has_exited<T>(_: T) -> Error {
) )
} }
#[derive(Debug, Clone, Deserialize, Serialize, TS)] #[derive(Debug, Clone, Deserialize, Serialize)]
pub struct ForwardTable(pub BTreeMap<u16, ForwardTarget>); pub struct ForwardTable(pub BTreeMap<u16, ForwardTarget>);
#[derive(Debug, Clone, Deserialize, Serialize, TS)] #[derive(Debug, Clone, Deserialize, Serialize)]
pub struct ForwardTarget { pub struct ForwardTarget {
pub target: SocketAddrV4, pub target: SocketAddrV4,
pub filter: String, pub filter: String,
@@ -538,7 +538,6 @@ impl InterfacePortForwardController {
_ = ip_info.changed() => { _ = ip_info.changed() => {
interfaces = ip_info.read(); interfaces = ip_info.read();
state.sync(&interfaces).await.log_err(); state.sync(&interfaces).await.log_err();
state.port_forward.gc().await.log_err();
} }
} }
} }

View File

@@ -1,9 +1,10 @@
use std::any::Any; use std::any::Any;
use std::collections::{BTreeMap, BTreeSet, HashMap}; use std::collections::{BTreeMap, BTreeSet, HashMap};
use std::fmt;
use std::future::Future; use std::future::Future;
use std::net::{IpAddr, Ipv4Addr, SocketAddr, SocketAddrV6}; use std::net::{IpAddr, Ipv4Addr, SocketAddr, SocketAddrV6};
use std::sync::{Arc, Weak}; use std::sync::{Arc, Weak};
use std::task::{ready, Poll}; use std::task::{Poll, ready};
use std::time::Duration; use std::time::Duration;
use clap::Parser; use clap::Parser;
@@ -17,7 +18,7 @@ use itertools::Itertools;
use models::GatewayId; use models::GatewayId;
use nix::net::if_::if_nametoindex; use nix::net::if_::if_nametoindex;
use patch_db::json_ptr::JsonPointer; use patch_db::json_ptr::JsonPointer;
use rpc_toolkit::{from_fn_async, Context, HandlerArgs, HandlerExt, ParentHandler}; use rpc_toolkit::{Context, HandlerArgs, HandlerExt, ParentHandler, from_fn_async};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use tokio::io::{AsyncBufReadExt, BufReader}; use tokio::io::{AsyncBufReadExt, BufReader};
use tokio::net::TcpListener; use tokio::net::TcpListener;
@@ -29,29 +30,28 @@ use zbus::proxy::{PropertyChanged, PropertyStream, SignalStream};
use zbus::zvariant::{ use zbus::zvariant::{
DeserializeDict, Dict, OwnedObjectPath, OwnedValue, Type as ZType, Value as ZValue, DeserializeDict, Dict, OwnedObjectPath, OwnedValue, Type as ZType, Value as ZValue,
}; };
use zbus::{proxy, Connection}; use zbus::{Connection, proxy};
use crate::context::{CliContext, RpcContext}; use crate::context::{CliContext, RpcContext};
use crate::db::model::public::{IpInfo, NetworkInterfaceInfo, NetworkInterfaceType};
use crate::db::model::Database; use crate::db::model::Database;
use crate::db::model::public::{IpInfo, NetworkInterfaceInfo, NetworkInterfaceType};
use crate::net::forward::START9_BRIDGE_IFACE; use crate::net::forward::START9_BRIDGE_IFACE;
use crate::net::gateway::device::DeviceProxy; use crate::net::gateway::device::DeviceProxy;
use crate::net::utils::ipv6_is_link_local; use crate::net::utils::ipv6_is_link_local;
use crate::net::web_server::{Accept, AcceptStream, Acceptor, MetadataVisitor}; use crate::net::web_server::{Accept, AcceptStream, Acceptor, MetadataVisitor};
use crate::prelude::*; use crate::prelude::*;
use crate::util::Invoke;
use crate::util::collections::OrdMapIterMut; use crate::util::collections::OrdMapIterMut;
use crate::util::future::Until; use crate::util::future::Until;
use crate::util::io::open_file; use crate::util::io::open_file;
use crate::util::serde::{display_serializable, HandlerExtSerde}; use crate::util::serde::{HandlerExtSerde, display_serializable};
use crate::util::sync::{SyncMutex, Watch}; use crate::util::sync::{SyncMutex, Watch};
use crate::util::Invoke;
pub fn gateway_api<C: Context>() -> ParentHandler<C> { pub fn gateway_api<C: Context>() -> ParentHandler<C> {
ParentHandler::new() ParentHandler::new()
.subcommand( .subcommand(
"list", "list",
from_fn_async(list_interfaces) from_fn_async(list_interfaces)
.custom_ts("{}".into(), BTreeMap::<GatewayId, NetworkInterfaceInfo>::inline_flattened())
.with_display_serializable() .with_display_serializable()
.with_custom_display_fn(|HandlerArgs { params, .. }, res| { .with_custom_display_fn(|HandlerArgs { params, .. }, res| {
use prettytable::*; use prettytable::*;
@@ -1552,6 +1552,14 @@ pub struct NetworkInterfaceListenerAcceptMetadata<B: Bind> {
pub inner: <B::Accept as Accept>::Metadata, pub inner: <B::Accept as Accept>::Metadata,
pub info: GatewayInfo, pub info: GatewayInfo,
} }
impl<B: Bind> fmt::Debug for NetworkInterfaceListenerAcceptMetadata<B> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("NetworkInterfaceListenerAcceptMetadata")
.field("inner", &self.inner)
.field("info", &self.info)
.finish()
}
}
impl<B: Bind> Clone for NetworkInterfaceListenerAcceptMetadata<B> impl<B: Bind> Clone for NetworkInterfaceListenerAcceptMetadata<B>
where where
<B::Accept as Accept>::Metadata: Clone, <B::Accept as Accept>::Metadata: Clone,
@@ -1628,3 +1636,39 @@ where
Self::new(Some(Either::Left(listener))) Self::new(Some(Either::Left(listener)))
} }
} }
#[test]
fn test_filter() {
use crate::net::host::binding::NetInfo;
let wg1 = "wg1".parse::<GatewayId>().unwrap();
assert!(!InterfaceFilter::filter(
&AndFilter(
NetInfo {
private_disabled: [wg1.clone()].into_iter().collect(),
public_enabled: Default::default(),
assigned_port: None,
assigned_ssl_port: None,
},
AndFilter(IdFilter(wg1.clone()), PublicFilter { public: false }),
)
.into_dyn(),
&wg1,
&NetworkInterfaceInfo {
name: None,
public: None,
secure: None,
ip_info: Some(Arc::new(IpInfo {
name: "".into(),
scope_id: 3,
device_type: Some(NetworkInterfaceType::Wireguard),
subnets: ["10.59.0.2/24".parse::<IpNet>().unwrap()]
.into_iter()
.collect(),
lan_ip: Default::default(),
wan_ip: None,
ntp_servers: Default::default(),
dns_servers: Default::default(),
})),
},
));
}

View File

@@ -16,7 +16,7 @@ use crate::net::tor::OnionAddress;
use crate::prelude::*; use crate::prelude::*;
use crate::util::serde::{HandlerExtSerde, display_serializable}; use crate::util::serde::{HandlerExtSerde, display_serializable};
#[derive(Clone, Debug, Deserialize, Serialize, TS)] #[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "kebab-case")]
#[serde(rename_all_fields = "camelCase")] #[serde(rename_all_fields = "camelCase")]
#[serde(tag = "kind")] #[serde(tag = "kind")]
@@ -235,7 +235,7 @@ pub fn address_api<C: Context, Kind: HostApiKind>()
) )
} }
#[derive(Deserialize, Serialize, Parser, TS)] #[derive(Deserialize, Serialize, Parser)]
pub struct AddPublicDomainParams { pub struct AddPublicDomainParams {
pub fqdn: InternedString, pub fqdn: InternedString,
#[arg(long)] #[arg(long)]
@@ -282,7 +282,7 @@ pub async fn add_public_domain<Kind: HostApiKind>(
.with_kind(ErrorKind::Unknown)? .with_kind(ErrorKind::Unknown)?
} }
#[derive(Deserialize, Serialize, Parser, TS)] #[derive(Deserialize, Serialize, Parser)]
pub struct RemoveDomainParams { pub struct RemoveDomainParams {
pub fqdn: InternedString, pub fqdn: InternedString,
} }
@@ -305,7 +305,7 @@ pub async fn remove_public_domain<Kind: HostApiKind>(
Ok(()) Ok(())
} }
#[derive(Deserialize, Serialize, Parser, TS)] #[derive(Deserialize, Serialize, Parser)]
pub struct AddPrivateDomainParams { pub struct AddPrivateDomainParams {
pub fqdn: InternedString, pub fqdn: InternedString,
} }
@@ -347,7 +347,7 @@ pub async fn remove_private_domain<Kind: HostApiKind>(
Ok(()) Ok(())
} }
#[derive(Deserialize, Serialize, Parser, TS)] #[derive(Deserialize, Serialize, Parser)]
pub struct OnionParams { pub struct OnionParams {
pub onion: String, pub onion: String,
} }

View File

@@ -19,6 +19,7 @@ use crate::prelude::*;
use crate::util::serde::{HandlerExtSerde, display_serializable}; use crate::util::serde::{HandlerExtSerde, display_serializable};
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize, TS)] #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize, TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct BindId { pub struct BindId {
pub id: HostId, pub id: HostId,
@@ -45,6 +46,7 @@ impl FromStr for BindId {
#[derive(Debug, Deserialize, Serialize, TS)] #[derive(Debug, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct BindInfo { pub struct BindInfo {
pub enabled: bool, pub enabled: bool,
pub options: BindOptions, pub options: BindOptions,
@@ -53,6 +55,7 @@ pub struct BindInfo {
#[derive(Clone, Debug, Deserialize, Serialize, TS, PartialEq, Eq, PartialOrd, Ord)] #[derive(Clone, Debug, Deserialize, Serialize, TS, PartialEq, Eq, PartialOrd, Ord)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct NetInfo { pub struct NetInfo {
#[ts(as = "BTreeSet::<GatewayId>")] #[ts(as = "BTreeSet::<GatewayId>")]
#[serde(default)] #[serde(default)]
@@ -142,6 +145,7 @@ impl InterfaceFilter for NetInfo {
} }
#[derive(Debug, Clone, Copy, serde::Serialize, serde::Deserialize, TS)] #[derive(Debug, Clone, Copy, serde::Serialize, serde::Deserialize, TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct Security { pub struct Security {
pub ssl: bool, pub ssl: bool,
@@ -149,6 +153,7 @@ pub struct Security {
#[derive(Clone, Debug, Deserialize, Serialize, TS)] #[derive(Clone, Debug, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct BindOptions { pub struct BindOptions {
pub preferred_external_port: u16, pub preferred_external_port: u16,
pub add_ssl: Option<AddSslOptions>, pub add_ssl: Option<AddSslOptions>,
@@ -157,6 +162,7 @@ pub struct BindOptions {
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq, TS)] #[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct AddSslOptions { pub struct AddSslOptions {
pub preferred_external_port: u16, pub preferred_external_port: u16,
// #[serde(default)] // #[serde(default)]
@@ -228,6 +234,7 @@ pub async fn list_bindings<Kind: HostApiKind>(
#[derive(Deserialize, Serialize, Parser, TS)] #[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct BindingGatewaySetEnabledParams { pub struct BindingGatewaySetEnabledParams {
internal_port: u16, internal_port: u16,
gateway: GatewayId, gateway: GatewayId,

View File

@@ -25,6 +25,7 @@ pub mod binding;
#[derive(Debug, Default, Deserialize, Serialize, HasModel, TS)] #[derive(Debug, Default, Deserialize, Serialize, HasModel, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[model = "Model<Self>"] #[model = "Model<Self>"]
#[ts(export)]
pub struct Host { pub struct Host {
pub bindings: BTreeMap<u16, BindInfo>, pub bindings: BTreeMap<u16, BindInfo>,
#[ts(type = "string[]")] #[ts(type = "string[]")]
@@ -73,6 +74,7 @@ impl Host {
#[derive(Debug, Default, Deserialize, Serialize, HasModel, TS)] #[derive(Debug, Default, Deserialize, Serialize, HasModel, TS)]
#[model = "Model<Self>"] #[model = "Model<Self>"]
#[ts(export)]
pub struct Hosts(pub BTreeMap<HostId, Host>); pub struct Hosts(pub BTreeMap<HostId, Host>);
impl Map for Hosts { impl Map for Hosts {
@@ -162,12 +164,12 @@ impl Model<Host> {
} }
} }
#[derive(Deserialize, Serialize, Parser, TS)] #[derive(Deserialize, Serialize, Parser)]
pub struct RequiresPackageId { pub struct RequiresPackageId {
package: PackageId, package: PackageId,
} }
#[derive(Deserialize, Serialize, Parser, TS)] #[derive(Deserialize, Serialize, Parser)]
pub struct RequiresHostId { pub struct RequiresHostId {
host: HostId, host: HostId,
} }

View File

@@ -6,6 +6,7 @@ use serde::{Deserialize, Serialize};
use ts_rs::TS; use ts_rs::TS;
#[derive(Clone, Debug, Deserialize, Serialize, TS)] #[derive(Clone, Debug, Deserialize, Serialize, TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[serde(rename_all_fields = "camelCase")] #[serde(rename_all_fields = "camelCase")]
#[serde(tag = "kind")] #[serde(tag = "kind")]
@@ -29,6 +30,7 @@ impl HostnameInfo {
} }
#[derive(Clone, Debug, Deserialize, Serialize, TS)] #[derive(Clone, Debug, Deserialize, Serialize, TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct GatewayInfo { pub struct GatewayInfo {
pub id: GatewayId, pub id: GatewayId,
@@ -37,6 +39,7 @@ pub struct GatewayInfo {
} }
#[derive(Clone, Debug, Deserialize, Serialize, TS)] #[derive(Clone, Debug, Deserialize, Serialize, TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct OnionHostname { pub struct OnionHostname {
#[ts(type = "string")] #[ts(type = "string")]
@@ -51,6 +54,7 @@ impl OnionHostname {
} }
#[derive(Clone, Debug, Deserialize, Serialize, TS)] #[derive(Clone, Debug, Deserialize, Serialize, TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[serde(rename_all_fields = "camelCase")] #[serde(rename_all_fields = "camelCase")]
#[serde(tag = "kind")] #[serde(tag = "kind")]
@@ -92,6 +96,7 @@ impl IpHostname {
} }
#[derive(Clone, Debug, Deserialize, Serialize, TS)] #[derive(Clone, Debug, Deserialize, Serialize, TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct ServiceInterface { pub struct ServiceInterface {
pub id: ServiceInterfaceId, pub id: ServiceInterfaceId,
@@ -104,6 +109,7 @@ pub struct ServiceInterface {
} }
#[derive(Clone, Debug, Deserialize, Serialize, TS)] #[derive(Clone, Debug, Deserialize, Serialize, TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub enum ServiceInterfaceType { pub enum ServiceInterfaceType {
Ui, Ui,
@@ -112,6 +118,7 @@ pub enum ServiceInterfaceType {
} }
#[derive(Clone, Debug, Deserialize, Serialize, TS)] #[derive(Clone, Debug, Deserialize, Serialize, TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct AddressInfo { pub struct AddressInfo {
pub username: Option<String>, pub username: Option<String>,

View File

@@ -240,16 +240,12 @@ impl CertPair {
} }
} }
pub async fn root_ca_start_time() -> SystemTime { pub async fn root_ca_start_time() -> Result<SystemTime, Error> {
if check_time_is_synchronized() Ok(if check_time_is_synchronized().await? {
.await
.log_err()
.unwrap_or(false)
{
SystemTime::now() SystemTime::now()
} else { } else {
*SOURCE_DATE *SOURCE_DATE
} })
} }
const EC_CURVE_NAME: nid::Nid = nid::Nid::X9_62_PRIME256V1; const EC_CURVE_NAME: nid::Nid = nid::Nid::X9_62_PRIME256V1;

View File

@@ -357,7 +357,7 @@ pub fn display_services(
Ok(()) Ok(())
} }
#[derive(Debug, Serialize, Deserialize, TS)] #[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "kebab-case")]
pub enum OnionServiceState { pub enum OnionServiceState {
Shutdown, Shutdown,
@@ -383,7 +383,7 @@ impl From<ArtiOnionServiceState> for OnionServiceState {
} }
} }
#[derive(Debug, Serialize, Deserialize, TS)] #[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct OnionServiceInfo { pub struct OnionServiceInfo {
pub state: OnionServiceState, pub state: OnionServiceState,

View File

@@ -15,7 +15,7 @@ use imbl::OrdMap;
use imbl_value::InternedString; use imbl_value::InternedString;
use lazy_static::lazy_static; use lazy_static::lazy_static;
use regex::Regex; use regex::Regex;
use rpc_toolkit::{from_fn_async, Context, Empty, HandlerExt, ParentHandler, UnknownTS}; use rpc_toolkit::{Context, Empty, HandlerExt, ParentHandler, from_fn_async};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use tokio::net::TcpStream; use tokio::net::TcpStream;
use tokio::process::Command; use tokio::process::Command;
@@ -27,16 +27,16 @@ use tracing::instrument;
use ts_rs::TS; use ts_rs::TS;
use crate::context::{CliContext, RpcContext}; use crate::context::{CliContext, RpcContext};
use crate::logs::{journalctl, LogSource, LogsParams}; use crate::logs::{LogSource, LogsParams, journalctl};
use crate::prelude::*; use crate::prelude::*;
use crate::util::Invoke;
use crate::util::collections::ordmap_retain; use crate::util::collections::ordmap_retain;
use crate::util::io::{write_file_atomic, ReadWriter}; use crate::util::io::{ReadWriter, write_file_atomic};
use crate::util::serde::{ use crate::util::serde::{
deserialize_from_str, display_serializable, serialize_display, Base64, HandlerExtSerde, BASE64, Base64, HandlerExtSerde, WithIoFormat, deserialize_from_str, display_serializable,
WithIoFormat, BASE64, serialize_display,
}; };
use crate::util::sync::Watch; use crate::util::sync::Watch;
use crate::util::Invoke;
pub const SYSTEMD_UNIT: &str = "tor@default"; pub const SYSTEMD_UNIT: &str = "tor@default";
const STARTING_HEALTH_TIMEOUT: u64 = 120; // 2min const STARTING_HEALTH_TIMEOUT: u64 = 120; // 2min
@@ -45,8 +45,7 @@ const TOR_CONTROL: SocketAddr =
SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::new(127, 0, 1, 1), 9051)); SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::new(127, 0, 1, 1), 9051));
const TOR_SOCKS: SocketAddr = SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::new(127, 0, 1, 1), 9050)); const TOR_SOCKS: SocketAddr = SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::new(127, 0, 1, 1), 9050));
#[derive(Debug, Clone, Copy, PartialEq, Eq, TS)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[ts(type = "string")]
pub struct OnionAddress(OnionAddressV3); pub struct OnionAddress(OnionAddressV3);
impl std::fmt::Display for OnionAddress { impl std::fmt::Display for OnionAddress {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
@@ -256,7 +255,6 @@ pub fn tor_api<C: Context>() -> ParentHandler<C> {
"logs", "logs",
from_fn_async(crate::logs::cli_logs::<RpcContext, Empty>) from_fn_async(crate::logs::cli_logs::<RpcContext, Empty>)
.no_display() .no_display()
.no_ts()
.with_about("Display Tor logs"), .with_about("Display Tor logs"),
) )
.subcommand( .subcommand(
@@ -314,7 +312,7 @@ pub async fn generate_key(ctx: RpcContext) -> Result<OnionAddress, Error> {
.result .result
} }
#[derive(Deserialize, Serialize, Parser, TS)] #[derive(Deserialize, Serialize, Parser)]
pub struct AddKeyParams { pub struct AddKeyParams {
pub key: Base64<[u8; 64]>, pub key: Base64<[u8; 64]>,
} }
@@ -388,7 +386,7 @@ pub async fn list_services(ctx: RpcContext, _: Empty) -> Result<Vec<OnionAddress
ctx.net_controller.tor.list_services().await ctx.net_controller.tor.list_services().await
} }
pub fn logs() -> UnknownTS<ParentHandler<RpcContext, LogsParams>> { pub fn logs() -> ParentHandler<RpcContext, LogsParams> {
crate::logs::logs::<RpcContext, Empty>(|_: &RpcContext, _| async { crate::logs::logs::<RpcContext, Empty>(|_: &RpcContext, _| async {
Ok(LogSource::Unit(SYSTEMD_UNIT)) Ok(LogSource::Unit(SYSTEMD_UNIT))
}) })
@@ -891,7 +889,8 @@ async fn torctl(
} }
} }
} }
Err(Error::new(eyre!("Log stream terminated"), ErrorKind::Tor)) // Err(Error::new(eyre!("Log stream terminated"), ErrorKind::Tor))
Ok(())
}; };
let health_checker = async { let health_checker = async {
let mut last_success = Instant::now(); let mut last_success = Instant::now();

View File

@@ -32,6 +32,7 @@ pub fn tunnel_api<C: Context>() -> ParentHandler<C> {
} }
#[derive(Debug, Clone, Deserialize, Serialize, Parser, TS)] #[derive(Debug, Clone, Deserialize, Serialize, Parser, TS)]
#[ts(export)]
pub struct AddTunnelParams { pub struct AddTunnelParams {
name: InternedString, name: InternedString,
config: String, config: String,
@@ -103,6 +104,7 @@ pub async fn add_tunnel(
} }
#[derive(Debug, Clone, Deserialize, Serialize, Parser, TS)] #[derive(Debug, Clone, Deserialize, Serialize, Parser, TS)]
#[ts(export)]
pub struct RemoveTunnelParams { pub struct RemoveTunnelParams {
id: GatewayId, id: GatewayId,
} }

View File

@@ -1,5 +1,6 @@
use std::any::Any; use std::any::Any;
use std::collections::{BTreeMap, BTreeSet}; use std::collections::{BTreeMap, BTreeSet};
use std::fmt;
use std::net::{IpAddr, SocketAddr}; use std::net::{IpAddr, SocketAddr};
use std::sync::{Arc, Weak}; use std::sync::{Arc, Weak};
use std::task::{Poll, ready}; use std::task::{Poll, ready};
@@ -41,6 +42,7 @@ use crate::net::tls::{
use crate::net::web_server::{Accept, AcceptStream, ExtractVisitor, TcpMetadata, extract}; use crate::net::web_server::{Accept, AcceptStream, ExtractVisitor, TcpMetadata, extract};
use crate::prelude::*; use crate::prelude::*;
use crate::util::collections::EqSet; use crate::util::collections::EqSet;
use crate::util::future::WeakFuture;
use crate::util::serde::{HandlerExtSerde, MaybeUtf8String, display_serializable}; use crate::util::serde::{HandlerExtSerde, MaybeUtf8String, display_serializable};
use crate::util::sync::{SyncMutex, Watch}; use crate::util::sync::{SyncMutex, Watch};
@@ -186,7 +188,7 @@ pub trait VHostTarget<A: Accept>: std::fmt::Debug + Eq {
hello: &'a ClientHello<'a>, hello: &'a ClientHello<'a>,
metadata: &'a <A as Accept>::Metadata, metadata: &'a <A as Accept>::Metadata,
) -> impl Future<Output = Option<(ServerConfig, Self::PreprocessRes)>> + Send + 'a; ) -> impl Future<Output = Option<(ServerConfig, Self::PreprocessRes)>> + Send + 'a;
fn handle_stream(&self, stream: AcceptStream, prev: Self::PreprocessRes); fn handle_stream(&self, stream: AcceptStream, prev: Self::PreprocessRes, rc: Weak<()>);
} }
pub trait DynVHostTargetT<A: Accept>: std::fmt::Debug + Any { pub trait DynVHostTargetT<A: Accept>: std::fmt::Debug + Any {
@@ -198,7 +200,7 @@ pub trait DynVHostTargetT<A: Accept>: std::fmt::Debug + Any {
hello: &'a ClientHello<'a>, hello: &'a ClientHello<'a>,
metadata: &'a <A as Accept>::Metadata, metadata: &'a <A as Accept>::Metadata,
) -> BoxFuture<'a, Option<(ServerConfig, Box<dyn Any + Send>)>>; ) -> BoxFuture<'a, Option<(ServerConfig, Box<dyn Any + Send>)>>;
fn handle_stream(&self, stream: AcceptStream, prev: Box<dyn Any + Send>); fn handle_stream(&self, stream: AcceptStream, prev: Box<dyn Any + Send>, rc: Weak<()>);
fn eq(&self, other: &dyn DynVHostTargetT<A>) -> bool; fn eq(&self, other: &dyn DynVHostTargetT<A>) -> bool;
} }
impl<A: Accept, T: VHostTarget<A> + 'static> DynVHostTargetT<A> for T { impl<A: Accept, T: VHostTarget<A> + 'static> DynVHostTargetT<A> for T {
@@ -218,9 +220,9 @@ impl<A: Accept, T: VHostTarget<A> + 'static> DynVHostTargetT<A> for T {
.map(|o| o.map(|(cfg, res)| (cfg, Box::new(res) as Box<dyn Any + Send>))) .map(|o| o.map(|(cfg, res)| (cfg, Box::new(res) as Box<dyn Any + Send>)))
.boxed() .boxed()
} }
fn handle_stream(&self, stream: AcceptStream, prev: Box<dyn Any + Send>) { fn handle_stream(&self, stream: AcceptStream, prev: Box<dyn Any + Send>, rc: Weak<()>) {
if let Ok(prev) = prev.downcast() { if let Ok(prev) = prev.downcast() {
VHostTarget::handle_stream(self, stream, *prev); VHostTarget::handle_stream(self, stream, *prev, rc);
} }
} }
fn eq(&self, other: &dyn DynVHostTargetT<A>) -> bool { fn eq(&self, other: &dyn DynVHostTargetT<A>) -> bool {
@@ -250,21 +252,27 @@ impl<A: Accept + 'static> PartialEq for DynVHostTarget<A> {
} }
} }
impl<A: Accept + 'static> Eq for DynVHostTarget<A> {} impl<A: Accept + 'static> Eq for DynVHostTarget<A> {}
struct Preprocessed<A: Accept>(DynVHostTarget<A>, Box<dyn Any + Send>); struct Preprocessed<A: Accept>(DynVHostTarget<A>, Weak<()>, Box<dyn Any + Send>);
impl<A: Accept> fmt::Debug for Preprocessed<A> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
(self.0).0.fmt(f)
}
}
impl<A: Accept + 'static> DynVHostTarget<A> { impl<A: Accept + 'static> DynVHostTarget<A> {
async fn into_preprocessed( async fn into_preprocessed(
self, self,
rc: Weak<()>,
prev: ServerConfig, prev: ServerConfig,
hello: &ClientHello<'_>, hello: &ClientHello<'_>,
metadata: &<A as Accept>::Metadata, metadata: &<A as Accept>::Metadata,
) -> Option<(ServerConfig, Preprocessed<A>)> { ) -> Option<(ServerConfig, Preprocessed<A>)> {
let (cfg, res) = self.0.preprocess(prev, hello, metadata).await?; let (cfg, res) = self.0.preprocess(prev, hello, metadata).await?;
Some((cfg, Preprocessed(self, res))) Some((cfg, Preprocessed(self, rc, res)))
} }
} }
impl<A: Accept + 'static> Preprocessed<A> { impl<A: Accept + 'static> Preprocessed<A> {
fn finish(self, stream: AcceptStream) { fn finish(self, stream: AcceptStream) {
(self.0).0.handle_stream(stream, self.1); (self.0).0.handle_stream(stream, self.2, self.1);
} }
} }
@@ -278,6 +286,7 @@ pub struct ProxyTarget {
impl PartialEq for ProxyTarget { impl PartialEq for ProxyTarget {
fn eq(&self, other: &Self) -> bool { fn eq(&self, other: &Self) -> bool {
self.filter == other.filter self.filter == other.filter
&& self.acme == other.acme
&& self.addr == other.addr && self.addr == other.addr
&& self.connect_ssl.as_ref().map(Arc::as_ptr) && self.connect_ssl.as_ref().map(Arc::as_ptr)
== other.connect_ssl.as_ref().map(Arc::as_ptr) == other.connect_ssl.as_ref().map(Arc::as_ptr)
@@ -293,6 +302,9 @@ where
type PreprocessRes = AcceptStream; type PreprocessRes = AcceptStream;
fn filter(&self, metadata: &<A as Accept>::Metadata) -> bool { fn filter(&self, metadata: &<A as Accept>::Metadata) -> bool {
let info = extract::<GatewayInfo, _>(metadata); let info = extract::<GatewayInfo, _>(metadata);
if info.is_none() {
tracing::warn!("No GatewayInfo on metadata");
}
info.as_ref() info.as_ref()
.map_or(true, |i| self.filter.filter(&i.id, &i.info)) .map_or(true, |i| self.filter.filter(&i.id, &i.info))
} }
@@ -303,7 +315,7 @@ where
&'a self, &'a self,
mut prev: ServerConfig, mut prev: ServerConfig,
hello: &'a ClientHello<'a>, hello: &'a ClientHello<'a>,
metadata: &'a <A as Accept>::Metadata, _: &'a <A as Accept>::Metadata,
) -> Option<(ServerConfig, Self::PreprocessRes)> { ) -> Option<(ServerConfig, Self::PreprocessRes)> {
let tcp_stream = TcpStream::connect(self.addr) let tcp_stream = TcpStream::connect(self.addr)
.await .await
@@ -344,13 +356,16 @@ where
} }
Some((prev, Box::pin(tcp_stream))) Some((prev, Box::pin(tcp_stream)))
} }
fn handle_stream(&self, mut stream: AcceptStream, mut prev: Self::PreprocessRes) { fn handle_stream(&self, mut stream: AcceptStream, mut prev: Self::PreprocessRes, rc: Weak<()>) {
tokio::spawn(async move { tokio::io::copy_bidirectional(&mut stream, &mut prev).await }); tokio::spawn(async move {
WeakFuture::new(rc, tokio::io::copy_bidirectional(&mut stream, &mut prev)).await
});
} }
} }
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize, TS)] #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub enum AlpnInfo { pub enum AlpnInfo {
Reflect, Reflect,
Specified(Vec<MaybeUtf8String>), Specified(Vec<MaybeUtf8String>),
@@ -434,16 +449,16 @@ where
return Some(prev); return Some(prev);
} }
let target = self.0.peek(|m| { let (target, rc) = self.0.peek(|m| {
m.get(&hello.server_name().map(InternedString::from)) m.get(&hello.server_name().map(InternedString::from))
.into_iter() .into_iter()
.flatten() .flatten()
.filter(|(_, rc)| rc.strong_count() > 0) .filter(|(_, rc)| rc.strong_count() > 0)
.find(|(t, _)| t.0.filter(metadata)) .find(|(t, _)| t.0.filter(metadata))
.map(|(e, _)| e.clone()) .map(|(t, rc)| (t.clone(), rc.clone()))
})?; })?;
let (prev, store) = target.into_preprocessed(prev, hello, metadata).await?; let (prev, store) = target.into_preprocessed(rc, prev, hello, metadata).await?;
self.1 = Some(store); self.1 = Some(store);
@@ -478,6 +493,14 @@ struct VHostListenerMetadata<A: Accept> {
inner: TlsMetadata<A::Metadata>, inner: TlsMetadata<A::Metadata>,
preprocessed: Preprocessed<A>, preprocessed: Preprocessed<A>,
} }
impl<A: Accept> fmt::Debug for VHostListenerMetadata<A> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("VHostListenerMetadata")
.field("inner", &self.inner)
.field("preprocessed", &self.preprocessed)
.finish()
}
}
impl<M, A> Accept for VHostListener<M, A> impl<M, A> Accept for VHostListener<M, A>
where where
for<'a> M: HasModel<Model = Model<M>> for<'a> M: HasModel<Model = Model<M>>
@@ -635,6 +658,7 @@ impl<A: Accept> VHostServer<A> {
changed = true; changed = true;
Arc::new(()) Arc::new(())
}; };
targets.retain(|_, rc| rc.strong_count() > 0);
targets.insert(target, Arc::downgrade(&rc)); targets.insert(target, Arc::downgrade(&rc));
writable.insert(hostname, targets); writable.insert(hostname, targets);
res = Ok(rc); res = Ok(rc);

View File

@@ -1,3 +1,4 @@
use core::fmt;
use std::any::Any; use std::any::Any;
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::future::Future; use std::future::Future;
@@ -68,7 +69,7 @@ pub fn extract<
metadata: &M, metadata: &M,
) -> Option<T> { ) -> Option<T> {
let mut visitor = ExtractVisitor(None); let mut visitor = ExtractVisitor(None);
visitor.visit(metadata); metadata.visit(&mut visitor);
visitor.0 visitor.0
} }
@@ -84,7 +85,7 @@ impl<V: MetadataVisitor> Visit<V> for TcpMetadata {
} }
pub trait Accept { pub trait Accept {
type Metadata; type Metadata: fmt::Debug;
fn poll_accept( fn poll_accept(
&mut self, &mut self,
cx: &mut std::task::Context<'_>, cx: &mut std::task::Context<'_>,
@@ -144,7 +145,7 @@ where
} }
} }
#[derive(Clone, VisitFields)] #[derive(Debug, Clone, VisitFields)]
pub struct MapListenerMetadata<K, M> { pub struct MapListenerMetadata<K, M> {
pub inner: M, pub inner: M,
pub key: K, pub key: K,
@@ -162,7 +163,7 @@ where
impl<K, A> Accept for BTreeMap<K, A> impl<K, A> Accept for BTreeMap<K, A>
where where
K: Clone, K: Clone + fmt::Debug,
A: Accept, A: Accept,
{ {
type Metadata = MapListenerMetadata<K, A::Metadata>; type Metadata = MapListenerMetadata<K, A::Metadata>;
@@ -218,40 +219,38 @@ trait DynAcceptT: Send + Sync {
fn poll_accept( fn poll_accept(
&mut self, &mut self,
cx: &mut std::task::Context<'_>, cx: &mut std::task::Context<'_>,
) -> Poll< ) -> Poll<Result<(DynMetadata, AcceptStream), Error>>;
Result<
(
Box<dyn for<'a> Visit<ExtensionVisitor<'a>> + Send + Sync>,
AcceptStream,
),
Error,
>,
>;
} }
impl<A> DynAcceptT for A impl<A> DynAcceptT for A
where where
A: Accept + Send + Sync, A: Accept + Send + Sync,
for<'a> <A as Accept>::Metadata: Visit<ExtensionVisitor<'a>> + Send + Sync + 'static, <A as Accept>::Metadata: DynMetadataT + 'static,
{ {
fn poll_accept( fn poll_accept(
&mut self, &mut self,
cx: &mut std::task::Context<'_>, cx: &mut std::task::Context<'_>,
) -> Poll< ) -> Poll<Result<(DynMetadata, AcceptStream), Error>> {
Result<
(
Box<dyn for<'a> Visit<ExtensionVisitor<'a>> + Send + Sync>,
AcceptStream,
),
Error,
>,
> {
let (metadata, stream) = ready!(Accept::poll_accept(self, cx)?); let (metadata, stream) = ready!(Accept::poll_accept(self, cx)?);
Poll::Ready(Ok((Box::new(metadata), stream))) Poll::Ready(Ok((DynMetadata(Box::new(metadata)), stream)))
} }
} }
pub struct DynAccept(Box<dyn DynAcceptT>); pub struct DynAccept(Box<dyn DynAcceptT>);
trait DynMetadataT: for<'a> Visit<ExtensionVisitor<'a>> + fmt::Debug + Send + Sync {}
impl<T> DynMetadataT for T where for<'a> T: Visit<ExtensionVisitor<'a>> + fmt::Debug + Send + Sync {}
#[derive(Debug)]
pub struct DynMetadata(Box<dyn DynMetadataT>);
impl<'a> Visit<ExtensionVisitor<'a>> for DynMetadata {
fn visit(
&self,
visitor: &mut ExtensionVisitor<'a>,
) -> <ExtensionVisitor<'a> as Visitor>::Result {
self.0.visit(visitor)
}
}
impl Accept for DynAccept { impl Accept for DynAccept {
type Metadata = Box<dyn for<'a> Visit<ExtensionVisitor<'a>> + Send + Sync>; type Metadata = DynMetadata;
fn poll_accept( fn poll_accept(
&mut self, &mut self,
cx: &mut std::task::Context<'_>, cx: &mut std::task::Context<'_>,
@@ -325,7 +324,7 @@ impl Acceptor<Vec<DynAccept>> {
} }
impl<K> Acceptor<BTreeMap<K, TcpListener>> impl<K> Acceptor<BTreeMap<K, TcpListener>>
where where
K: Ord + Clone + Send + Sync + 'static, K: Ord + Clone + fmt::Debug + Send + Sync + 'static,
{ {
pub async fn bind_map( pub async fn bind_map(
listen: impl IntoIterator<Item = (K, SocketAddr)>, listen: impl IntoIterator<Item = (K, SocketAddr)>,
@@ -347,7 +346,7 @@ where
} }
impl<K> Acceptor<BTreeMap<K, DynAccept>> impl<K> Acceptor<BTreeMap<K, DynAccept>>
where where
K: Ord + Clone + Send + Sync + 'static, K: Ord + Clone + fmt::Debug + Send + Sync + 'static,
{ {
pub async fn bind_map_dyn( pub async fn bind_map_dyn(
listen: impl IntoIterator<Item = (K, SocketAddr)>, listen: impl IntoIterator<Item = (K, SocketAddr)>,

View File

@@ -343,23 +343,22 @@ pub async fn remove(ctx: RpcContext, SsidParams { ssid }: SsidParams) -> Result<
.result?; .result?;
Ok(()) Ok(())
} }
#[derive(serde::Serialize, serde::Deserialize, TS)] #[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct WifiListInfo { pub struct WifiListInfo {
ssids: HashMap<Ssid, SignalStrength>, ssids: HashMap<Ssid, SignalStrength>,
connected: Option<Ssid>, connected: Option<Ssid>,
#[ts(type = "sttring | null")]
country: Option<CountryCode>, country: Option<CountryCode>,
ethernet: bool, ethernet: bool,
available_wifi: Vec<WifiListOut>, available_wifi: Vec<WifiListOut>,
} }
#[derive(serde::Serialize, serde::Deserialize, Clone, TS)] #[derive(serde::Serialize, serde::Deserialize, Clone)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct WifiListInfoLow { pub struct WifiListInfoLow {
strength: SignalStrength, strength: SignalStrength,
security: Vec<String>, security: Vec<String>,
} }
#[derive(serde::Serialize, serde::Deserialize, TS)] #[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct WifiListOut { pub struct WifiListOut {
ssid: Ssid, ssid: Ssid,
@@ -590,7 +589,7 @@ pub struct NetworkId(String);
/// Ssid are the names of the wifis, usually human readable. /// Ssid are the names of the wifis, usually human readable.
#[derive( #[derive(
Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, serde::Serialize, serde::Deserialize, TS, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, serde::Serialize, serde::Deserialize,
)] )]
pub struct Ssid(String); pub struct Ssid(String);
@@ -607,7 +606,6 @@ pub struct Ssid(String);
Hash, Hash,
serde::Serialize, serde::Serialize,
serde::Deserialize, serde::Deserialize,
TS,
)] )]
pub struct SignalStrength(u8); pub struct SignalStrength(u8);

View File

@@ -388,7 +388,7 @@ impl Map for Notifications {
} }
} }
#[derive(Debug, Serialize, Deserialize, HasModel, TS)] #[derive(Debug, Serialize, Deserialize, HasModel)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[model = "Model<Self>"] #[model = "Model<Self>"]
pub struct Notification { pub struct Notification {
@@ -403,7 +403,7 @@ pub struct Notification {
pub seen: bool, pub seen: bool,
} }
#[derive(Debug, Serialize, Deserialize, TS)] #[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct NotificationWithId { pub struct NotificationWithId {
id: u32, id: u32,

View File

@@ -356,7 +356,10 @@ pub async fn execute<C: Context>(
let mut install = Command::new("chroot"); let mut install = Command::new("chroot");
install.arg(overlay.path()).arg("grub-install"); install.arg(overlay.path()).arg("grub-install");
if tokio::fs::metadata("/sys/firmware/efi").await.is_err() { if tokio::fs::metadata("/sys/firmware/efi").await.is_err() {
install.arg("--target=i386-pc"); match ARCH {
"x86_64" => install.arg("--target=i386-pc"),
_ => &mut install,
};
} else { } else {
match ARCH { match ARCH {
"x86_64" => install.arg("--target=x86_64-efi"), "x86_64" => install.arg("--target=x86_64-efi"),
@@ -372,7 +375,7 @@ pub async fn execute<C: Context>(
Command::new("chroot") Command::new("chroot")
.arg(overlay.path()) .arg(overlay.path())
.arg("update-grub2") .arg("update-grub")
.invoke(crate::ErrorKind::Grub) .invoke(crate::ErrorKind::Grub)
.await?; .await?;
dev.unmount(false).await?; dev.unmount(false).await?;

View File

@@ -196,6 +196,7 @@ impl std::ops::AddAssign<u64> for Progress {
} }
#[derive(Debug, Clone, Deserialize, Serialize, TS)] #[derive(Debug, Clone, Deserialize, Serialize, TS)]
#[ts(export)]
pub struct NamedProgress { pub struct NamedProgress {
#[ts(type = "string")] #[ts(type = "string")]
pub name: InternedString, pub name: InternedString,
@@ -203,6 +204,7 @@ pub struct NamedProgress {
} }
#[derive(Debug, Clone, Deserialize, Serialize, TS)] #[derive(Debug, Clone, Deserialize, Serialize, TS)]
#[ts(export)]
pub struct FullProgress { pub struct FullProgress {
pub overall: Progress, pub overall: Progress,
pub phases: Vec<NamedProgress>, pub phases: Vec<NamedProgress>,

View File

@@ -32,7 +32,6 @@ pub fn admin_api<C: Context>() -> ParentHandler<C> {
"add", "add",
from_fn_async(cli_add_admin) from_fn_async(cli_add_admin)
.no_display() .no_display()
.no_ts()
.with_about("Add admin signer"), .with_about("Add admin signer"),
) )
.subcommand( .subcommand(
@@ -73,7 +72,7 @@ fn signers_api<C: Context>() -> ParentHandler<C> {
) )
.subcommand( .subcommand(
"add", "add",
from_fn_async(cli_add_signer).no_ts().with_about("Add signer"), from_fn_async(cli_add_signer).with_about("Add signer"),
) )
.subcommand( .subcommand(
"edit", "edit",
@@ -173,6 +172,7 @@ pub async fn add_signer(ctx: RegistryContext, signer: SignerInfo) -> Result<Guid
#[derive(Debug, Deserialize, Serialize, Parser, TS)] #[derive(Debug, Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")] #[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct EditSignerParams { pub struct EditSignerParams {
pub id: Guid, pub id: Guid,
#[arg(short = 'n', long)] #[arg(short = 'n', long)]
@@ -280,6 +280,7 @@ pub async fn cli_add_signer(
#[derive(Debug, Deserialize, Serialize, TS)] #[derive(Debug, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct AddAdminParams { pub struct AddAdminParams {
pub signer: Guid, pub signer: Guid,
} }
@@ -304,6 +305,7 @@ pub async fn add_admin(
#[derive(Debug, Deserialize, Serialize, Parser, TS)] #[derive(Debug, Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct RemoveAdminParams { pub struct RemoveAdminParams {
pub signer: Guid, pub signer: Guid,
} }

View File

@@ -22,6 +22,7 @@ use crate::upload::UploadingFile;
#[derive(Debug, Deserialize, Serialize, TS)] #[derive(Debug, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct RegistryAsset<Commitment> { pub struct RegistryAsset<Commitment> {
#[ts(type = "string")] #[ts(type = "string")]
pub published_at: DateTime<Utc>, pub published_at: DateTime<Utc>,

View File

@@ -22,24 +22,18 @@ pub fn db_api<C: Context>() -> ParentHandler<C> {
"dump", "dump",
from_fn_async(cli_dump) from_fn_async(cli_dump)
.with_display_serializable() .with_display_serializable()
.no_ts()
.with_about("Filter/query db to display tables and records"), .with_about("Filter/query db to display tables and records"),
) )
.subcommand( .subcommand(
"dump", "dump",
from_fn_async(dump) from_fn_async(dump)
.with_metadata("admin", Value::Bool(true)) .with_metadata("admin", Value::Bool(true))
.no_cli() .no_cli(),
.custom_ts(
DumpParams::inline_flattened(),
format!("{{ id: number; value: unknown }}"),
),
) )
.subcommand( .subcommand(
"apply", "apply",
from_fn_async(cli_apply) from_fn_async(cli_apply)
.no_display() .no_display()
.no_ts()
.with_about("Update a db record"), .with_about("Update a db record"),
) )
.subcommand( .subcommand(

View File

@@ -47,6 +47,7 @@ pub fn info_api<C: Context>() -> ParentHandler<C, WithIoFormat<Empty>> {
#[derive(Debug, Default, Deserialize, Serialize, TS)] #[derive(Debug, Default, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct RegistryInfo { pub struct RegistryInfo {
pub name: Option<String>, pub name: Option<String>,
pub icon: Option<DataUrl<'static>>, pub icon: Option<DataUrl<'static>>,
@@ -65,6 +66,7 @@ pub async fn get_info(ctx: RegistryContext) -> Result<RegistryInfo, Error> {
#[derive(Debug, Deserialize, Serialize, Parser, TS)] #[derive(Debug, Deserialize, Serialize, Parser, TS)]
#[command(rename_all = "kebab-case")] #[command(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct SetNameParams { pub struct SetNameParams {
pub name: String, pub name: String,
} }
@@ -81,6 +83,7 @@ pub async fn set_name(
#[derive(Debug, Deserialize, Serialize, TS)] #[derive(Debug, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct SetIconParams { pub struct SetIconParams {
pub icon: DataUrl<'static>, pub icon: DataUrl<'static>,
} }
@@ -98,6 +101,7 @@ pub async fn set_icon(
#[derive(Debug, Deserialize, Serialize, Parser, TS)] #[derive(Debug, Deserialize, Serialize, Parser, TS)]
#[command(rename_all = "kebab-case")] #[command(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct CliSetIconParams { pub struct CliSetIconParams {
pub icon: PathBuf, pub icon: PathBuf,
} }

View File

@@ -11,6 +11,7 @@ use crate::context::CliContext;
use crate::middleware::cors::Cors; use crate::middleware::cors::Cors;
use crate::middleware::signature::SignatureAuth; use crate::middleware::signature::SignatureAuth;
use crate::net::static_server::{bad_request, not_found, server_error}; use crate::net::static_server::{bad_request, not_found, server_error};
use crate::net::web_server::{Accept, WebServer};
use crate::prelude::*; use crate::prelude::*;
use crate::registry::context::RegistryContext; use crate::registry::context::RegistryContext;
use crate::registry::device_info::DeviceInfoMiddleware; use crate::registry::device_info::DeviceInfoMiddleware;
@@ -42,6 +43,7 @@ impl RegistryDatabase {}
#[derive(Debug, Default, Deserialize, Serialize, HasModel, TS)] #[derive(Debug, Default, Deserialize, Serialize, HasModel, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[model = "Model<Self>"] #[model = "Model<Self>"]
#[ts(export)]
pub struct FullIndex { pub struct FullIndex {
pub name: Option<String>, pub name: Option<String>,
pub icon: Option<DataUrl<'static>>, pub icon: Option<DataUrl<'static>>,

View File

@@ -75,6 +75,7 @@ pub fn remove_api<C: Context>() -> ParentHandler<C> {
#[derive(Debug, Deserialize, Serialize, TS)] #[derive(Debug, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct AddAssetParams { pub struct AddAssetParams {
#[ts(type = "string")] #[ts(type = "string")]
pub version: Version, pub version: Version,
@@ -282,6 +283,7 @@ pub async fn cli_add_asset(
#[derive(Debug, Deserialize, Serialize, TS)] #[derive(Debug, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct RemoveAssetParams { pub struct RemoveAssetParams {
#[ts(type = "string")] #[ts(type = "string")]
pub version: Version, pub version: Version,

View File

@@ -30,7 +30,6 @@ pub fn get_api<C: Context>() -> ParentHandler<C> {
"iso", "iso",
from_fn_async(cli_get_os_asset) from_fn_async(cli_get_os_asset)
.no_display() .no_display()
.no_ts()
.with_about("Download iso"), .with_about("Download iso"),
) )
.subcommand("img", from_fn_async(get_img).no_cli()) .subcommand("img", from_fn_async(get_img).no_cli())
@@ -38,7 +37,6 @@ pub fn get_api<C: Context>() -> ParentHandler<C> {
"img", "img",
from_fn_async(cli_get_os_asset) from_fn_async(cli_get_os_asset)
.no_display() .no_display()
.no_ts()
.with_about("Download img"), .with_about("Download img"),
) )
.subcommand("squashfs", from_fn_async(get_squashfs).no_cli()) .subcommand("squashfs", from_fn_async(get_squashfs).no_cli())
@@ -46,13 +44,13 @@ pub fn get_api<C: Context>() -> ParentHandler<C> {
"squashfs", "squashfs",
from_fn_async(cli_get_os_asset) from_fn_async(cli_get_os_asset)
.no_display() .no_display()
.no_ts()
.with_about("Download squashfs"), .with_about("Download squashfs"),
) )
} }
#[derive(Debug, Deserialize, Serialize, TS)] #[derive(Debug, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct GetOsAssetParams { pub struct GetOsAssetParams {
#[ts(type = "string")] #[ts(type = "string")]
pub version: Version, pub version: Version,

View File

@@ -11,7 +11,6 @@ pub fn asset_api<C: Context>() -> ParentHandler<C> {
"add", "add",
from_fn_async(add::cli_add_asset) from_fn_async(add::cli_add_asset)
.no_display() .no_display()
.no_ts()
.with_about("Add asset to registry"), .with_about("Add asset to registry"),
) )
.subcommand("remove", add::remove_api::<C>()) .subcommand("remove", add::remove_api::<C>())
@@ -20,7 +19,6 @@ pub fn asset_api<C: Context>() -> ParentHandler<C> {
"sign", "sign",
from_fn_async(sign::cli_sign_asset) from_fn_async(sign::cli_sign_asset)
.no_display() .no_display()
.no_ts()
.with_about("Sign file and add to registry index"), .with_about("Sign file and add to registry index"),
) )
// TODO: remove signature api // TODO: remove signature api

View File

@@ -49,6 +49,7 @@ pub fn sign_api<C: Context>() -> ParentHandler<C> {
#[derive(Debug, Deserialize, Serialize, TS)] #[derive(Debug, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct SignAssetParams { pub struct SignAssetParams {
#[ts(type = "string")] #[ts(type = "string")]
version: Version, version: Version,

View File

@@ -14,6 +14,7 @@ use crate::sign::commitment::blake3::Blake3Commitment;
#[derive(Debug, Default, Deserialize, Serialize, HasModel, TS)] #[derive(Debug, Default, Deserialize, Serialize, HasModel, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[model = "Model<Self>"] #[model = "Model<Self>"]
#[ts(export)]
pub struct OsIndex { pub struct OsIndex {
pub versions: OsVersionInfoMap, pub versions: OsVersionInfoMap,
} }
@@ -36,6 +37,7 @@ impl Map for OsVersionInfoMap {
#[derive(Debug, Default, Deserialize, Serialize, HasModel, TS)] #[derive(Debug, Default, Deserialize, Serialize, HasModel, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[model = "Model<Self>"] #[model = "Model<Self>"]
#[ts(export)]
pub struct OsVersionInfo { pub struct OsVersionInfo {
pub headline: String, pub headline: String,
pub release_notes: String, pub release_notes: String,

View File

@@ -46,10 +46,6 @@ pub fn version_api<C: Context>() -> ParentHandler<C> {
"get", "get",
from_fn_async(get_version) from_fn_async(get_version)
.with_metadata("get_device_info", Value::Bool(true)) .with_metadata("get_device_info", Value::Bool(true))
.custom_ts(
GetOsVersionParams::inline_flattened(),
BTreeMap::<String, OsVersionInfo>::inline_flattened(),
)
.with_display_serializable() .with_display_serializable()
.with_custom_display_fn(|handle, result| { .with_custom_display_fn(|handle, result| {
display_version_info(handle.params, result) display_version_info(handle.params, result)
@@ -62,6 +58,7 @@ pub fn version_api<C: Context>() -> ParentHandler<C> {
#[derive(Debug, Deserialize, Serialize, Parser, TS)] #[derive(Debug, Deserialize, Serialize, Parser, TS)]
#[command(rename_all = "kebab-case")] #[command(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct AddVersionParams { pub struct AddVersionParams {
#[ts(type = "string")] #[ts(type = "string")]
pub version: Version, pub version: Version,
@@ -109,6 +106,7 @@ pub async fn add_version(
#[derive(Debug, Deserialize, Serialize, Parser, TS)] #[derive(Debug, Deserialize, Serialize, Parser, TS)]
#[command(rename_all = "kebab-case")] #[command(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct RemoveVersionParams { pub struct RemoveVersionParams {
#[ts(type = "string")] #[ts(type = "string")]
pub version: Version, pub version: Version,
@@ -133,6 +131,7 @@ pub async fn remove_version(
#[derive(Debug, Deserialize, Serialize, Parser, TS)] #[derive(Debug, Deserialize, Serialize, Parser, TS)]
#[command(rename_all = "kebab-case")] #[command(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct GetOsVersionParams { pub struct GetOsVersionParams {
#[ts(type = "string | null")] #[ts(type = "string | null")]
#[arg(long = "src")] #[arg(long = "src")]

View File

@@ -45,6 +45,7 @@ pub fn signer_api<C: Context>() -> ParentHandler<C> {
#[derive(Debug, Deserialize, Serialize, Parser, TS)] #[derive(Debug, Deserialize, Serialize, Parser, TS)]
#[command(rename_all = "kebab-case")] #[command(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct VersionSignerParams { pub struct VersionSignerParams {
#[ts(type = "string")] #[ts(type = "string")]
pub version: Version, pub version: Version,
@@ -107,6 +108,7 @@ pub async fn remove_version_signer(
#[derive(Debug, Deserialize, Serialize, Parser, TS)] #[derive(Debug, Deserialize, Serialize, Parser, TS)]
#[command(rename_all = "kebab-case")] #[command(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct ListVersionSignersParams { pub struct ListVersionSignersParams {
#[ts(type = "string")] #[ts(type = "string")]
pub version: Version, pub version: Version,

View File

@@ -26,6 +26,7 @@ use crate::util::io::TrackingIO;
#[derive(Debug, Deserialize, Serialize, TS)] #[derive(Debug, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct AddPackageParams { pub struct AddPackageParams {
#[ts(type = "string")] #[ts(type = "string")]
pub url: Url, pub url: Url,
@@ -162,6 +163,7 @@ pub async fn cli_add_package(
#[derive(Debug, Deserialize, Serialize, Parser, TS)] #[derive(Debug, Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct RemovePackageParams { pub struct RemovePackageParams {
pub id: PackageId, pub id: PackageId,
pub version: VersionString, pub version: VersionString,

View File

@@ -61,6 +61,7 @@ pub fn category_api<C: Context>() -> ParentHandler<C> {
#[derive(Debug, Deserialize, Serialize, Parser, TS)] #[derive(Debug, Deserialize, Serialize, Parser, TS)]
#[command(rename_all = "kebab-case")] #[command(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct AddCategoryParams { pub struct AddCategoryParams {
#[ts(type = "string")] #[ts(type = "string")]
pub id: InternedString, pub id: InternedString,
@@ -86,6 +87,7 @@ pub async fn add_category(
#[derive(Debug, Deserialize, Serialize, Parser, TS)] #[derive(Debug, Deserialize, Serialize, Parser, TS)]
#[command(rename_all = "kebab-case")] #[command(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct RemoveCategoryParams { pub struct RemoveCategoryParams {
#[ts(type = "string")] #[ts(type = "string")]
pub id: InternedString, pub id: InternedString,
@@ -110,6 +112,7 @@ pub async fn remove_category(
#[derive(Debug, Deserialize, Serialize, Parser, TS)] #[derive(Debug, Deserialize, Serialize, Parser, TS)]
#[command(rename_all = "kebab-case")] #[command(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct AddPackageToCategoryParams { pub struct AddPackageToCategoryParams {
#[ts(type = "string")] #[ts(type = "string")]
pub id: InternedString, pub id: InternedString,
@@ -138,6 +141,7 @@ pub async fn add_package(
#[derive(Debug, Deserialize, Serialize, Parser, TS)] #[derive(Debug, Deserialize, Serialize, Parser, TS)]
#[command(rename_all = "kebab-case")] #[command(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct RemovePackageFromCategoryParams { pub struct RemovePackageFromCategoryParams {
#[ts(type = "string")] #[ts(type = "string")]
pub id: InternedString, pub id: InternedString,

View File

@@ -19,6 +19,7 @@ use crate::util::serde::{WithIoFormat, display_serializable};
Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize, TS, ValueEnum, Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize, TS, ValueEnum,
)] )]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub enum PackageDetailLevel { pub enum PackageDetailLevel {
None, None,
Short, Short,
@@ -32,6 +33,7 @@ impl Default for PackageDetailLevel {
#[derive(Debug, Deserialize, Serialize, TS)] #[derive(Debug, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct PackageInfoShort { pub struct PackageInfoShort {
pub release_notes: String, pub release_notes: String,
} }
@@ -39,6 +41,7 @@ pub struct PackageInfoShort {
#[derive(Debug, Deserialize, Serialize, TS, Parser)] #[derive(Debug, Deserialize, Serialize, TS, Parser)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")] #[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct GetPackageParams { pub struct GetPackageParams {
pub id: Option<PackageId>, pub id: Option<PackageId>,
#[ts(type = "string | null")] #[ts(type = "string | null")]
@@ -57,6 +60,7 @@ pub struct GetPackageParams {
#[derive(Debug, Deserialize, Serialize, TS)] #[derive(Debug, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct GetPackageResponse { pub struct GetPackageResponse {
#[ts(type = "string[]")] #[ts(type = "string[]")]
pub categories: BTreeSet<InternedString>, pub categories: BTreeSet<InternedString>,
@@ -99,6 +103,7 @@ impl GetPackageResponse {
#[derive(Debug, Deserialize, Serialize, TS)] #[derive(Debug, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct GetPackageResponseFull { pub struct GetPackageResponseFull {
#[ts(type = "string[]")] #[ts(type = "string[]")]
pub categories: BTreeSet<InternedString>, pub categories: BTreeSet<InternedString>,

View File

@@ -23,6 +23,7 @@ use crate::sign::{AnySignature, AnyVerifyingKey};
#[derive(Debug, Default, Deserialize, Serialize, HasModel, TS)] #[derive(Debug, Default, Deserialize, Serialize, HasModel, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[model = "Model<Self>"] #[model = "Model<Self>"]
#[ts(export)]
pub struct PackageIndex { pub struct PackageIndex {
pub categories: BTreeMap<InternedString, Category>, pub categories: BTreeMap<InternedString, Category>,
pub packages: BTreeMap<PackageId, PackageInfo>, pub packages: BTreeMap<PackageId, PackageInfo>,
@@ -31,6 +32,7 @@ pub struct PackageIndex {
#[derive(Debug, Default, Deserialize, Serialize, HasModel, TS)] #[derive(Debug, Default, Deserialize, Serialize, HasModel, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[model = "Model<Self>"] #[model = "Model<Self>"]
#[ts(export)]
pub struct PackageInfo { pub struct PackageInfo {
pub authorized: BTreeSet<Guid>, pub authorized: BTreeSet<Guid>,
pub versions: BTreeMap<VersionString, PackageVersionInfo>, pub versions: BTreeMap<VersionString, PackageVersionInfo>,
@@ -41,6 +43,7 @@ pub struct PackageInfo {
#[derive(Debug, Deserialize, Serialize, HasModel, TS)] #[derive(Debug, Deserialize, Serialize, HasModel, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[model = "Model<Self>"] #[model = "Model<Self>"]
#[ts(export)]
pub struct Category { pub struct Category {
pub name: String, pub name: String,
} }
@@ -48,6 +51,7 @@ pub struct Category {
#[derive(Debug, Deserialize, Serialize, HasModel, TS)] #[derive(Debug, Deserialize, Serialize, HasModel, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[model = "Model<Self>"] #[model = "Model<Self>"]
#[ts(export)]
pub struct DependencyMetadata { pub struct DependencyMetadata {
#[ts(type = "string | null")] #[ts(type = "string | null")]
pub title: Option<InternedString>, pub title: Option<InternedString>,
@@ -59,6 +63,7 @@ pub struct DependencyMetadata {
#[derive(Debug, Deserialize, Serialize, HasModel, TS)] #[derive(Debug, Deserialize, Serialize, HasModel, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[model = "Model<Self>"] #[model = "Model<Self>"]
#[ts(export)]
pub struct PackageVersionInfo { pub struct PackageVersionInfo {
#[ts(type = "string")] #[ts(type = "string")]
pub title: InternedString, pub title: InternedString,

View File

@@ -29,7 +29,6 @@ pub fn package_api<C: Context>() -> ParentHandler<C> {
"add", "add",
from_fn_async(add::cli_add_package) from_fn_async(add::cli_add_package)
.no_display() .no_display()
.no_ts()
.with_about("Add package to registry index"), .with_about("Add package to registry index"),
) )
.subcommand( .subcommand(

View File

@@ -45,6 +45,7 @@ pub fn signer_api<C: Context>() -> ParentHandler<C> {
#[derive(Debug, Deserialize, Serialize, Parser, TS)] #[derive(Debug, Deserialize, Serialize, Parser, TS)]
#[command(rename_all = "kebab-case")] #[command(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct PackageSignerParams { pub struct PackageSignerParams {
pub id: PackageId, pub id: PackageId,
pub signer: Guid, pub signer: Guid,
@@ -106,6 +107,7 @@ pub async fn remove_package_signer(
#[derive(Debug, Deserialize, Serialize, Parser, TS)] #[derive(Debug, Deserialize, Serialize, Parser, TS)]
#[command(rename_all = "kebab-case")] #[command(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct ListPackageSignersParams { pub struct ListPackageSignersParams {
pub id: PackageId, pub id: PackageId,
} }

View File

@@ -15,6 +15,7 @@ use crate::sign::{AnySignature, AnyVerifyingKey, SignatureScheme};
#[derive(Debug, Deserialize, Serialize, HasModel, TS)] #[derive(Debug, Deserialize, Serialize, HasModel, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[model = "Model<Self>"] #[model = "Model<Self>"]
#[ts(export)]
pub struct SignerInfo { pub struct SignerInfo {
pub name: String, pub name: String,
pub contact: Vec<ContactInfo>, pub contact: Vec<ContactInfo>,
@@ -23,6 +24,7 @@ pub struct SignerInfo {
#[derive(Clone, Debug, Deserialize, Serialize, TS, PartialEq, Eq)] #[derive(Clone, Debug, Deserialize, Serialize, TS, PartialEq, Eq)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
// TODO: better types // TODO: better types
pub enum ContactInfo { pub enum ContactInfo {
Email(String), Email(String),
@@ -59,6 +61,7 @@ impl ValueParserFactory for ContactInfo {
#[derive(Clone, Debug, Deserialize, Serialize, TS)] #[derive(Clone, Debug, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub enum AcceptSigners { pub enum AcceptSigners {
#[serde(skip)] #[serde(skip)]
Accepted, Accepted,

View File

@@ -25,13 +25,11 @@ pub fn s9pk() -> ParentHandler<CliContext> {
"pack", "pack",
from_fn_async(super::v2::pack::pack) from_fn_async(super::v2::pack::pack)
.no_display() .no_display()
.no_ts()
.with_about("Package s9pk input files into valid s9pk"), .with_about("Package s9pk input files into valid s9pk"),
) )
.subcommand( .subcommand(
"list-ingredients", "list-ingredients",
from_fn_async(super::v2::pack::list_ingredients) from_fn_async(super::v2::pack::list_ingredients)
.no_ts()
.with_custom_display_fn(|_, ingredients| { .with_custom_display_fn(|_, ingredients| {
ingredients ingredients
.into_iter() .into_iter()
@@ -51,17 +49,16 @@ pub fn s9pk() -> ParentHandler<CliContext> {
) )
.subcommand( .subcommand(
"edit", "edit",
edit().no_ts().with_about("Commands to add an image to an s9pk or edit the manifest"), edit().with_about("Commands to add an image to an s9pk or edit the manifest"),
) )
.subcommand( .subcommand(
"inspect", "inspect",
inspect().no_ts().with_about("Commands to display file paths, file contents, or manifest"), inspect().with_about("Commands to display file paths, file contents, or manifest"),
) )
.subcommand( .subcommand(
"convert", "convert",
from_fn_async(convert) from_fn_async(convert)
.no_display() .no_display()
.no_ts()
.with_about("Convert s9pk from v1 to v2"), .with_about("Convert s9pk from v1 to v2"),
) )
} }

View File

@@ -5,7 +5,7 @@ use color_eyre::eyre::eyre;
use exver::{Version, VersionRange}; use exver::{Version, VersionRange};
use imbl_value::InternedString; use imbl_value::InternedString;
pub use models::PackageId; pub use models::PackageId;
use models::{mime, ImageId, VolumeId}; use models::{ImageId, VolumeId, mime};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use ts_rs::TS; use ts_rs::TS;
use url::Url; use url::Url;
@@ -16,15 +16,10 @@ use crate::s9pk::git_hash::GitHash;
use crate::s9pk::merkle_archive::directory_contents::DirectoryContents; use crate::s9pk::merkle_archive::directory_contents::DirectoryContents;
use crate::s9pk::merkle_archive::expected::{Expected, Filter}; use crate::s9pk::merkle_archive::expected::{Expected, Filter};
use crate::s9pk::v2::pack::ImageConfig; use crate::s9pk::v2::pack::ImageConfig;
use crate::util::serde::Regex;
use crate::util::VersionString; use crate::util::VersionString;
use crate::util::serde::Regex;
use crate::version::{Current, VersionT}; use crate::version::{Current, VersionT};
#[test]
fn export_bindings_manifest() {
Manifest::export_all_to("./bindings/manifest").unwrap();
}
fn current_version() -> Version { fn current_version() -> Version {
Current::default().semver() Current::default().semver()
} }
@@ -32,6 +27,7 @@ fn current_version() -> Version {
#[derive(Clone, Debug, Deserialize, Serialize, HasModel, TS)] #[derive(Clone, Debug, Deserialize, Serialize, HasModel, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[model = "Model<Self>"] #[model = "Model<Self>"]
#[ts(export)]
pub struct Manifest { pub struct Manifest {
pub id: PackageId, pub id: PackageId,
#[ts(type = "string")] #[ts(type = "string")]
@@ -171,6 +167,7 @@ impl Manifest {
#[derive(Clone, Debug, Default, Deserialize, Serialize, TS)] #[derive(Clone, Debug, Default, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct HardwareRequirements { pub struct HardwareRequirements {
#[serde(default)] #[serde(default)]
pub device: Vec<DeviceFilter>, pub device: Vec<DeviceFilter>,
@@ -182,6 +179,7 @@ pub struct HardwareRequirements {
#[derive(Clone, Debug, Deserialize, Serialize, TS)] #[derive(Clone, Debug, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct DeviceFilter { pub struct DeviceFilter {
#[ts(type = "\"processor\" | \"display\"")] #[ts(type = "\"processor\" | \"display\"")]
pub class: InternedString, pub class: InternedString,
@@ -191,6 +189,7 @@ pub struct DeviceFilter {
} }
#[derive(Clone, Debug, Deserialize, Serialize, TS)] #[derive(Clone, Debug, Deserialize, Serialize, TS)]
#[ts(export)]
pub struct Description { pub struct Description {
pub short: String, pub short: String,
pub long: String, pub long: String,
@@ -215,6 +214,7 @@ impl Description {
#[derive(Clone, Debug, Default, Deserialize, Serialize, TS)] #[derive(Clone, Debug, Default, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct Alerts { pub struct Alerts {
pub install: Option<String>, pub install: Option<String>,
pub uninstall: Option<String>, pub uninstall: Option<String>,

View File

@@ -248,6 +248,7 @@ impl PackParams {
#[derive(Debug, Clone, Deserialize, Serialize, TS)] #[derive(Debug, Clone, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct ImageConfig { pub struct ImageConfig {
pub source: ImageSource, pub source: ImageSource,
#[ts(type = "string[]")] #[ts(type = "string[]")]
@@ -335,6 +336,7 @@ impl clap::FromArgMatches for ImageConfig {
#[derive(Debug, Clone, Deserialize, Serialize, TS)] #[derive(Debug, Clone, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[serde(untagged)] #[serde(untagged)]
#[ts(export)]
pub enum BuildArg { pub enum BuildArg {
String(String), String(String),
EnvVar { env: String }, EnvVar { env: String },
@@ -342,6 +344,7 @@ pub enum BuildArg {
#[derive(Debug, Clone, Deserialize, Serialize, TS)] #[derive(Debug, Clone, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub enum ImageSource { pub enum ImageSource {
Packed, Packed,
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
@@ -623,6 +626,7 @@ fn tar2sqfs(dest: impl AsRef<Path>) -> Result<Command, Error> {
#[derive(Debug, Clone, Deserialize, Serialize, TS)] #[derive(Debug, Clone, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct ImageMetadata { pub struct ImageMetadata {
pub workdir: PathBuf, pub workdir: PathBuf,
#[ts(type = "string")] #[ts(type = "string")]

View File

@@ -1,9 +1,9 @@
use std::collections::BTreeSet; use std::collections::BTreeSet;
use models::{ActionId, PackageId, ReplayId}; use models::{ActionId, PackageId, ReplayId};
use rpc_toolkit::{from_fn_async, Context, HandlerExt, ParentHandler}; use rpc_toolkit::{Context, HandlerExt, ParentHandler, from_fn_async};
use crate::action::{display_action_result, ActionInput, ActionResult}; use crate::action::{ActionInput, ActionResult, display_action_result};
use crate::db::model::package::{ use crate::db::model::package::{
ActionMetadata, Task, TaskCondition, TaskEntry, TaskSeverity, TaskTrigger, ActionMetadata, Task, TaskCondition, TaskEntry, TaskSeverity, TaskTrigger,
}; };
@@ -44,6 +44,7 @@ pub fn action_api<C: Context>() -> ParentHandler<C> {
} }
#[derive(Debug, Clone, Serialize, Deserialize, TS)] #[derive(Debug, Clone, Serialize, Deserialize, TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct ExportActionParams { pub struct ExportActionParams {
id: ActionId, id: ActionId,
@@ -76,6 +77,7 @@ pub async fn export_action(
} }
#[derive(Debug, Clone, Serialize, Deserialize, TS, Parser)] #[derive(Debug, Clone, Serialize, Deserialize, TS, Parser)]
#[ts(export)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct ClearActionsParams { pub struct ClearActionsParams {
#[arg(long)] #[arg(long)]
@@ -108,6 +110,7 @@ async fn clear_actions(
#[derive(Debug, Clone, Serialize, Deserialize, TS, Parser)] #[derive(Debug, Clone, Serialize, Deserialize, TS, Parser)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct GetActionInputParams { pub struct GetActionInputParams {
#[serde(default)] #[serde(default)]
#[ts(skip)] #[ts(skip)]
@@ -145,6 +148,7 @@ async fn get_action_input(
#[derive(Debug, Clone, Serialize, Deserialize, TS, Parser)] #[derive(Debug, Clone, Serialize, Deserialize, TS, Parser)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct RunActionParams { pub struct RunActionParams {
#[serde(default)] #[serde(default)]
#[ts(skip)] #[ts(skip)]
@@ -153,8 +157,8 @@ pub struct RunActionParams {
#[ts(optional)] #[ts(optional)]
package_id: Option<PackageId>, package_id: Option<PackageId>,
action_id: ActionId, action_id: ActionId,
#[ts(optional, type = "unknown")] #[ts(type = "any")]
input: Option<Value>, input: Value,
} }
async fn run_action( async fn run_action(
context: EffectContext, context: EffectContext,
@@ -167,8 +171,6 @@ async fn run_action(
) -> Result<Option<ActionResult>, Error> { ) -> Result<Option<ActionResult>, Error> {
let context = context.deref()?; let context = context.deref()?;
let input = input.unwrap_or_default();
let package_id = package_id.as_ref().unwrap_or(&context.seed.id); let package_id = package_id.as_ref().unwrap_or(&context.seed.id);
if package_id != &context.seed.id { if package_id != &context.seed.id {
@@ -193,6 +195,7 @@ async fn run_action(
#[derive(Clone, Debug, Deserialize, Serialize, TS)] #[derive(Clone, Debug, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct CreateTaskParams { pub struct CreateTaskParams {
#[serde(default)] #[serde(default)]
#[ts(skip)] #[ts(skip)]
@@ -280,6 +283,7 @@ async fn create_task(
#[derive(Debug, Clone, Serialize, Deserialize, TS, Parser)] #[derive(Debug, Clone, Serialize, Deserialize, TS, Parser)]
#[ts(type = "{ only: string[] } | { except: string[] }")] #[ts(type = "{ only: string[] } | { except: string[] }")]
#[ts(export)]
pub struct ClearTasksParams { pub struct ClearTasksParams {
#[arg(long, conflicts_with = "except")] #[arg(long, conflicts_with = "except")]
pub only: Option<Vec<ReplayId>>, pub only: Option<Vec<ReplayId>>,

View File

@@ -293,6 +293,7 @@ impl CallbackHandlers {
#[derive(Debug, Clone, Serialize, Deserialize, TS, Parser)] #[derive(Debug, Clone, Serialize, Deserialize, TS, Parser)]
#[ts(type = "{ only: number[] } | { except: number[] }")] #[ts(type = "{ only: number[] } | { except: number[] }")]
#[ts(export)]
pub struct ClearCallbacksParams { pub struct ClearCallbacksParams {
#[arg(long, conflicts_with = "except")] #[arg(long, conflicts_with = "except")]
pub only: Option<Vec<CallbackId>>, pub only: Option<Vec<CallbackId>>,

View File

@@ -35,6 +35,7 @@ pub async fn shutdown(context: EffectContext, EventId { event_id }: EventId) ->
#[derive(Debug, Clone, Serialize, Deserialize, TS, Parser)] #[derive(Debug, Clone, Serialize, Deserialize, TS, Parser)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct GetStatusParams { pub struct GetStatusParams {
#[ts(optional)] #[ts(optional)]
pub package_id: Option<PackageId>, pub package_id: Option<PackageId>,
@@ -75,6 +76,7 @@ pub async fn get_status(
#[derive(Debug, Clone, Serialize, Deserialize, TS)] #[derive(Debug, Clone, Serialize, Deserialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub enum SetMainStatusStatus { pub enum SetMainStatusStatus {
Running, Running,
Stopped, Stopped,
@@ -98,6 +100,7 @@ impl ValueParserFactory for SetMainStatusStatus {
#[derive(Debug, Clone, Serialize, Deserialize, Parser, TS)] #[derive(Debug, Clone, Serialize, Deserialize, Parser, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct SetMainStatus { pub struct SetMainStatus {
status: SetMainStatusStatus, status: SetMainStatusStatus,
} }

View File

@@ -22,6 +22,7 @@ use crate::status::health_check::NamedHealthCheckResult;
use crate::volume::data_dir; use crate::volume::data_dir;
#[derive(Debug, Clone, Serialize, Deserialize, TS)] #[derive(Debug, Clone, Serialize, Deserialize, TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct MountTarget { pub struct MountTarget {
package_id: PackageId, package_id: PackageId,
@@ -31,6 +32,7 @@ pub struct MountTarget {
filetype: FileType, filetype: FileType,
} }
#[derive(Debug, Clone, Serialize, Deserialize, TS)] #[derive(Debug, Clone, Serialize, Deserialize, TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct MountParams { pub struct MountParams {
location: PathBuf, location: PathBuf,
@@ -96,6 +98,7 @@ pub async fn get_installed_packages(context: EffectContext) -> Result<BTreeSet<P
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize, TS)] #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub enum DependencyKind { pub enum DependencyKind {
Exists, Exists,
Running, Running,
@@ -103,6 +106,7 @@ pub enum DependencyKind {
#[derive(Debug, Clone, Deserialize, Serialize, TS)] #[derive(Debug, Clone, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase", tag = "kind")] #[serde(rename_all = "camelCase", tag = "kind")]
#[serde(rename_all_fields = "camelCase")] #[serde(rename_all_fields = "camelCase")]
#[ts(export)]
pub enum DependencyRequirement { pub enum DependencyRequirement {
Running { Running {
id: PackageId, id: PackageId,
@@ -166,6 +170,7 @@ impl ValueParserFactory for DependencyRequirement {
#[derive(Deserialize, Serialize, Parser, TS)] #[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[command(rename_all = "camelCase")] #[command(rename_all = "camelCase")]
#[ts(export)]
pub struct SetDependenciesParams { pub struct SetDependenciesParams {
dependencies: Vec<DependencyRequirement>, dependencies: Vec<DependencyRequirement>,
} }
@@ -266,12 +271,14 @@ pub async fn get_dependencies(context: EffectContext) -> Result<Vec<DependencyRe
#[derive(Debug, Clone, Serialize, Deserialize, Parser, TS)] #[derive(Debug, Clone, Serialize, Deserialize, Parser, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct CheckDependenciesParam { pub struct CheckDependenciesParam {
#[ts(optional)] #[ts(optional)]
package_ids: Option<Vec<PackageId>>, package_ids: Option<Vec<PackageId>>,
} }
#[derive(Debug, Clone, Serialize, Deserialize, TS)] #[derive(Debug, Clone, Serialize, Deserialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct CheckDependenciesResult { pub struct CheckDependenciesResult {
package_id: PackageId, package_id: PackageId,
#[ts(type = "string | null")] #[ts(type = "string | null")]

View File

@@ -6,6 +6,7 @@ use crate::status::health_check::NamedHealthCheckResult;
#[derive(Debug, Clone, Serialize, Deserialize, TS)] #[derive(Debug, Clone, Serialize, Deserialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct SetHealth { pub struct SetHealth {
id: HealthCheckId, id: HealthCheckId,
#[serde(flatten)] #[serde(flatten)]

View File

@@ -1,18 +1,17 @@
use std::net::Ipv4Addr; use std::net::Ipv4Addr;
use rpc_toolkit::{from_fn, from_fn_async, from_fn_blocking, Context, HandlerExt, ParentHandler}; use rpc_toolkit::{Context, HandlerExt, ParentHandler, from_fn, from_fn_async, from_fn_blocking};
use ts_rs::TS;
use crate::prelude::*; use crate::prelude::*;
use crate::service::cli::ContainerCliContext; use crate::service::cli::ContainerCliContext;
use crate::service::effects::context::EffectContext; use crate::service::effects::context::EffectContext;
use crate::{echo, HOST_IP}; use crate::{HOST_IP, echo};
mod action; mod action;
pub mod callbacks; pub mod callbacks;
pub mod context; pub mod context;
mod control; mod control;
pub mod dependency; mod dependency;
mod health; mod health;
mod net; mod net;
mod prelude; mod prelude;
@@ -20,22 +19,6 @@ mod subcontainer;
mod system; mod system;
mod version; mod version;
#[test]
fn export_bindings_service_effects_api() {
use rpc_toolkit::HandlerTS;
std::fs::create_dir_all("./bindings").unwrap();
std::fs::write(
"./bindings/service-effects-api.ts",
format!(
"export type ServiceEffectsApi = {}",
handler::<EffectContext>().type_info().unwrap()
)
.as_bytes(),
)
.unwrap();
}
pub fn handler<C: Context>() -> ParentHandler<C> { pub fn handler<C: Context>() -> ParentHandler<C> {
ParentHandler::new() ParentHandler::new()
.subcommand("git-info", from_fn(|_: C| crate::version::git_info())) .subcommand("git-info", from_fn(|_: C| crate::version::git_info()))
@@ -113,31 +96,20 @@ pub fn handler<C: Context>() -> ParentHandler<C> {
ParentHandler::<C>::new() ParentHandler::<C>::new()
.subcommand( .subcommand(
"launch", "launch",
from_fn_blocking(subcontainer::launch).no_display().no_ts(), from_fn_blocking(subcontainer::launch).no_display(),
) )
.subcommand( .subcommand(
"launch-init", "launch-init",
from_fn_blocking(subcontainer::launch_init) from_fn_blocking(subcontainer::launch_init).no_display(),
.no_display()
.no_ts(),
)
.subcommand(
"exec",
from_fn_blocking(subcontainer::exec).no_display().no_ts(),
) )
.subcommand("exec", from_fn_blocking(subcontainer::exec).no_display())
.subcommand( .subcommand(
"exec-command", "exec-command",
from_fn_blocking(subcontainer::exec_command) from_fn_blocking(subcontainer::exec_command).no_display(),
.no_display()
.no_ts(),
) )
.subcommand( .subcommand(
"create-fs", "create-fs",
from_fn_async(subcontainer::create_subcontainer_fs) from_fn_async(subcontainer::create_subcontainer_fs)
.custom_ts(
subcontainer::CreateSubcontainerFsParams::inline_flattened(),
"[string, string]".into(),
)
.with_custom_display_fn(|_, (path, _)| Ok(println!("{}", path.display()))) .with_custom_display_fn(|_, (path, _)| Ok(println!("{}", path.display())))
.with_call_remote::<ContainerCliContext>(), .with_call_remote::<ContainerCliContext>(),
) )

View File

@@ -5,6 +5,7 @@ use crate::service::effects::prelude::*;
#[derive(Debug, Clone, Serialize, Deserialize, TS)] #[derive(Debug, Clone, Serialize, Deserialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct BindParams { pub struct BindParams {
id: HostId, id: HostId,
internal_port: u16, internal_port: u16,
@@ -29,6 +30,7 @@ pub async fn bind(
} }
#[derive(Debug, Clone, Serialize, Deserialize, TS, Parser)] #[derive(Debug, Clone, Serialize, Deserialize, TS, Parser)]
#[ts(export)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct ClearBindingsParams { pub struct ClearBindingsParams {
#[serde(default)] #[serde(default)]
@@ -50,6 +52,7 @@ pub async fn clear_bindings(
} }
#[derive(Debug, Clone, Serialize, Deserialize, TS)] #[derive(Debug, Clone, Serialize, Deserialize, TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct GetServicePortForwardParams { pub struct GetServicePortForwardParams {
#[ts(optional)] #[ts(optional)]

View File

@@ -7,6 +7,7 @@ use crate::service::rpc::CallbackId;
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, TS)] #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct GetHostInfoParams { pub struct GetHostInfoParams {
host_id: HostId, host_id: HostId,
#[ts(optional)] #[ts(optional)]

View File

@@ -8,6 +8,7 @@ use crate::service::rpc::CallbackId;
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, TS)] #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct GetContainerIpParams { pub struct GetContainerIpParams {
#[ts(optional)] #[ts(optional)]
package_id: Option<PackageId>, package_id: Option<PackageId>,

View File

@@ -9,6 +9,7 @@ use crate::service::effects::prelude::*;
use crate::service::rpc::CallbackId; use crate::service::rpc::CallbackId;
#[derive(Debug, Clone, Serialize, Deserialize, TS)] #[derive(Debug, Clone, Serialize, Deserialize, TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct ExportServiceInterfaceParams { pub struct ExportServiceInterfaceParams {
id: ServiceInterfaceId, id: ServiceInterfaceId,
@@ -82,6 +83,7 @@ pub async fn export_service_interface(
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, TS)] #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct GetServiceInterfaceParams { pub struct GetServiceInterfaceParams {
#[ts(optional)] #[ts(optional)]
package_id: Option<PackageId>, package_id: Option<PackageId>,
@@ -122,6 +124,7 @@ pub async fn get_service_interface(
} }
#[derive(Debug, Clone, Serialize, Deserialize, TS)] #[derive(Debug, Clone, Serialize, Deserialize, TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct ListServiceInterfacesParams { pub struct ListServiceInterfacesParams {
#[ts(optional)] #[ts(optional)]
@@ -164,6 +167,7 @@ pub async fn list_service_interfaces(
} }
#[derive(Debug, Clone, Serialize, Deserialize, TS, Parser)] #[derive(Debug, Clone, Serialize, Deserialize, TS, Parser)]
#[ts(export)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct ClearServiceInterfacesParams { pub struct ClearServiceInterfacesParams {
pub except: Vec<ServiceInterfaceId>, pub except: Vec<ServiceInterfaceId>,

View File

@@ -14,6 +14,7 @@ use crate::util::serde::Pem;
#[derive(Debug, Clone, Copy, serde::Serialize, serde::Deserialize, TS, PartialEq, Eq)] #[derive(Debug, Clone, Copy, serde::Serialize, serde::Deserialize, TS, PartialEq, Eq)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub enum Algorithm { pub enum Algorithm {
Ecdsa, Ecdsa,
Ed25519, Ed25519,
@@ -21,6 +22,7 @@ pub enum Algorithm {
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, TS)] #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct GetSslCertificateParams { pub struct GetSslCertificateParams {
#[ts(type = "string[]")] #[ts(type = "string[]")]
hostnames: BTreeSet<InternedString>, hostnames: BTreeSet<InternedString>,
@@ -142,6 +144,7 @@ pub async fn get_ssl_certificate(
#[derive(Debug, Clone, Serialize, Deserialize, TS)] #[derive(Debug, Clone, Serialize, Deserialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct GetSslKeyParams { pub struct GetSslKeyParams {
#[ts(type = "string[]")] #[ts(type = "string[]")]
hostnames: BTreeSet<InternedString>, hostnames: BTreeSet<InternedString>,

View File

@@ -8,6 +8,7 @@ pub(super) use crate::service::effects::context::EffectContext;
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Parser, TS)] #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Parser, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct EventId { pub struct EventId {
#[serde(default)] #[serde(default)]
#[arg(default_value_t, long)] #[arg(default_value_t, long)]

View File

@@ -23,6 +23,7 @@ use sync_dummy as sync;
#[derive(Debug, Deserialize, Serialize, Parser, TS)] #[derive(Debug, Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct DestroySubcontainerFsParams { pub struct DestroySubcontainerFsParams {
guid: Guid, guid: Guid,
} }
@@ -69,6 +70,7 @@ pub async fn destroy_subcontainer_fs(
#[derive(Debug, Deserialize, Serialize, Parser, TS)] #[derive(Debug, Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct CreateSubcontainerFsParams { pub struct CreateSubcontainerFsParams {
image_id: ImageId, image_id: ImageId,
#[ts(type = "string | null")] #[ts(type = "string | null")]

View File

@@ -4,6 +4,7 @@ use crate::service::rpc::CallbackId;
use crate::system::SmtpValue; use crate::system::SmtpValue;
#[derive(Debug, Clone, Serialize, Deserialize, TS, Parser)] #[derive(Debug, Clone, Serialize, Deserialize, TS, Parser)]
#[ts(export)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct GetSystemSmtpParams { pub struct GetSystemSmtpParams {
#[arg(skip)] #[arg(skip)]

View File

@@ -7,6 +7,7 @@ use crate::volume::PKG_VOLUME_DIR;
#[derive(Debug, Clone, Serialize, Deserialize, TS, Parser)] #[derive(Debug, Clone, Serialize, Deserialize, TS, Parser)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct SetDataVersionParams { pub struct SetDataVersionParams {
#[ts(type = "string")] #[ts(type = "string")]
version: Option<String>, version: Option<String>,

View File

@@ -8,7 +8,7 @@ use const_format::formatcp;
use josekit::jwk::Jwk; use josekit::jwk::Jwk;
use patch_db::json_ptr::ROOT; use patch_db::json_ptr::ROOT;
use rpc_toolkit::yajrc::RpcError; use rpc_toolkit::yajrc::RpcError;
use rpc_toolkit::{from_fn_async, Context, Empty, HandlerExt, ParentHandler}; use rpc_toolkit::{Context, Empty, HandlerExt, ParentHandler, from_fn_async};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use tokio::io::AsyncWriteExt; use tokio::io::AsyncWriteExt;
use tokio::process::Command; use tokio::process::Command;
@@ -24,24 +24,24 @@ use crate::context::rpc::InitRpcContextPhases;
use crate::context::setup::SetupResult; use crate::context::setup::SetupResult;
use crate::context::{RpcContext, SetupContext}; use crate::context::{RpcContext, SetupContext};
use crate::db::model::Database; use crate::db::model::Database;
use crate::disk::REPAIR_DISK_PATH;
use crate::disk::fsck::RepairStrategy; use crate::disk::fsck::RepairStrategy;
use crate::disk::main::DEFAULT_PASSWORD; use crate::disk::main::DEFAULT_PASSWORD;
use crate::disk::mount::filesystem::cifs::Cifs;
use crate::disk::mount::filesystem::ReadWrite; use crate::disk::mount::filesystem::ReadWrite;
use crate::disk::mount::filesystem::cifs::Cifs;
use crate::disk::mount::guard::{GenericMountGuard, TmpMountGuard}; use crate::disk::mount::guard::{GenericMountGuard, TmpMountGuard};
use crate::disk::util::{pvscan, recovery_info, DiskInfo, StartOsRecoveryInfo}; use crate::disk::util::{DiskInfo, StartOsRecoveryInfo, pvscan, recovery_info};
use crate::disk::REPAIR_DISK_PATH; use crate::init::{InitPhases, InitResult, init};
use crate::init::{init, InitPhases, InitResult};
use crate::net::ssl::root_ca_start_time; use crate::net::ssl::root_ca_start_time;
use crate::prelude::*; use crate::prelude::*;
use crate::progress::{FullProgress, PhaseProgressTrackerHandle, ProgressUnits}; use crate::progress::{FullProgress, PhaseProgressTrackerHandle, ProgressUnits};
use crate::rpc_continuations::Guid; use crate::rpc_continuations::Guid;
use crate::shutdown::Shutdown; use crate::shutdown::Shutdown;
use crate::system::sync_kiosk; use crate::system::sync_kiosk;
use crate::util::crypto::EncryptedWire;
use crate::util::io::{create_file, dir_copy, dir_size, Counter};
use crate::util::Invoke; use crate::util::Invoke;
use crate::{Error, ErrorKind, ResultExt, DATA_DIR, MAIN_DATA, PACKAGE_DATA, PLATFORM}; use crate::util::crypto::EncryptedWire;
use crate::util::io::{Counter, create_file, dir_copy, dir_size};
use crate::{DATA_DIR, Error, ErrorKind, MAIN_DATA, PACKAGE_DATA, PLATFORM, ResultExt};
pub fn setup<C: Context>() -> ParentHandler<C> { pub fn setup<C: Context>() -> ParentHandler<C> {
ParentHandler::new() ParentHandler::new()
@@ -60,16 +60,13 @@ pub fn setup<C: Context>() -> ParentHandler<C> {
"get-pubkey", "get-pubkey",
from_fn_async(get_pubkey) from_fn_async(get_pubkey)
.with_metadata("authenticated", Value::Bool(false)) .with_metadata("authenticated", Value::Bool(false))
.no_cli() .no_cli(),
.custom_ts("{}".to_string(), "unknown".to_string()),
) )
.subcommand("exit", from_fn_async(exit).no_cli()) .subcommand("exit", from_fn_async(exit).no_cli())
.subcommand("logs", crate::system::logs::<SetupContext>().no_ts()) .subcommand("logs", crate::system::logs::<SetupContext>())
.subcommand( .subcommand(
"logs", "logs",
from_fn_async(crate::logs::cli_logs::<SetupContext, Empty>) from_fn_async(crate::logs::cli_logs::<SetupContext, Empty>).no_display(),
.no_display()
.no_ts(),
) )
.subcommand("restart", from_fn_async(restart).no_cli()) .subcommand("restart", from_fn_async(restart).no_cli())
} }
@@ -127,6 +124,7 @@ async fn setup_init(
#[derive(Deserialize, Serialize, TS)] #[derive(Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct AttachParams { pub struct AttachParams {
#[serde(rename = "startOsPassword")] #[serde(rename = "startOsPassword")]
password: Option<EncryptedWire>, password: Option<EncryptedWire>,
@@ -205,6 +203,7 @@ pub async fn attach(
#[derive(Debug, Deserialize, Serialize, TS)] #[derive(Debug, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
#[serde(tag = "status")] #[serde(tag = "status")]
pub enum SetupStatusRes { pub enum SetupStatusRes {
Complete(SetupResult), Complete(SetupResult),
@@ -213,6 +212,7 @@ pub enum SetupStatusRes {
#[derive(Debug, Deserialize, Serialize, TS)] #[derive(Debug, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct SetupProgress { pub struct SetupProgress {
pub progress: FullProgress, pub progress: FullProgress,
pub guid: Guid, pub guid: Guid,
@@ -249,6 +249,7 @@ pub fn cifs<C: Context>() -> ParentHandler<C> {
#[derive(Deserialize, Serialize, TS)] #[derive(Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct VerifyCifsParams { pub struct VerifyCifsParams {
hostname: String, hostname: String,
path: PathBuf, path: PathBuf,
@@ -305,6 +306,7 @@ pub enum RecoverySource<Password> {
#[derive(Deserialize, Serialize, TS)] #[derive(Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct SetupExecuteParams { pub struct SetupExecuteParams {
start_os_logicalname: PathBuf, start_os_logicalname: PathBuf,
start_os_password: EncryptedWire, start_os_password: EncryptedWire,
@@ -497,7 +499,7 @@ async fn fresh_setup(
.. ..
}: SetupExecuteProgress, }: SetupExecuteProgress,
) -> Result<(SetupResult, RpcContext), Error> { ) -> Result<(SetupResult, RpcContext), Error> {
let account = AccountInfo::new(start_os_password, root_ca_start_time().await)?; let account = AccountInfo::new(start_os_password, root_ca_start_time().await?)?;
let db = ctx.db().await?; let db = ctx.db().await?;
let kiosk = Some(kiosk.unwrap_or(true)).filter(|_| &*PLATFORM != "raspberrypi"); let kiosk = Some(kiosk.unwrap_or(true)).filter(|_| &*PLATFORM != "raspberrypi");
sync_kiosk(kiosk).await?; sync_kiosk(kiosk).await?;

View File

@@ -15,6 +15,7 @@ use crate::util::serde::Base64;
#[derive(Clone, Debug, Deserialize, Serialize, HasModel, PartialEq, Eq, TS)] #[derive(Clone, Debug, Deserialize, Serialize, HasModel, PartialEq, Eq, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[model = "Model<Self>"] #[model = "Model<Self>"]
#[ts(export)]
pub struct Blake3Commitment { pub struct Blake3Commitment {
pub hash: Base64<[u8; 32]>, pub hash: Base64<[u8; 32]>,
#[ts(type = "number")] #[ts(type = "number")]

View File

@@ -14,6 +14,7 @@ use crate::util::serde::Base64;
#[derive(Debug, Deserialize, Serialize, HasModel, TS)] #[derive(Debug, Deserialize, Serialize, HasModel, TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[model = "Model<Self>"] #[model = "Model<Self>"]
#[ts(export)]
pub struct MerkleArchiveCommitment { pub struct MerkleArchiveCommitment {
pub root_sighash: Base64<[u8; 32]>, pub root_sighash: Base64<[u8; 32]>,
#[ts(type = "number")] #[ts(type = "number")]

Some files were not shown because too many files have changed in this diff Show More