ddf0ddf71e
Сквозная миграция HY2XS на современную Hysteria (2.12.2) и переход на v1. Build: - версия Hysteria резолвится на этапе сборки из HyNetworks/hysteria и замораживается в metadata пакета (version + immutable url + sha256); - compatibility gate: реальный бинарник должен принять канонический конфиг HY2XS для gecko и salamander до создания пакета; - сборка прогоняет тесты оркестратора и админки. Конфигурационный контракт: - HY2XS_CONFIG_SCHEMA_VERSION=2, чужая схема отклоняется fail-fast; - obfs стал настоящим union gecko|salamander, gecko — default; - obfs-блок рендерится оркестратором целиком, два подтипа одновременно структурно невозможны; - современный baseline: congestion bbr/standard, disableLossCompensation=false, disableStatelessReset=false, полный quic-блок. Исправления: - share URI для gecko: генератор был завязан на Obfs.Salamander.Password и выдавал нерабочую ссылку при любой другой обфускации; - SNI брался только из ACME-блока и уходил пустым при HY2XS_TLS_MODE=file; - экспорт конфига выносил trafficStats.secret, access_token и obfs-пароль; - экспорт терял неизвестные upstream-поля при round-trip через типизированную модель; - renderRuntimeEnv печатал тип обфускации литералом, расходясь с конфигом; - namedotcom удалён из ACME-реестра (нет в Hysteria с 2.11.0). Тесты: - 95 тестов оркестратора: env, рендер, семантика профиля, резолвер, rollover; - тесты URI и экспорта в Go; - tools/test/e2e-hysteria.sh с реальным клиентом Hysteria. UX: - подсказки и примеры в форме создания пира. Прочее: CHANGELOG.md, .gitattributes (LF для target-side файлов), документация на русском.
127 lines
7.4 KiB
Bash
127 lines
7.4 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
require_repo_layout() {
|
|
[ -f "LICENSE" ] || fail "missing LICENSE"
|
|
[ -d "orchestrator/src" ] || fail "missing orchestrator/src"
|
|
[ -f "orchestrator/package.json" ] || fail "missing orchestrator/package.json"
|
|
[ -f "orchestrator/bun.lock" ] || fail "missing orchestrator/bun.lock"
|
|
[ -f "package/install.sh" ] || fail "missing package/install.sh"
|
|
[ -d "package/templates" ] || fail "missing package/templates"
|
|
[ -f "package/config/hy2xs.env" ] || fail "missing package/config/hy2xs.env"
|
|
[ -f "package/templates/env/post-install.env.tpl" ] || fail "missing package/templates/env/post-install.env.tpl"
|
|
[ -d "package/systemd" ] || fail "missing package/systemd"
|
|
[ -d "apps" ] || fail "missing apps HY2XS admin source"
|
|
[ -f "apps/go.mod" ] || fail "missing apps/go.mod"
|
|
[ -f "apps/go.sum" ] || fail "missing apps/go.sum"
|
|
[ -f "apps/frontend/package.json" ] || fail "missing apps/frontend/package.json"
|
|
[ -f "apps/frontend/pnpm-lock.yaml" ] || fail "missing apps/frontend/pnpm-lock.yaml"
|
|
}
|
|
|
|
verify_source_tree_policy() {
|
|
local allow_dirty="${ALLOW_DIRTY_BUILD:-false}"
|
|
local dirty="false"
|
|
|
|
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
|
fail "build must run inside git work tree"
|
|
fi
|
|
|
|
if [ -n "$(git status --porcelain 2>/dev/null || true)" ]; then
|
|
dirty="true"
|
|
fi
|
|
|
|
if [ "$dirty" = "true" ] && [ "$allow_dirty" != "true" ]; then
|
|
fail "dirty git tree is not allowed for production build; set ALLOW_DIRTY_BUILD=true to override"
|
|
fi
|
|
}
|
|
|
|
verify_archive() {
|
|
local version="$1"
|
|
local archive="dist/hy2xs-install-${version}.tar.gz"
|
|
|
|
[ -f "$archive" ] || fail "archive was not created: $archive"
|
|
|
|
local listing
|
|
listing="$(tar -tzf "$archive")"
|
|
|
|
printf '%s\n' "$listing" | grep -q '^hy2xs-install/install.sh$' || fail "archive missing install.sh"
|
|
printf '%s\n' "$listing" | grep -q '^hy2xs-install/LICENSE$' || fail "archive missing LICENSE"
|
|
printf '%s\n' "$listing" | grep -q '^hy2xs-install/orchestrator/hy2xs-orchestrator$' || fail "archive missing orchestrator artifact"
|
|
printf '%s\n' "$listing" | grep -q '^hy2xs-install/ui/hy2xs-admin/hy2xs-admin$' || fail "archive missing bundled UI binary"
|
|
printf '%s\n' "$listing" | grep -q '^hy2xs-install/systemd/hysteria-server.service$' || fail "archive missing hysteria systemd unit"
|
|
printf '%s\n' "$listing" | grep -q '^hy2xs-install/systemd/hy2xs-admin.service$' || fail "archive missing admin systemd unit"
|
|
printf '%s\n' "$listing" | grep -q '^hy2xs-install/templates/hysteria/config.yaml.tpl$' || fail "archive missing Hysteria config template"
|
|
printf '%s\n' "$listing" | grep -q '^hy2xs-install/config/hy2xs.env$' || fail "archive missing canonical runtime config"
|
|
printf '%s\n' "$listing" | grep -q '^hy2xs-install/templates/env/post-install.env.tpl$' || fail "archive missing post-install env template"
|
|
printf '%s\n' "$listing" | grep -q '^hy2xs-install/metadata/checksums.txt$' || fail "archive missing checksums"
|
|
printf '%s\n' "$listing" | grep -q '^hy2xs-install/metadata/hysteria.version$' || fail "archive missing pinned Hysteria version"
|
|
printf '%s\n' "$listing" | grep -q '^hy2xs-install/metadata/hysteria.url$' || fail "archive missing pinned Hysteria artifact url"
|
|
printf '%s\n' "$listing" | grep -q '^hy2xs-install/metadata/hysteria.sha256$' || fail "archive missing pinned Hysteria sha256"
|
|
printf '%s\n' "$listing" | grep -q '^hy2xs-install/metadata/hysteria.resolution$' || fail "archive missing Hysteria resolution marker"
|
|
|
|
local license_text
|
|
license_text="$(tar -xOzf "$archive" hy2xs-install/LICENSE)"
|
|
printf '%s\n' "$license_text" | grep -q 'GNU AFFERO GENERAL PUBLIC LICENSE' \
|
|
|| fail "packaged LICENSE is not the GNU Affero General Public License"
|
|
printf '%s\n' "$license_text" | grep -q 'Version 3, 19 November 2007' \
|
|
|| fail "packaged LICENSE is not AGPL version 3"
|
|
|
|
local env_content
|
|
env_content="$(tar -xOzf "$archive" hy2xs-install/config/hy2xs.env)"
|
|
printf '%s\n' "$env_content" | grep -q 'replace-with-your-domain.example' && fail "packaged hy2xs.env contains placeholder domain"
|
|
printf '%s\n' "$env_content" | grep -q 'replace-with-your-email@example.com' && fail "packaged hy2xs.env contains placeholder email"
|
|
|
|
local hysteria_tpl
|
|
hysteria_tpl="$(tar -xOzf "$archive" hy2xs-install/templates/hysteria/config.yaml.tpl)"
|
|
printf '%s\n' "$hysteria_tpl" | grep -q '/hui/hysteria2/auth?access_token={{HYSTERIA_API_SECRET}}' || fail "hysteria auth template must include machine access_token"
|
|
printf '%s\n' "$hysteria_tpl" | grep -q '{{OBFS_BLOCK}}' || fail "hysteria template must render a typed obfs block"
|
|
|
|
# Замороженная версия обязана совпадать во всех местах пакета.
|
|
local pinned_version pinned_sha pinned_url meta_env
|
|
pinned_version="$(tar -xOzf "$archive" hy2xs-install/metadata/hysteria.version | tr -d '\n')"
|
|
pinned_sha="$(tar -xOzf "$archive" hy2xs-install/metadata/hysteria.sha256 | tr -d '\n')"
|
|
pinned_url="$(tar -xOzf "$archive" hy2xs-install/metadata/hysteria.url | tr -d '\n')"
|
|
meta_env="$(tar -xOzf "$archive" hy2xs-install/metadata/package.env)"
|
|
|
|
printf '%s' "$pinned_version" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+$' \
|
|
|| fail "packaged Hysteria version is not a concrete vX.Y.Z: $pinned_version"
|
|
printf '%s' "$pinned_sha" | grep -Eq '^[a-f0-9]{64}$' \
|
|
|| fail "packaged Hysteria sha256 is not a 64-char hex digest"
|
|
printf '%s' "$pinned_url" | grep -Fq "$pinned_version" \
|
|
|| fail "packaged Hysteria artifact url does not point at the pinned version: $pinned_url"
|
|
if printf '%s' "$pinned_url" | grep -q 'latest'; then
|
|
fail "packaged Hysteria artifact url must be immutable, not a moving latest: $pinned_url"
|
|
fi
|
|
|
|
printf '%s\n' "$meta_env" | grep -q "^hysteria_version=${pinned_version}$" \
|
|
|| fail "metadata package.env disagrees with metadata/hysteria.version"
|
|
printf '%s\n' "$meta_env" | grep -q "^hysteria_artifact_sha256=${pinned_sha}$" \
|
|
|| fail "metadata package.env disagrees with metadata/hysteria.sha256"
|
|
|
|
local post_install_tpl
|
|
post_install_tpl="$(tar -xOzf "$archive" hy2xs-install/templates/env/post-install.env.tpl)"
|
|
printf '%s\n' "$post_install_tpl" | grep -q '^HY2_AUTH_URL=http://127.0.0.1:{{UI_PORT}}/hui/hysteria2/auth?access_token={{HYSTERIA_API_SECRET}}$' || fail "post-install env template must include machine access_token in HY2_AUTH_URL"
|
|
|
|
local tmp
|
|
tmp="$(mktemp -d)"
|
|
tar -xzf "$archive" -C "$tmp"
|
|
[ -x "$tmp/hy2xs-install/install.sh" ] || fail "install.sh is not executable"
|
|
[ -x "$tmp/hy2xs-install/orchestrator/hy2xs-orchestrator" ] || fail "orchestrator is not executable"
|
|
[ -x "$tmp/hy2xs-install/ui/hy2xs-admin/hy2xs-admin" ] || fail "hy2xs-admin is not executable"
|
|
|
|
"$tmp/hy2xs-install/orchestrator/hy2xs-orchestrator" status --package-dir "$tmp/hy2xs-install" >/dev/null 2>&1 || fail "orchestrator status sanity check failed"
|
|
|
|
local meta
|
|
meta="$(cat "$tmp/hy2xs-install/metadata/package.env")"
|
|
printf '%s\n' "$meta" | grep -q '^source_git_commit=' || fail "metadata missing source_git_commit"
|
|
printf '%s\n' "$meta" | grep -q '^dirty_tree=' || fail "metadata missing dirty_tree"
|
|
printf '%s\n' "$meta" | grep -q '^build_profile=production$' || fail "metadata missing build_profile=production"
|
|
printf '%s\n' "$meta" | grep -q '^license=AGPL-3.0-only$' || fail "metadata missing license=AGPL-3.0-only"
|
|
|
|
if declare -F run_fix20_acceptance_subset >/dev/null 2>&1; then
|
|
run_fix20_acceptance_subset "$tmp/hy2xs-install"
|
|
fi
|
|
|
|
rm -rf "$tmp"
|
|
}
|