From 8317dc22468ed25ed469b83b09595204f7aafc7b Mon Sep 17 00:00:00 2001 From: bagas Date: Thu, 1 Jan 2026 23:32:40 +0700 Subject: [PATCH] update: unlock tcp forwarding for non-auth user --- components/tunnel-config.tsx | 113 ++++++++++++++++++++--------------- 1 file changed, 66 insertions(+), 47 deletions(-) diff --git a/components/tunnel-config.tsx b/components/tunnel-config.tsx index c9ef14e..d5ea961 100644 --- a/components/tunnel-config.tsx +++ b/components/tunnel-config.tsx @@ -5,7 +5,7 @@ import { ComposableMap, Geographies, Geography, Marker } from "react-simple-maps import Link from "next/link" export interface TunnelConfig { - type: "http" | "tcp" + type: "http" | "tcp" | "custom-domain" serverPort: number localPort: number } @@ -194,7 +194,7 @@ export default function TunnelConfig({ const [serverError, setServerError] = useState(null) const [portError, setPortError] = useState(null) const [pendingServerSelection, setPendingServerSelection] = useState(null) - const [showTcpLoginPrompt, setShowTcpLoginPrompt] = useState(false) + const [showCustomDomainLoginPrompt, setShowCustomDomainLoginPrompt] = useState(false) useEffect(() => { const loadServers = async () => { @@ -269,7 +269,7 @@ export default function TunnelConfig({ s.ping !== null && s.capabilities.http && ((localConfig.type === "http" && s.capabilities.http) || - (localConfig.type === "tcp" && s.capabilities.tcp && isAuthenticated)), + (localConfig.type === "tcp" && s.capabilities.tcp)), ) if (compatibleServers.length > 0) { @@ -302,7 +302,7 @@ export default function TunnelConfig({ onServerSelect(pendingServerSelection) setPendingServerSelection(null) - if (localConfig.type === "tcp" && (!pendingServerSelection.capabilities.tcp || !isAuthenticated)) { + if (localConfig.type === "tcp" && !pendingServerSelection.capabilities.tcp) { updateConfig({ type: "http", serverPort: 443 }) } } @@ -353,13 +353,18 @@ export default function TunnelConfig({ } const handleTcpSelection = () => { + setShowCustomDomainLoginPrompt(false) + updateConfig({ type: "tcp", serverPort: 0 }) + } + + const handleCustomDomainSelection = () => { if (!isAuthenticated) { - setShowTcpLoginPrompt(true) + setShowCustomDomainLoginPrompt(true) return } - updateConfig({ type: "tcp", serverPort: 0 }) - setShowTcpLoginPrompt(false) + // Navigate to custom domain configuration page + window.location.href = "/custom-domain" } const generateCommand = () => { @@ -507,7 +512,7 @@ export default function TunnelConfig({ if (localConfig.type === "http" && !server.capabilities.http) { return false } - if (localConfig.type === "tcp" && (!server.capabilities.tcp || !isAuthenticated)) { + if (localConfig.type === "tcp" && !server.capabilities.tcp) { return false } @@ -521,9 +526,6 @@ export default function TunnelConfig({ if (localConfig.type === "tcp" && !server.capabilities.tcp) { return "TCP not supported" } - if (localConfig.type === "tcp" && !isAuthenticated) { - return "Sign in required for TCP" - } if (localConfig.type === "http" && !server.capabilities.http) { return "HTTP not supported" } @@ -533,7 +535,7 @@ export default function TunnelConfig({ const getCompatibleServers = () => { return servers.filter((server) => { if (localConfig.type === "http") return server.capabilities.http - if (localConfig.type === "tcp") return server.capabilities.tcp && isAuthenticated + if (localConfig.type === "tcp") return server.capabilities.tcp return true }) } @@ -610,13 +612,10 @@ export default function TunnelConfig({

No servers support {localConfig.type.toUpperCase()} forwarding - {!isAuthenticated && localConfig.type === "tcp" && " for guest users"}

- {!isAuthenticated && localConfig.type === "tcp" - ? "Please sign in to access TCP forwarding or switch to HTTP/HTTPS forwarding." - : "Please switch to HTTP/HTTPS forwarding or wait for TCP-compatible servers to come online."} + Please switch to HTTP/HTTPS forwarding or wait for compatible servers to come online.

)} @@ -799,17 +798,14 @@ export default function TunnelConfig({ HTTP )} {server.capabilities.tcp && ( - - TCP{!isAuthenticated && " 🔒"} + + TCP )} - {server.capabilities.tcp && isAuthenticated && ( + {server.capabilities.tcp && (

{getPortRestrictionInfo(server)}

@@ -864,7 +860,10 @@ export default function TunnelConfig({ name="forwardingType" value="http" checked={localConfig.type === "http"} - onChange={() => updateConfig({ type: "http", serverPort: 443 })} + onChange={() => { + setShowCustomDomainLoginPrompt(false) + updateConfig({ type: "http", serverPort: 443 }) + }} className="sr-only" />
TCP - {!isAuthenticated && hasTcpServers && ( +
+ + +