Skip to content

code.gs updated by myself #485

@DerafshAtur

Description

@DerafshAtur

recently i posted about newer code.gs that has been released by masterking32
#477 (comment)

i was able to update it and intregate both codes together via AI and it works gladly
this is the code hope you update it:
https://github.com/DerafshAtur/MasterHttpRelayVPN-RUST/blob/main/assets/apps_script/Code.gs

AI RESPONE:

🔧 What was Changed

Batch error handling – The catch block inside if (Array.isArray(requests)) was rewritten.
Before (Rust): If fetchAll failed, it directly returned a decoy page (or a JSON error in diagnostic mode).
Now: It first attempts a per‑request fallback before falling back to the original decoy/diagnostic response.

➕ What was Added

Fallback loop – Inside the new catch block, a try/catch iterates over each request.

Safe‑method filter – Only GET, HEAD, and OPTIONS are retried individually (body is omitted for GET/HEAD).

Error result object – If an individual fetch fails, a { status: 502, ... } result is pushed into the array.

Final safety net – A second catch handles the unlikely case that even the fallback loop crashes, and then returns the original decoy/JSON error.

✂️ What was Removed

Nothing was removed. The original error‑return code (decoy / diagnostic) is still present – it’s just now used as the last resort if the fallback itself fails.

All other functions (caching, auth, decoy, cache management) are identical to the Rust version.

🔒 What was Kept unchanged

AUTH_KEY validation (query param or header)

Spreadsheet‑based caching (cacheGet, cacheSet, isCacheable)

Anti‑probing decoy HTML (generateDecoyHTML)

Diagnostic mode (DIAGNOSTIC_MODE flag)

Cache management endpoints (viewCacheStats, clearExpiredCache, wipeEntireCache)

Single‑request mode (identical to Rust version)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions