mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2025-12-12 07:40:49 -08:00
f
This commit is contained in:
3
.github/workflows/build_master.yml
vendored
3
.github/workflows/build_master.yml
vendored
@@ -88,9 +88,8 @@ jobs:
|
||||
RATIO=$(awk "BEGIN {printf \"%.1f\", ($COMPRESSED_SIZE / $ORIGINAL_SIZE) * 100}")
|
||||
echo "Compression: ${ORIGINAL_SIZE} bytes -> ${COMPRESSED_SIZE} bytes (${RATIO}%)"
|
||||
|
||||
# Copy both versions to the searchindex repo
|
||||
# Copy ONLY the .gz version to the searchindex repo (no uncompressed .js)
|
||||
cd /tmp/searchindex-repo
|
||||
cp "${GITHUB_WORKSPACE}/${ASSET}" "${FILENAME}"
|
||||
cp "${GITHUB_WORKSPACE}/${ASSET}.gz" "${FILENAME}.gz"
|
||||
|
||||
# Stage all files
|
||||
|
||||
16
.github/workflows/translate_all.yml
vendored
16
.github/workflows/translate_all.yml
vendored
@@ -175,10 +175,8 @@ jobs:
|
||||
# Clone the searchindex repo
|
||||
git clone https://x-access-token:${TOKEN}@github.com/${TARGET_REPO}.git /tmp/searchindex-repo
|
||||
|
||||
# Copy and compress the searchindex file
|
||||
cp "$ASSET" "/tmp/searchindex-repo/${FILENAME}"
|
||||
# Compress the searchindex file
|
||||
gzip -9 -k -f "$ASSET"
|
||||
cp "${ASSET}.gz" "/tmp/searchindex-repo/${FILENAME}.gz"
|
||||
|
||||
# Show compression stats
|
||||
ORIGINAL_SIZE=$(wc -c < "$ASSET")
|
||||
@@ -186,11 +184,14 @@ jobs:
|
||||
RATIO=$(awk "BEGIN {printf \"%.1f\", ($COMPRESSED_SIZE / $ORIGINAL_SIZE) * 100}")
|
||||
echo "Compression: ${ORIGINAL_SIZE} bytes -> ${COMPRESSED_SIZE} bytes (${RATIO}%)"
|
||||
|
||||
# Copy ONLY the .gz version to the searchindex repo (no uncompressed .js)
|
||||
cp "${ASSET}.gz" "/tmp/searchindex-repo/${FILENAME}.gz"
|
||||
|
||||
# Commit and push with retry logic
|
||||
cd /tmp/searchindex-repo
|
||||
git config user.name "GitHub Actions"
|
||||
git config user.email "github-actions@github.com"
|
||||
git add "${FILENAME}" "${FILENAME}.gz"
|
||||
git add "${FILENAME}.gz"
|
||||
|
||||
if git diff --staged --quiet; then
|
||||
echo "No changes to commit"
|
||||
@@ -223,12 +224,11 @@ jobs:
|
||||
git config user.name "GitHub Actions"
|
||||
git config user.email "github-actions@github.com"
|
||||
|
||||
# Re-copy and compress the searchindex file
|
||||
cp "$ASSET" "${FILENAME}"
|
||||
# Re-copy ONLY the .gz version (no uncompressed .js)
|
||||
cp "${ASSET}.gz" "${FILENAME}.gz"
|
||||
|
||||
git add "${FILENAME}" "${FILENAME}.gz"
|
||||
git commit -m "Update ${FILENAME} from hacktricks-cloud build"
|
||||
git add "${FILENAME}.gz"
|
||||
git commit -m "Update ${FILENAME}.gz from hacktricks-cloud build"
|
||||
echo "Re-cloned and re-committed, will retry push..."
|
||||
else
|
||||
echo "Rebase failed for unknown reason, retrying anyway..."
|
||||
|
||||
@@ -44,32 +44,25 @@
|
||||
async function loadIndex(remote, local, isCloud=false){
|
||||
let rawLoaded = false;
|
||||
if(remote){
|
||||
/* Try compressed version first */
|
||||
/* Try ONLY compressed version from GitHub (remote already includes .js.gz) */
|
||||
try {
|
||||
const gzUrl = remote + '.gz';
|
||||
const r = await fetch(gzUrl,{mode:'cors'});
|
||||
const r = await fetch(remote,{mode:'cors'});
|
||||
if (r.ok) {
|
||||
const compressed = await r.arrayBuffer();
|
||||
const text = await decompressGzip(compressed);
|
||||
importScripts(URL.createObjectURL(new Blob([text],{type:'application/javascript'})));
|
||||
rawLoaded = true;
|
||||
console.log('Loaded compressed',gzUrl);
|
||||
console.log('Loaded compressed from GitHub:',remote);
|
||||
}
|
||||
} catch(e){ console.warn('compressed',remote+'.gz','failed →',e); }
|
||||
|
||||
/* Fall back to uncompressed if compressed failed */
|
||||
if(!rawLoaded){
|
||||
try {
|
||||
const r = await fetch(remote,{mode:'cors'});
|
||||
if (!r.ok) throw new Error('HTTP '+r.status);
|
||||
importScripts(URL.createObjectURL(new Blob([await r.text()],{type:'application/javascript'})));
|
||||
rawLoaded = true;
|
||||
console.log('Loaded uncompressed',remote);
|
||||
} catch(e){ console.warn('remote',remote,'failed →',e); }
|
||||
}
|
||||
} catch(e){ console.warn('compressed GitHub',remote,'failed →',e); }
|
||||
}
|
||||
/* If remote (GitHub) failed, fall back to local uncompressed file */
|
||||
if(!rawLoaded && local){
|
||||
try { importScripts(abs(local)); rawLoaded = true; }
|
||||
try {
|
||||
importScripts(abs(local));
|
||||
rawLoaded = true;
|
||||
console.log('Loaded local fallback:',local);
|
||||
}
|
||||
catch(e){ console.error('local',local,'failed →',e); }
|
||||
}
|
||||
if(!rawLoaded) return null; /* give up on this index */
|
||||
@@ -106,8 +99,9 @@
|
||||
const lang = data.lang || 'en';
|
||||
const searchindexBase = 'https://raw.githubusercontent.com/HackTricks-wiki/hacktricks-searchindex/main';
|
||||
|
||||
const mainFilenames = Array.from(new Set(['searchindex-' + lang + '.js', 'searchindex-en.js']));
|
||||
const cloudFilenames = Array.from(new Set(['searchindex-cloud-' + lang + '.js', 'searchindex-cloud-en.js']));
|
||||
/* Remote sources are .js.gz (compressed), local fallback is .js (uncompressed) */
|
||||
const mainFilenames = Array.from(new Set(['searchindex-' + lang + '.js.gz', 'searchindex-en.js.gz']));
|
||||
const cloudFilenames = Array.from(new Set(['searchindex-cloud-' + lang + '.js.gz', 'searchindex-cloud-en.js.gz']));
|
||||
|
||||
const MAIN_REMOTE_SOURCES = mainFilenames.map(function(filename) { return searchindexBase + '/' + filename; });
|
||||
const CLOUD_REMOTE_SOURCES = cloudFilenames.map(function(filename) { return searchindexBase + '/' + filename; });
|
||||
|
||||
Reference in New Issue
Block a user