File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,11 +16,31 @@ BASE="https://github.com/apernet/hysteria/releases/download/app/${HYSTERIA_VERSI
1616
1717OUT=" $( pwd) /app/executableSo"
1818
19+ # Fetch the official checksums once for integrity verification.
20+ HASHES=" $( curl -fsSL " $BASE /hashes.txt" ) "
21+
22+ sha256_tool () {
23+ if command -v sha256sum > /dev/null 2>&1 ; then sha256sum " $1 " | awk ' {print $1}'
24+ else shasum -a 256 " $1 " | awk ' {print $1}' ; fi
25+ }
26+
1927dl () {
2028 local abi=" $1 " asset=" $2 "
2129 echo " >> downloading libhysteria2.so for $abi ($asset )"
2230 mkdir -p " $OUT /$abi "
2331 curl -fL " $BASE /$asset " -o " $OUT /$abi /libhysteria2.so"
32+ # Verify against the official SHA256 (hashes.txt lines: "<sha> build/<asset>").
33+ local expected actual
34+ expected=" $( printf ' %s\n' " $HASHES " | awk -v a=" build/$asset " ' $2==a {print $1}' ) "
35+ if [ -z " $expected " ]; then
36+ echo " Error: no checksum for $asset in hashes.txt" >&2
37+ exit 1
38+ fi
39+ actual=" $( sha256_tool " $OUT /$abi /libhysteria2.so" ) "
40+ if [ " $expected " != " $actual " ]; then
41+ echo " Error: checksum mismatch for $asset (expected $expected , got $actual )" >&2
42+ exit 1
43+ fi
2444 chmod +x " $OUT /$abi /libhysteria2.so"
2545}
2646
You can’t perform that action at this time.
0 commit comments