Compare commits
12 Commits
2981b2be2b
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| cec15bb57b | |||
| 8fff196bcb | |||
| 0c08c4024c | |||
| d36b14852f | |||
| 0682972459 | |||
| 9a4b32b374 | |||
| 9ad57a408f | |||
| 78c00d7af6 | |||
| a5a2838448 | |||
| 16efb43bec | |||
| 4824621d9c | |||
| 72108b1d3f |
60
app/api/session/[...params]/route.ts
Normal file
60
app/api/session/[...params]/route.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
import { auth } from "@/lib/auth";
|
||||
import { headers } from "next/headers"
|
||||
import { NextRequest } from "next/server";
|
||||
|
||||
export async function PATCH(req: NextRequest, context: { params: Promise<{ params: string[] }> }) {
|
||||
const { params } = await context.params;
|
||||
const requestHeaders = await headers();
|
||||
const result = await auth.api.getToken({ headers: requestHeaders }).catch(() => null);
|
||||
if (!result || typeof result !== "object" || !("token" in result)) {
|
||||
return new Response("Unauthorized", { status: 401 });
|
||||
}
|
||||
|
||||
const { token } = result as { token: string };
|
||||
if (!token) {
|
||||
return new Response("Unauthorized", { status: 401 });
|
||||
}
|
||||
|
||||
const data = await fetch(`${process.env.API_URL}/api/session/${params.join("/")}`, {
|
||||
method: "PATCH",
|
||||
headers: {
|
||||
authorization: `Bearer ${token}`,
|
||||
},
|
||||
cache: "no-store",
|
||||
body: await req.text(),
|
||||
})
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function DELETE(req: NextRequest, context: { params: Promise<{ params: string[] }> }) {
|
||||
const { params } = await context.params;
|
||||
if (!params || params.length < 3) {
|
||||
return new Response("Bad Request", { status: 400 });
|
||||
}
|
||||
const node = params[0]
|
||||
const tunnelType = params[1]
|
||||
const slug = params[2]
|
||||
|
||||
const requestHeaders = await headers();
|
||||
const result = await auth.api.getToken({ headers: requestHeaders }).catch(() => null);
|
||||
if (!result || typeof result !== "object" || !("token" in result)) {
|
||||
return new Response("Unauthorized", { status: 401 });
|
||||
}
|
||||
|
||||
const { token } = result as { token: string };
|
||||
if (!token) {
|
||||
return new Response("Unauthorized", { status: 401 });
|
||||
}
|
||||
|
||||
const data = await fetch(`${process.env.API_URL}/api/session/${node}/${tunnelType}/${slug}`, {
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
authorization: `Bearer ${token}`,
|
||||
},
|
||||
cache: "no-store",
|
||||
body: await req.text(),
|
||||
})
|
||||
|
||||
return data;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client"
|
||||
|
||||
import { useEffect, useState } from "react"
|
||||
import { useEffect, useState, type FormEvent } from "react"
|
||||
import Link from "next/link"
|
||||
import { useRouter } from "next/navigation"
|
||||
import TunnelConfig, { type TunnelConfig as TunnelConfigType, type Server } from "@/components/tunnel-config"
|
||||
@@ -12,6 +12,8 @@ const defaultConfig: TunnelConfigType = {
|
||||
localPort: 8000,
|
||||
}
|
||||
|
||||
const STOP_CONFIRMATION_TEXT = "YEAH SURE BUDDY"
|
||||
|
||||
const formatStartedAgo = (timestamp?: ApiTimestamp): string | undefined => {
|
||||
if (!timestamp) return undefined
|
||||
const startedMs = timestamp.seconds * 1000 + Math.floor(timestamp.nanos / 1_000_000)
|
||||
@@ -32,13 +34,13 @@ const toActiveConnection = (session: ApiSession): ActiveConnection => {
|
||||
return {
|
||||
id: session.slug || `${session.node}-${session.started_at?.seconds ?? Date.now()}`,
|
||||
name: session.slug || session.node || "Unknown tunnel",
|
||||
slug: session.slug,
|
||||
status: session.active ? "connected" : "error",
|
||||
protocol: (session.forwarding_type || "http").toLowerCase(),
|
||||
serverLabel: session.node || "Unknown node",
|
||||
node: session.node,
|
||||
remote: session.slug ? `${session.slug}.${session.node}` : session.node || "—",
|
||||
startedAgo,
|
||||
latencyMs: null,
|
||||
dataInOut: undefined,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,15 +71,15 @@ type ActiveConnectionStatus = "connected" | "pending" | "error"
|
||||
type ActiveConnection = {
|
||||
id: string
|
||||
name: string
|
||||
slug?: string
|
||||
status: ActiveConnectionStatus
|
||||
protocol: string
|
||||
serverLabel: string
|
||||
node?: string
|
||||
remote: string
|
||||
localPort?: number
|
||||
serverPort?: number
|
||||
startedAgo?: string
|
||||
latencyMs?: number | null
|
||||
dataInOut?: string
|
||||
}
|
||||
|
||||
export default function DashboardClient({ initialActiveConnections }: DashboardClientProps) {
|
||||
@@ -90,6 +92,25 @@ export default function DashboardClient({ initialActiveConnections }: DashboardC
|
||||
)
|
||||
const { data: cachedSession } = authClient.useSession()
|
||||
const [session, setSession] = useState<SessionResponse["data"] | null>(cachedSession ?? null)
|
||||
const [openActionId, setOpenActionId] = useState<string | null>(null)
|
||||
const [stopModal, setStopModal] = useState<{
|
||||
connectionId: string
|
||||
node?: string
|
||||
slug?: string
|
||||
protocol?: string
|
||||
name: string
|
||||
} | null>(null)
|
||||
const [stopModalInput, setStopModalInput] = useState("")
|
||||
const [stopSaving, setStopSaving] = useState(false)
|
||||
const [stopError, setStopError] = useState<string | null>(null)
|
||||
const [slugModal, setSlugModal] = useState<{
|
||||
connectionId: string
|
||||
currentSlug: string
|
||||
newSlug: string
|
||||
node: string
|
||||
} | null>(null)
|
||||
const [slugError, setSlugError] = useState<string | null>(null)
|
||||
const [slugSaving, setSlugSaving] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
setActiveConnections(initialActiveConnections.map(toActiveConnection))
|
||||
@@ -101,133 +122,435 @@ export default function DashboardClient({ initialActiveConnections }: DashboardC
|
||||
}
|
||||
}, [cachedSession, session])
|
||||
|
||||
const stopConnection = (id: string) => {
|
||||
setActiveConnections((prev) => prev.filter((conn) => conn.id !== id))
|
||||
setStatusMessage("Connection stopped")
|
||||
const openStopModal = (connection: ActiveConnection) => {
|
||||
setStopModal({
|
||||
connectionId: connection.id,
|
||||
node: connection.node || connection.serverLabel,
|
||||
slug: connection.slug || connection.name,
|
||||
protocol: connection.protocol,
|
||||
name: connection.name,
|
||||
})
|
||||
setStopModalInput("")
|
||||
setStopError(null)
|
||||
setOpenActionId(null)
|
||||
}
|
||||
|
||||
return (
|
||||
<main className="flex-1">
|
||||
<div className="max-w-7xl mx-auto px-4 py-8 space-y-6">
|
||||
<div className="flex flex-col gap-1">
|
||||
<h1 className="text-2xl font-semibold">Active Forwarding</h1>
|
||||
<p className="text-sm text-gray-400">Live tunnels for this session.</p>
|
||||
</div>
|
||||
const closeStopModal = () => {
|
||||
setStopModal(null)
|
||||
setStopModalInput("")
|
||||
setStopSaving(false)
|
||||
setStopError(null)
|
||||
}
|
||||
|
||||
{statusMessage && (
|
||||
<div className="rounded-lg border border-emerald-700 bg-emerald-900/40 px-4 py-3 text-sm text-emerald-200">
|
||||
{statusMessage}
|
||||
</div>
|
||||
)}
|
||||
const stopConnection = async () => {
|
||||
if (!stopModal) return
|
||||
|
||||
<div className="rounded-lg border border-gray-800 bg-gray-900 p-5">
|
||||
<div className="flex items-center justify-between mb-4">
|
||||
<div>
|
||||
<h2 className="text-lg font-semibold">Active Connections</h2>
|
||||
<p className="text-sm text-gray-400">Monitor and manage your running tunnels</p>
|
||||
if (stopModalInput.trim() !== STOP_CONFIRMATION_TEXT) {
|
||||
setStopError("Please type the confirmation phrase exactly.")
|
||||
return
|
||||
}
|
||||
|
||||
const node = stopModal.node
|
||||
const tunnelType = stopModal.protocol?.toLowerCase()
|
||||
const slug = stopModal.slug
|
||||
|
||||
if (!node || !tunnelType || !slug) {
|
||||
setStopError("Missing connection details; cannot stop.")
|
||||
return
|
||||
}
|
||||
|
||||
setStopSaving(true)
|
||||
setStopError(null)
|
||||
setStatusMessage(null)
|
||||
|
||||
try {
|
||||
const endpoint = `/api/session/${encodeURIComponent(node)}/${encodeURIComponent(tunnelType)}/${encodeURIComponent(slug)}`
|
||||
const response = await fetch(endpoint, {
|
||||
method: "DELETE",
|
||||
})
|
||||
|
||||
if (!response.ok) {
|
||||
const message = await response.text()
|
||||
setStopError(message || "Failed to stop connection.")
|
||||
return
|
||||
}
|
||||
|
||||
setActiveConnections((prev) => prev.filter((conn) => conn.id !== stopModal.connectionId))
|
||||
setStatusMessage("Connection stopped")
|
||||
closeStopModal()
|
||||
} catch (error) {
|
||||
console.error("Failed to stop connection", error)
|
||||
setStopError("Failed to stop connection.")
|
||||
} finally {
|
||||
setStopSaving(false)
|
||||
}
|
||||
}
|
||||
|
||||
const openChangeSlugModal = (connection: ActiveConnection) => {
|
||||
setSlugModal({
|
||||
connectionId: connection.id,
|
||||
currentSlug: connection.name,
|
||||
newSlug: connection.name,
|
||||
node: connection.node || connection.serverLabel,
|
||||
})
|
||||
setSlugError(null)
|
||||
setOpenActionId(null)
|
||||
}
|
||||
|
||||
const closeSlugModal = () => setSlugModal(null)
|
||||
|
||||
const validateSlug = (value: string): string | null => {
|
||||
const trimmed = value.trim().toLowerCase()
|
||||
if (trimmed.length < 3 || trimmed.length > 20) return "Slug must be 3-20 characters."
|
||||
if (!/^[a-z0-9-]+$/.test(trimmed)) return "Only lowercase letters, numbers, and hyphens are allowed."
|
||||
if (trimmed.startsWith("-") || trimmed.endsWith("-")) return "No leading or trailing hyphens."
|
||||
return null
|
||||
}
|
||||
|
||||
const submitSlugChange = async (event: FormEvent<HTMLFormElement>) => {
|
||||
event.preventDefault()
|
||||
if (!slugModal) return
|
||||
|
||||
const trimmedSlug = slugModal.newSlug.trim().toLowerCase()
|
||||
const validationError = validateSlug(trimmedSlug)
|
||||
setSlugError(validationError)
|
||||
if (validationError) return
|
||||
|
||||
setSlugSaving(true)
|
||||
setStatusMessage(null)
|
||||
|
||||
try {
|
||||
const response = await fetch(`/api/session/${slugModal.node}`, {
|
||||
method: "PATCH",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({ old: slugModal.currentSlug, new: trimmedSlug }),
|
||||
})
|
||||
|
||||
if (!response.ok) {
|
||||
const message = await response.text()
|
||||
setSlugError(message || "Failed to update slug.")
|
||||
return
|
||||
}
|
||||
|
||||
setActiveConnections((prev) =>
|
||||
prev.map((conn) =>
|
||||
conn.id === slugModal.connectionId
|
||||
? {
|
||||
...conn,
|
||||
name: trimmedSlug,
|
||||
remote: conn.node ? `${trimmedSlug}.${conn.node}` : trimmedSlug,
|
||||
}
|
||||
: conn,
|
||||
),
|
||||
)
|
||||
|
||||
setStatusMessage("Slug updated")
|
||||
setSlugModal(null)
|
||||
} catch (error) {
|
||||
console.error("Failed to update slug", error)
|
||||
setSlugError("Failed to update slug.")
|
||||
} finally {
|
||||
setSlugSaving(false)
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (slugModal || stopModal) {
|
||||
const previousOverflow = document.body.style.overflow
|
||||
document.body.style.overflow = "hidden"
|
||||
return () => {
|
||||
document.body.style.overflow = previousOverflow
|
||||
}
|
||||
}
|
||||
}, [slugModal, stopModal])
|
||||
|
||||
useEffect(() => {
|
||||
const closeOnEscape = (event: KeyboardEvent) => {
|
||||
if (event.key === "Escape") {
|
||||
setOpenActionId(null)
|
||||
setSlugModal(null)
|
||||
setStopModal(null)
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener("keydown", closeOnEscape)
|
||||
return () => window.removeEventListener("keydown", closeOnEscape)
|
||||
}, [])
|
||||
|
||||
const stopModalContent = !stopModal
|
||||
? null
|
||||
: (
|
||||
<div className="fixed inset-0 z-30 flex items-center justify-center bg-black/60 px-4">
|
||||
<div className="w-full max-w-md rounded-lg border border-gray-800 bg-gray-900 p-6 shadow-xl">
|
||||
<div className="flex items-start justify-between gap-4 mb-6">
|
||||
<div className="flex items-start gap-3">
|
||||
<div className="flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-red-500/10 ring-1 ring-red-500/20">
|
||||
<svg className="h-5 w-5 text-red-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" />
|
||||
</svg>
|
||||
</div>
|
||||
<div>
|
||||
<h3 className="text-lg font-semibold text-white">Stop connection</h3>
|
||||
<p className="mt-1 text-sm text-gray-400 leading-relaxed">
|
||||
Type <span className="font-mono text-xs text-red-300 bg-red-950/50 px-1.5 py-0.5 rounded">{STOP_CONFIRMATION_TEXT}</span> to stop <span className="font-medium text-gray-300">{stopModal.slug || stopModal.name}</span> on {stopModal.node || "this node"}.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => router.refresh()}
|
||||
className="text-sm text-emerald-400 hover:text-emerald-300"
|
||||
onClick={closeStopModal}
|
||||
className="flex h-8 w-8 items-center justify-center rounded-lg text-gray-400 transition-colors hover:bg-gray-800 hover:text-gray-200"
|
||||
aria-label="Close modal"
|
||||
>
|
||||
Refresh
|
||||
<svg className="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{activeConnections.length === 0 ? (
|
||||
<div className="rounded-lg border border-dashed border-gray-700 bg-gray-800/60 p-6 text-center text-gray-400">
|
||||
No active connections yet. Configure a tunnel to see it here.
|
||||
<div className="mt-4 space-y-4">
|
||||
<label className="block text-sm text-gray-300">
|
||||
Confirmation phrase
|
||||
<input
|
||||
type="text"
|
||||
value={stopModalInput}
|
||||
onChange={(e) => {
|
||||
setStopModalInput(e.target.value)
|
||||
if (stopError) setStopError(null)
|
||||
}}
|
||||
placeholder={STOP_CONFIRMATION_TEXT}
|
||||
className="mt-2 w-full rounded-md border border-gray-700 bg-gray-800 px-3 py-2 text-white focus:border-emerald-500 focus:outline-none"
|
||||
/>
|
||||
</label>
|
||||
{stopError && <p className="text-sm text-red-400">{stopError}</p>}
|
||||
<div className="flex items-center justify-end gap-3">
|
||||
<button
|
||||
type="button"
|
||||
onClick={closeStopModal}
|
||||
className="rounded-md px-4 py-2 text-sm font-medium bg-gray-700 text-gray-200 border border-gray-700 hover:bg-gray-600 hover:border-gray-500"
|
||||
disabled={stopSaving}
|
||||
>
|
||||
Cancel
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={stopConnection}
|
||||
disabled={stopModalInput.trim() !== STOP_CONFIRMATION_TEXT || stopSaving}
|
||||
className={`rounded-md px-4 py-2 text-sm font-medium text-white${stopModalInput.trim() === STOP_CONFIRMATION_TEXT && !stopSaving ? 'bg-red-600 hover:bg-red-700 border border-gray-500' : 'bg-red-900 hover:text-white-300 cursor-not-allowed border border-gray-700'}`}>
|
||||
{stopSaving ? "Stopping..." : "Confirm stop"}
|
||||
</button>
|
||||
</div>
|
||||
) : (
|
||||
<div className="space-y-3">
|
||||
{activeConnections.map((connection) => {
|
||||
const metaParts: string[] = []
|
||||
if (connection.localPort && connection.serverPort) {
|
||||
metaParts.push(`Local ${connection.localPort} → Server ${connection.serverPort}`)
|
||||
}
|
||||
if (connection.startedAgo) {
|
||||
metaParts.push(connection.startedAgo)
|
||||
}
|
||||
const metaText = metaParts.length > 0 ? metaParts.join(" · ") : "No session metadata yet"
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
return (
|
||||
<div
|
||||
key={connection.id}
|
||||
className="rounded-lg border border-gray-800 bg-gray-800/60 p-4 flex flex-col gap-3 md:flex-row md:items-center md:justify-between"
|
||||
>
|
||||
<div className="space-y-1">
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-white font-medium">{connection.name}</span>
|
||||
<span
|
||||
className={`rounded-full px-2 py-0.5 text-xs font-semibold ${
|
||||
connection.status === "connected"
|
||||
const slugModalContent = !slugModal
|
||||
? null
|
||||
: (
|
||||
<div className="fixed inset-0 z-20 flex items-center justify-center bg-black/60 px-4">
|
||||
<div className="w-full max-w-md rounded-lg border border-gray-800 bg-gray-900 p-6 shadow-xl">
|
||||
<div className="flex items-start justify-between gap-4">
|
||||
<div>
|
||||
<h3 className="text-lg font-semibold text-white">Change slug</h3>
|
||||
<p className="text-sm text-gray-400">Update the identifier for this tunnel.</p>
|
||||
</div>
|
||||
<button
|
||||
onClick={closeSlugModal}
|
||||
className="text-gray-400 hover:text-gray-200"
|
||||
aria-label="Close modal"
|
||||
>
|
||||
×
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<form onSubmit={submitSlugChange} className="mt-4 space-y-4">
|
||||
<label className="block text-sm text-gray-300">
|
||||
New slug
|
||||
<input
|
||||
type="text"
|
||||
value={slugModal.newSlug}
|
||||
onChange={(e) => {
|
||||
const nextValue = e.target.value.toLowerCase()
|
||||
setSlugModal((prev) => (prev ? { ...prev, newSlug: nextValue } : prev))
|
||||
setSlugError(validateSlug(nextValue))
|
||||
}}
|
||||
className="mt-2 w-full rounded-md border border-gray-700 bg-gray-800 px-3 py-2 text-white focus:border-emerald-500 focus:outline-none"
|
||||
placeholder={slugModal.currentSlug}
|
||||
/>
|
||||
{slugError && <p className="mt-2 text-sm text-red-400">{slugError}</p>}
|
||||
</label>
|
||||
|
||||
<div className="flex items-center justify-end gap-3">
|
||||
<button
|
||||
type="button"
|
||||
onClick={closeSlugModal}
|
||||
className="rounded-md border border-gray-700 px-4 py-2 text-sm text-gray-200 hover:border-gray-500"
|
||||
>
|
||||
Cancel
|
||||
</button>
|
||||
<button
|
||||
type="submit"
|
||||
disabled={Boolean(slugError) || slugSaving}
|
||||
className="rounded-md bg-emerald-600 px-4 py-2 text-sm font-medium text-white hover:bg-emerald-500 disabled:cursor-not-allowed disabled:opacity-60"
|
||||
>
|
||||
{slugSaving ? "Saving..." : "Save slug"}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
return (
|
||||
<>
|
||||
<main className="flex-1">
|
||||
<div className="max-w-7xl mx-auto px-4 py-8 space-y-6">
|
||||
<div className="flex flex-col gap-1">
|
||||
<h1 className="text-2xl font-semibold">Active Forwarding</h1>
|
||||
<p className="text-sm text-gray-400">Live tunnels for this session.</p>
|
||||
</div>
|
||||
|
||||
{statusMessage && (
|
||||
<div className="rounded-lg border border-emerald-700 bg-emerald-900/40 px-4 py-3 text-sm text-emerald-200">
|
||||
{statusMessage}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="rounded-lg border border-gray-800 bg-gray-900 p-5">
|
||||
<div className="flex items-center justify-between mb-4">
|
||||
<div>
|
||||
<h2 className="text-lg font-semibold">Active Connections</h2>
|
||||
<p className="text-sm text-gray-400">Monitor and manage your running tunnels</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => router.refresh()}
|
||||
className="text-sm text-emerald-400 hover:text-emerald-300"
|
||||
>
|
||||
Refresh
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{activeConnections.length === 0 ? (
|
||||
<div className="rounded-lg border border-dashed border-gray-700 bg-gray-800/60 p-6 text-center text-gray-400">
|
||||
No active connections yet. Configure a tunnel to see it here.
|
||||
</div>
|
||||
) : (
|
||||
<div className="space-y-3">
|
||||
{activeConnections.map((connection) => {
|
||||
const metaParts: string[] = []
|
||||
if (connection.localPort && connection.serverPort) {
|
||||
metaParts.push(`Local ${connection.localPort} → Server ${connection.serverPort}`)
|
||||
}
|
||||
if (connection.startedAgo) {
|
||||
metaParts.push(connection.startedAgo)
|
||||
}
|
||||
const metaText = metaParts.length > 0 ? metaParts.join(" · ") : "No session metadata yet"
|
||||
|
||||
return (
|
||||
<div
|
||||
key={connection.id}
|
||||
className="rounded-lg border border-gray-800 bg-gray-800/60 p-4 flex flex-col gap-3 md:flex-row md:items-center md:justify-between"
|
||||
>
|
||||
<div className="space-y-1">
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-white font-medium">{connection.name}</span>
|
||||
<span
|
||||
className={`rounded-full px-2 py-0.5 text-xs font-semibold ${connection.status === "connected"
|
||||
? "bg-emerald-900/60 text-emerald-300 border border-emerald-700"
|
||||
: connection.status === "pending"
|
||||
? "bg-yellow-900/60 text-yellow-300 border border-yellow-700"
|
||||
: "bg-red-900/60 text-red-300 border border-red-700"
|
||||
}`}
|
||||
>
|
||||
{connection.status === "connected"
|
||||
? "Connected"
|
||||
: connection.status === "pending"
|
||||
? "Reconnecting"
|
||||
: "Error"}
|
||||
</span>
|
||||
</div>
|
||||
<p className="text-sm text-gray-300">
|
||||
{(connection.protocol || "http").toUpperCase()} · {connection.serverLabel}
|
||||
</p>
|
||||
<p className="text-xs text-gray-400">{connection.remote || "—"}</p>
|
||||
<p className="text-xs text-gray-500">{metaText}</p>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-wrap items-center gap-3 md:justify-end">
|
||||
<div className="text-right">
|
||||
<p className="text-sm text-gray-300">Latency</p>
|
||||
<p className="text-lg font-semibold text-white">
|
||||
{connection.latencyMs != null ? `${connection.latencyMs}ms` : "—"}
|
||||
}`}
|
||||
>
|
||||
{connection.status === "connected"
|
||||
? "Connected"
|
||||
: connection.status === "pending"
|
||||
? "Reconnecting"
|
||||
: "Error"}
|
||||
</span>
|
||||
</div>
|
||||
<p className="text-sm text-gray-300">
|
||||
{(connection.protocol || "http").toUpperCase()} · {connection.serverLabel}
|
||||
</p>
|
||||
</div>
|
||||
<div className="text-right">
|
||||
<p className="text-sm text-gray-300">Data</p>
|
||||
<p className="text-lg font-semibold text-white">{connection.dataInOut || "—"}</p>
|
||||
</div>
|
||||
<button
|
||||
onClick={() => stopConnection(connection.id)}
|
||||
className="rounded-lg border border-gray-700 px-3 py-2 text-sm text-gray-200 hover:border-red-500 hover:text-red-200 transition"
|
||||
>
|
||||
Stop
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{(() => {
|
||||
const isTcp = connection.protocol === "tcp"
|
||||
const isHttp = connection.protocol === "http" || connection.protocol === "https"
|
||||
const httpRemote = connection.remote ? `https://${connection.remote}` : "—"
|
||||
const tcpRemote =
|
||||
connection.node && connection.name
|
||||
? `tcp://${connection.node}:${connection.name}`
|
||||
: connection.remote || "—"
|
||||
|
||||
<div className="rounded-lg border border-gray-800 bg-gray-900 p-5">
|
||||
<div className="flex flex-col gap-2 mb-4 sm:flex-row sm:items-center sm:justify-between">
|
||||
<div>
|
||||
<h2 className="text-lg font-semibold">Custom Tunnel Configuration</h2>
|
||||
<p className="text-sm text-gray-400">Pick a location, test latency, and shape your tunnel exactly how you need.</p>
|
||||
</div>
|
||||
<Link href="/tunnel-not-found" className="text-sm text-emerald-400 hover:text-emerald-300">
|
||||
View docs
|
||||
</Link>
|
||||
const displayRemote = isTcp ? tcpRemote : isHttp ? httpRemote : connection.remote || "—"
|
||||
|
||||
return <p className="text-xs text-gray-400">{displayRemote}</p>
|
||||
})()}
|
||||
<p className="text-xs text-gray-500">{metaText}</p>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-wrap items-center gap-3 md:justify-end relative">
|
||||
<button
|
||||
onClick={() =>
|
||||
setOpenActionId((current) => (current === connection.id ? null : connection.id))
|
||||
}
|
||||
className="rounded-lg border border-gray-700 px-3 py-2 text-sm text-gray-200 hover:border-gray-500 transition"
|
||||
>
|
||||
Actions
|
||||
</button>
|
||||
|
||||
{openActionId === connection.id && (
|
||||
<div className="absolute right-0 top-12 z-10 w-44 rounded-md border border-gray-700 bg-gray-800 shadow-lg">
|
||||
<button
|
||||
className="w-full px-3 py-2 text-left text-sm text-gray-200 hover:bg-gray-700"
|
||||
onClick={() => openStopModal(connection)}
|
||||
>
|
||||
Stop connection
|
||||
</button>
|
||||
{connection.protocol !== "tcp" && (
|
||||
<button
|
||||
className="w-full px-3 py-2 text-left text-sm text-gray-200 hover:bg-gray-700"
|
||||
onClick={() => openChangeSlugModal(connection)}
|
||||
>
|
||||
Change slug
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<TunnelConfig
|
||||
config={tunnelConfig}
|
||||
onConfigChange={setTunnelConfig}
|
||||
selectedServer={selectedServer}
|
||||
onServerSelect={setSelectedServer}
|
||||
isAuthenticated={Boolean(session)}
|
||||
userId={session?.user?.sshIdentifier}
|
||||
/>
|
||||
<div className="rounded-lg border border-gray-800 bg-gray-900 p-5">
|
||||
<div className="flex flex-col gap-2 mb-4 sm:flex-row sm:items-center sm:justify-between">
|
||||
<div>
|
||||
<h2 className="text-lg font-semibold">Custom Tunnel Configuration</h2>
|
||||
<p className="text-sm text-gray-400">Pick a location, test latency, and shape your tunnel exactly how you need.</p>
|
||||
</div>
|
||||
<Link href="/tunnel-not-found" className="text-sm text-emerald-400 hover:text-emerald-300">
|
||||
View docs
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<TunnelConfig
|
||||
config={tunnelConfig}
|
||||
onConfigChange={setTunnelConfig}
|
||||
selectedServer={selectedServer}
|
||||
onServerSelect={setSelectedServer}
|
||||
isAuthenticated={Boolean(session)}
|
||||
userId={session?.user?.sshIdentifier}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</main>
|
||||
{stopModalContent}
|
||||
{slugModalContent}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
111
package-lock.json
generated
111
package-lock.json
generated
@@ -43,16 +43,48 @@
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/@better-auth/core": {
|
||||
"version": "1.4.11",
|
||||
"resolved": "https://registry.npmjs.org/@better-auth/core/-/core-1.4.11.tgz",
|
||||
"integrity": "sha512-BYKiYx5GVp5a4rIZXRJwCsDhpSRXd1mfcPn4AKXeuLhcKrurs4uWWN5iBFq+tJ2eNgAcs0WV5pFm/uoz0oFdQQ==",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@standard-schema/spec": "^1.0.0",
|
||||
"zod": "^4.1.12"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@better-auth/utils": "0.3.0",
|
||||
"@better-fetch/fetch": "1.1.21",
|
||||
"better-call": "1.1.7",
|
||||
"jose": "^6.1.0",
|
||||
"kysely": "^0.28.5",
|
||||
"nanostores": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@better-auth/telemetry": {
|
||||
"version": "1.4.11",
|
||||
"resolved": "https://registry.npmjs.org/@better-auth/telemetry/-/telemetry-1.4.11.tgz",
|
||||
"integrity": "sha512-PUtmnBZ7QQpuQUmwMf8pQBUGKEutUC9s5TsJAhoR69crAqWHKZCfR48iN+/4C5JMs2mpO75Ygsi6h9yJ/UqAIg==",
|
||||
"dependencies": {
|
||||
"@better-auth/utils": "0.3.0",
|
||||
"@better-fetch/fetch": "1.1.21"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@better-auth/core": "1.4.11"
|
||||
}
|
||||
},
|
||||
"node_modules/@better-auth/utils": {
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@better-auth/utils/-/utils-0.3.0.tgz",
|
||||
"integrity": "sha512-W+Adw6ZA6mgvnSnhOki270rwJ42t4XzSK6YWGF//BbVXL6SwCLWfyzBc1lN2m/4RM28KubdBKQ4X5VMoLRNPQw==",
|
||||
"license": "MIT"
|
||||
"license": "MIT",
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/@better-fetch/fetch": {
|
||||
"version": "1.1.21",
|
||||
"resolved": "https://registry.npmjs.org/@better-fetch/fetch/-/fetch-1.1.21.tgz",
|
||||
"integrity": "sha512-/ImESw0sskqlVR94jB+5+Pxjf+xBwDZF/N5+y2/q4EqD7IARUTSpPfIo8uf39SYpCxyOCtbyYpUrZ3F/k0zT4A=="
|
||||
"integrity": "sha512-/ImESw0sskqlVR94jB+5+Pxjf+xBwDZF/N5+y2/q4EqD7IARUTSpPfIo8uf39SYpCxyOCtbyYpUrZ3F/k0zT4A==",
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/@drizzle-team/brocli": {
|
||||
"version": "0.10.2",
|
||||
@@ -1994,9 +2026,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "24.10.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.10.4.tgz",
|
||||
"integrity": "sha512-vnDVpYPMzs4wunl27jHrfmwojOGKya0xyM3sH+UE5iv5uPS6vX7UIoh6m+vQc5LGBq52HBKPIn/zcSZVzeDEZg==",
|
||||
"version": "24.10.7",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.10.7.tgz",
|
||||
"integrity": "sha512-+054pVMzVTmRQV8BhpGv3UyfZ2Llgl8rdpDTon+cUH9+na0ncBVXj3wTUKh14+Kiz18ziM3b4ikpP5/Pc0rQEQ==",
|
||||
"devOptional": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -2009,6 +2041,7 @@
|
||||
"integrity": "sha512-RmhMd/wD+CF8Dfo+cVIy3RR5cl8CyfXQ0tGgW6XBL8L4LM/UTEbNXYRbLwU6w+CgrKBNbrQWt4FUtTfaU5jSYQ==",
|
||||
"devOptional": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@types/node": "*",
|
||||
"pg-protocol": "*",
|
||||
@@ -2016,9 +2049,12 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@types/react": {
|
||||
"version": "19.2.7",
|
||||
"version": "19.2.8",
|
||||
"resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.8.tgz",
|
||||
"integrity": "sha512-3MbSL37jEchWZz2p2mjntRZtPt837ij10ApxKfgmXCTuHWagYg7iA5bqPw6C8BMPfwidlvfPI/fxOc42HLhcyg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"csstype": "^3.2.2"
|
||||
}
|
||||
@@ -2052,13 +2088,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/better-auth": {
|
||||
"version": "1.4.10",
|
||||
"resolved": "https://registry.npmjs.org/better-auth/-/better-auth-1.4.10.tgz",
|
||||
"integrity": "sha512-0kqwEBJLe8eyFzbUspRG/htOriCf9uMLlnpe34dlIJGdmDfPuQISd4shShvUrvIVhPxsY1dSTXdXPLpqISYOYg==",
|
||||
"version": "1.4.11",
|
||||
"resolved": "https://registry.npmjs.org/better-auth/-/better-auth-1.4.11.tgz",
|
||||
"integrity": "sha512-UvBokjRrLK+6mFvmZVhXEDe+ghqdR60DwfRvdth6R2cNnFn/VAGL6WcLVwEKBYjBplNMdslR62vOhUM+CSN0ww==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@better-auth/core": "1.4.10",
|
||||
"@better-auth/telemetry": "1.4.10",
|
||||
"@better-auth/core": "1.4.11",
|
||||
"@better-auth/telemetry": "1.4.11",
|
||||
"@better-auth/utils": "0.3.0",
|
||||
"@better-fetch/fetch": "1.1.21",
|
||||
"@noble/ciphers": "^2.0.0",
|
||||
@@ -2147,40 +2183,12 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/better-auth/node_modules/@better-auth/core": {
|
||||
"version": "1.4.10",
|
||||
"resolved": "https://registry.npmjs.org/@better-auth/core/-/core-1.4.10.tgz",
|
||||
"integrity": "sha512-AThrfb6CpG80wqkanfrbN2/fGOYzhGladHFf3JhaWt/3/Vtf4h084T6PJLrDE7M/vCCGYvDI1DkvP3P1OB2HAg==",
|
||||
"dependencies": {
|
||||
"@standard-schema/spec": "^1.0.0",
|
||||
"zod": "^4.1.12"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@better-auth/utils": "0.3.0",
|
||||
"@better-fetch/fetch": "1.1.21",
|
||||
"better-call": "1.1.7",
|
||||
"jose": "^6.1.0",
|
||||
"kysely": "^0.28.5",
|
||||
"nanostores": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/better-auth/node_modules/@better-auth/telemetry": {
|
||||
"version": "1.4.10",
|
||||
"resolved": "https://registry.npmjs.org/@better-auth/telemetry/-/telemetry-1.4.10.tgz",
|
||||
"integrity": "sha512-Dq4XJX6EKsUu0h3jpRagX739p/VMOTcnJYWRrLtDYkqtZFg+sFiFsSWVcfapZoWpRSUGYX9iKwl6nDHn6Ju2oQ==",
|
||||
"dependencies": {
|
||||
"@better-auth/utils": "0.3.0",
|
||||
"@better-fetch/fetch": "1.1.21"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@better-auth/core": "1.4.10"
|
||||
}
|
||||
},
|
||||
"node_modules/better-call": {
|
||||
"version": "1.1.7",
|
||||
"resolved": "https://registry.npmjs.org/better-call/-/better-call-1.1.7.tgz",
|
||||
"integrity": "sha512-6gaJe1bBIEgVebQu/7q9saahVzvBsGaByEnE8aDVncZEDiJO7sdNB28ot9I6iXSbR25egGmmZ6aIURXyQHRraQ==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@better-auth/utils": "^0.3.0",
|
||||
"@better-fetch/fetch": "^1.1.4",
|
||||
@@ -2299,6 +2307,7 @@
|
||||
"node_modules/d3-selection": {
|
||||
"version": "3.0.0",
|
||||
"license": "ISC",
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
@@ -2391,6 +2400,7 @@
|
||||
"integrity": "sha512-O9EC/miwdnRDY10qRxM8P3Pg8hXe3LyU4ZipReKOgTwn4OqANmftj8XJz1UPUAS6NMHf0E2htjsbQujUTkncCg==",
|
||||
"devOptional": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@drizzle-team/brocli": "^0.10.2",
|
||||
"@esbuild-kit/esm-loader": "^2.5.5",
|
||||
@@ -2406,6 +2416,7 @@
|
||||
"resolved": "https://registry.npmjs.org/drizzle-orm/-/drizzle-orm-0.45.1.tgz",
|
||||
"integrity": "sha512-Te0FOdKIistGNPMq2jscdqngBRfBpC8uMFVwqjf6gtTVJHIQ/dosgV/CLBU2N4ZJBsXL5savCba9b0YJskKdcA==",
|
||||
"license": "Apache-2.0",
|
||||
"peer": true,
|
||||
"peerDependencies": {
|
||||
"@aws-sdk/client-rds-data": ">=3",
|
||||
"@cloudflare/workers-types": ">=4",
|
||||
@@ -2545,6 +2556,7 @@
|
||||
"devOptional": true,
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"bin": {
|
||||
"esbuild": "bin/esbuild"
|
||||
},
|
||||
@@ -2646,20 +2658,21 @@
|
||||
"resolved": "https://registry.npmjs.org/jose/-/jose-6.1.3.tgz",
|
||||
"integrity": "sha512-0TpaTfihd4QMNwrz/ob2Bp7X04yuxJkjRGi4aKmOqwhov54i6u79oCv7T+C7lo70MKH6BesI3vscD1yb/yzKXQ==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/panva"
|
||||
}
|
||||
},
|
||||
"node_modules/js-tokens": {
|
||||
"version": "4.0.0",
|
||||
"license": "MIT",
|
||||
"peer": true
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/kysely": {
|
||||
"version": "0.28.9",
|
||||
"resolved": "https://registry.npmjs.org/kysely/-/kysely-0.28.9.tgz",
|
||||
"integrity": "sha512-3BeXMoiOhpOwu62CiVpO6lxfq4eS6KMYfQdMsN/2kUCRNuF2YiEr7u0HLHaQU+O4Xu8YXE3bHVkwaQ85i72EuA==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=20.0.0"
|
||||
}
|
||||
@@ -2924,7 +2937,6 @@
|
||||
"node_modules/loose-envify": {
|
||||
"version": "1.4.0",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"js-tokens": "^3.0.0 || ^4.0.0"
|
||||
},
|
||||
@@ -2974,6 +2986,7 @@
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": "^20.0.0 || >=22.0.0"
|
||||
}
|
||||
@@ -2989,6 +3002,7 @@
|
||||
"resolved": "https://registry.npmjs.org/next/-/next-16.1.1.tgz",
|
||||
"integrity": "sha512-QI+T7xrxt1pF6SQ/JYFz95ro/mg/1Znk5vBebsWwbpejj1T0A23hO7GYEaVac9QUOT2BIMiuzm0L99ooq7k0/w==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@next/env": "16.1.1",
|
||||
"@swc/helpers": "0.5.15",
|
||||
@@ -3068,7 +3082,6 @@
|
||||
"node_modules/object-assign": {
|
||||
"version": "4.1.1",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
@@ -3078,6 +3091,7 @@
|
||||
"resolved": "https://registry.npmjs.org/pg/-/pg-8.16.3.tgz",
|
||||
"integrity": "sha512-enxc1h0jA/aq5oSDMvqyW3q89ra6XIIDZgCX9vkMrnz5DFTw/Ny3Li2lFQ+pt3L6MCgm/5o2o8HW9hiJji+xvw==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"pg-connection-string": "^2.9.1",
|
||||
"pg-pool": "^3.10.1",
|
||||
@@ -3247,6 +3261,7 @@
|
||||
"resolved": "https://registry.npmjs.org/react/-/react-19.2.3.tgz",
|
||||
"integrity": "sha512-Ku/hhYbVjOQnXDZFv2+RibmLFGwFdeeKHFcOTlrt7xplBnya5OGn/hIRDsqDiSUcfORsDC7MPxwork8jBwsIWA==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
@@ -3256,6 +3271,7 @@
|
||||
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.3.tgz",
|
||||
"integrity": "sha512-yELu4WmLPw5Mr/lmeEpox5rw3RETacE++JgHqQzd2dg+YbJuat3jH4ingc+WPZhxaoFzdv9y33G+F7Nl5O0GBg==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"scheduler": "^0.27.0"
|
||||
},
|
||||
@@ -3265,8 +3281,7 @@
|
||||
},
|
||||
"node_modules/react-is": {
|
||||
"version": "16.13.1",
|
||||
"license": "MIT",
|
||||
"peer": true
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/react-simple-maps": {
|
||||
"version": "3.0.0",
|
||||
@@ -3425,7 +3440,8 @@
|
||||
"version": "4.1.18",
|
||||
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.1.18.tgz",
|
||||
"integrity": "sha512-4+Z+0yiYyEtUVCScyfHCxOYP06L5Ne+JiHhY2IjR2KWMIWhJOYZKLSGZaP5HkZ8+bY0cxfzwDE5uOmzFXyIwxw==",
|
||||
"license": "MIT"
|
||||
"license": "MIT",
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/tailwindcss-animate": {
|
||||
"version": "1.0.7",
|
||||
@@ -3999,6 +4015,7 @@
|
||||
"resolved": "https://registry.npmjs.org/zod/-/zod-4.2.1.tgz",
|
||||
"integrity": "sha512-0wZ1IRqGGhMP76gLqz8EyfBXKk0J2qo2+H3fi4mcUP/KtTocoX08nmIAHl1Z2kJIZbZee8KOpBCSNPRgauucjw==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/colinhacks"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user