добавил прокси и докер

This commit is contained in:
2026-03-06 03:26:51 +05:00
parent b4561a0a15
commit 307b8c809b
6 changed files with 374 additions and 3 deletions

29
mod.ts
View File

@@ -9,6 +9,10 @@
import { serve } from "https://deno.land/std@0.208.0/http/server.ts";
import { YTMusic, YouTubeSearch, LastFM, fetchFromPiped, fetchFromInvidious, getLyrics, getTrendingMusic, getRadio, getTopArtists, getTopTracks, getArtistInfo, getTrackInfo, getSongComplete, getAlbumComplete, getArtistComplete, getFullChain } from "./lib.ts";
import { html as uiHtml } from "./ui.ts";
import { installProxyFetch } from "./proxy.ts";
// ── Proxy must be installed BEFORE any fetch calls ──────────────────────────
installProxyFetch();
const PORT = parseInt(Deno.env.get("PORT") || "8000");
@@ -94,6 +98,31 @@ async function handler(req: Request): Promise<Response> {
if (pathname === "/favicon.ico") return new Response(null, { status: 204 });
if (pathname === "/health") return json({ status: "ok" });
// ============ PROXY CONFIG ============
if (pathname === "/api/proxy/config") {
const httpsProxy = Deno.env.get("HTTPS_PROXY") || Deno.env.get("https_proxy");
const httpProxy = Deno.env.get("HTTP_PROXY") || Deno.env.get("http_proxy");
const proxyUrl = Deno.env.get("PROXY_URL");
const noProxy = Deno.env.get("NO_PROXY") || Deno.env.get("no_proxy");
const active = !!(httpsProxy || httpProxy || proxyUrl);
// Mask credentials in proxy URL for display
const mask = (u: string | undefined) =>
u ? u.replace(/:\/\/[^@]*@/, "://<hidden>@") : null;
return json({
proxy_enabled: active,
https_proxy: mask(httpsProxy || undefined),
http_proxy: mask(httpProxy || undefined),
proxy_url: mask(proxyUrl || undefined),
no_proxy: noProxy || null,
note: active
? "All outbound requests are routed through the proxy"
: "No proxy configured — direct connections are used",
});
}
// ============ SEARCH ============
if (pathname === "/api/search") {