Refactor Tunnel
This commit is contained in:
@@ -21,8 +21,9 @@ const CLIENT_PING_FAST_MS = 10000;
|
||||
const CLIENT_PING_SLOW_MS = 60000;
|
||||
const CLIENT_PING_TIMEOUT_MS = 5000;
|
||||
|
||||
// Browser-side health probe: must reach origin (not just CF edge).
|
||||
// CORS mode → res.ok=false for 5xx (Cloudflare Error 1033 when origin dead).
|
||||
// Browser-side health probe: must reach origin (not just CF/TS edge).
|
||||
// cors mode → res.ok=false for 5xx (e.g. Cloudflare 530 when origin dead).
|
||||
// /api/health route sets Access-Control-Allow-Origin: * → CORS works through tunnel.
|
||||
async function clientPingUrl(url) {
|
||||
if (!url) return false;
|
||||
try {
|
||||
|
||||
@@ -577,9 +577,6 @@ export default function ProxyPoolsPage() {
|
||||
<div className="flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between">
|
||||
<div className="min-w-0">
|
||||
<h1 className="text-xl font-semibold sm:text-2xl">Proxy Pools</h1>
|
||||
<p className="text-sm text-text-muted mt-1">
|
||||
Manage reusable per-connection proxies and bind them to provider connections.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 gap-2 sm:flex sm:items-center">
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { disableTunnel } from "@/lib/tunnel/tunnelManager";
|
||||
import { disableTunnel } from "@/lib/tunnel";
|
||||
|
||||
export async function POST() {
|
||||
try {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { enableTunnel } from "@/lib/tunnel/tunnelManager";
|
||||
import { enableTunnel } from "@/lib/tunnel";
|
||||
|
||||
const DNS_WARMUP_DELAY_MS = 8000;
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { getTunnelStatus, getTailscaleStatus } from "@/lib/tunnel/tunnelManager";
|
||||
import { getDownloadStatus } from "@/lib/tunnel/cloudflared";
|
||||
import { getTunnelStatus, getTailscaleStatus, getDownloadStatus } from "@/lib/tunnel";
|
||||
|
||||
export async function GET() {
|
||||
try {
|
||||
|
||||
@@ -2,7 +2,7 @@ import os from "os";
|
||||
import { exec } from "child_process";
|
||||
import { promisify } from "util";
|
||||
import { NextResponse } from "next/server";
|
||||
import { isTailscaleInstalled, isTailscaleLoggedIn, TAILSCALE_SOCKET } from "@/lib/tunnel/tailscale";
|
||||
import { isTailscaleInstalled, isTailscaleLoggedIn, TAILSCALE_SOCKET } from "@/lib/tunnel";
|
||||
import { getCachedPassword, loadEncryptedPassword } from "@/mitm/manager";
|
||||
|
||||
const execAsync = promisify(exec);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { disableTailscale } from "@/lib/tunnel/tunnelManager";
|
||||
import { disableTailscale } from "@/lib/tunnel";
|
||||
|
||||
export async function POST() {
|
||||
try {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { enableTailscale } from "@/lib/tunnel/tunnelManager";
|
||||
import { enableTailscale } from "@/lib/tunnel";
|
||||
|
||||
export async function POST() {
|
||||
try {
|
||||
|
||||
@@ -2,10 +2,9 @@
|
||||
|
||||
import os from "os";
|
||||
import { execSync } from "child_process";
|
||||
import { installTailscale } from "@/lib/tunnel/tailscale";
|
||||
import { installTailscale, loadState, generateShortId } from "@/lib/tunnel";
|
||||
import { getCachedPassword, loadEncryptedPassword, initDbHooks } from "@/mitm/manager";
|
||||
import { getSettings, updateSettings } from "@/lib/localDb";
|
||||
import { loadState, generateShortId } from "@/lib/tunnel/state.js";
|
||||
|
||||
initDbHooks(getSettings, updateSettings);
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { startLogin } from "@/lib/tunnel/tailscale";
|
||||
import { loadState, generateShortId } from "@/lib/tunnel/state.js";
|
||||
|
||||
export async function POST() {
|
||||
try {
|
||||
const shortId = loadState()?.shortId || generateShortId();
|
||||
const result = await startLogin(shortId);
|
||||
return NextResponse.json(result);
|
||||
} catch (error) {
|
||||
console.error("Tailscale login error:", error);
|
||||
return NextResponse.json({ error: error.message }, { status: 500 });
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
"use server";
|
||||
|
||||
import { NextResponse } from "next/server";
|
||||
import { startDaemonWithPassword } from "@/lib/tunnel/tailscale";
|
||||
import { getCachedPassword, loadEncryptedPassword, initDbHooks } from "@/mitm/manager";
|
||||
import { getSettings, updateSettings } from "@/lib/localDb";
|
||||
|
||||
initDbHooks(getSettings, updateSettings);
|
||||
|
||||
export async function POST(request) {
|
||||
try {
|
||||
const body = await request.json().catch(() => ({}));
|
||||
// Use provided password, or fall back to cached/stored MITM password
|
||||
const password = body.sudoPassword || getCachedPassword() || await loadEncryptedPassword() || "";
|
||||
await startDaemonWithPassword(password);
|
||||
return NextResponse.json({ success: true });
|
||||
} catch (error) {
|
||||
console.error("Tailscale start daemon error:", error);
|
||||
return NextResponse.json({ error: error.message }, { status: 500 });
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import "material-symbols/outlined.css";
|
||||
import "./globals.css";
|
||||
import { ThemeProvider } from "@/shared/components/ThemeProvider";
|
||||
import "@/lib/network/initOutboundProxy"; // Auto-initialize outbound proxy env
|
||||
import "@/shared/services/bootstrap"; // Auto-run initializeApp (watchdog, auto-resume tunnel)
|
||||
import { initConsoleLogCapture } from "@/lib/consoleLogBuffer";
|
||||
import { RuntimeI18nProvider } from "@/i18n/RuntimeI18nProvider";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user