From f5989f317f06e07b75b8054e54b6c58126f8bbcc Mon Sep 17 00:00:00 2001 From: Will Norris Date: Mon, 4 Dec 2023 11:58:14 -0800 Subject: [PATCH] client/web: handle offline exit nodes If the currently selected exit node is offline, render the exit node selector in red with an error message. Update exit nodes in the dropdown to indicate if they are offline, and don't allow them to be selected. This also updates some older color values to use the new colors. Updates #10261 Signed-off-by: Will Norris --- .../web/src/components/exit-node-selector.tsx | 146 +++++++++++------- client/web/src/hooks/exit-nodes.ts | 4 +- client/web/web.go | 1 + 3 files changed, 90 insertions(+), 61 deletions(-) diff --git a/client/web/src/components/exit-node-selector.tsx b/client/web/src/components/exit-node-selector.tsx index a2d041ecf..0f47ffae4 100644 --- a/client/web/src/components/exit-node-selector.tsx +++ b/client/web/src/components/exit-node-selector.tsx @@ -46,11 +46,13 @@ export default function ExitNodeSelector({ none, // not using exit nodes advertising, // advertising as exit node using, // using another exit node + offline, // selected exit node node is offline ] = useMemo( () => [ selected.ID === noExitNode.ID, selected.ID === runAsExitNode.ID, selected.ID !== noExitNode.ID && selected.ID !== runAsExitNode.ID, + !selected.Online, ], [selected] ) @@ -74,74 +76,91 @@ export default function ExitNodeSelector({ >
- - {!disabled && (advertising || using) && ( + {!disabled && (advertising || using) && ( + + )} +
+ {offline && ( +

+ The selected exit node is currently offline. Your internet traffic + is blocked until you disable the exit node or select a different + one. +

)} @@ -254,10 +273,16 @@ function ExitNodeSelectorItem({ return ( ) } diff --git a/client/web/src/hooks/exit-nodes.ts b/client/web/src/hooks/exit-nodes.ts index 298de79e3..f9013dced 100644 --- a/client/web/src/hooks/exit-nodes.ts +++ b/client/web/src/hooks/exit-nodes.ts @@ -222,8 +222,10 @@ export function trimDNSSuffix(s: string, tailnetDNSName: string): string { return s } -export const noExitNode: ExitNode = { ID: "NONE", Name: "None" } +// Neither of these are really "online", but setting this makes them selectable. +export const noExitNode: ExitNode = { ID: "NONE", Name: "None", Online: true } export const runAsExitNode: ExitNode = { ID: "RUNNING", Name: "Run as exit nodeā€¦", + Online: true, } diff --git a/client/web/web.go b/client/web/web.go index 49e4ff38b..767d08794 100644 --- a/client/web/web.go +++ b/client/web/web.go @@ -738,6 +738,7 @@ func (s *Server) serveGetExitNodes(w http.ResponseWriter, r *http.Request) { ID: ps.ID, Name: ps.DNSName, Location: ps.Location, + Online: ps.Online, }) } writeJSON(w, exitNodes)