From 7e71de9c512015706038d525e9c0b78c90ebfaf4 Mon Sep 17 00:00:00 2001 From: Caleb Doxsey Date: Thu, 26 Dec 2024 09:19:07 -0700 Subject: [PATCH 1/2] add udp support --- api.proto | 11 +++++- src/renderer/pages/ConnectForm.tsx | 36 +++++++++++++++++-- src/shared/pb/api.ts | 57 ++++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+), 3 deletions(-) diff --git a/api.proto b/api.proto index 886ddac..1fe4ef2 100644 --- a/api.proto +++ b/api.proto @@ -85,7 +85,8 @@ service Listener { // StatusUpdates opens a stream to listen to connection status updates // a client has to subscribe and continuously // listen to the broadcasted updates - rpc StatusUpdates(StatusUpdatesRequest) returns (stream ConnectionStatusUpdate); + rpc StatusUpdates(StatusUpdatesRequest) + returns (stream ConnectionStatusUpdate); } message ListenerUpdateRequest { @@ -211,10 +212,18 @@ message ClientCertFromStore { optional string subject_filter = 2; } +enum Protocol { + UNKNOWN = 0; + TCP = 1; + UDP = 2; +} + // Connection message Connection { // name is a user friendly connection name that a user may define optional string name = 1; + // the protocol to use for the connection + optional Protocol protocol = 10; // remote_addr is a remote pomerium host:port string remote_addr = 2; // listen_address, if not provided, will assign a random port each time diff --git a/src/renderer/pages/ConnectForm.tsx b/src/renderer/pages/ConnectForm.tsx index 5873b18..e1d9684 100644 --- a/src/renderer/pages/ConnectForm.tsx +++ b/src/renderer/pages/ConnectForm.tsx @@ -8,10 +8,15 @@ import { CardContent, Chip, Container, + FormControl, FormControlLabel, FormHelperText, Grid, IconButton, + InputLabel, + MenuItem, + Select, + SelectChangeEvent, styled, Switch, Typography, @@ -38,6 +43,7 @@ import { formatTag } from '../../shared/validators'; import { ClientCertFromStore, Connection, + Protocol, Record, Selector, } from '../../shared/pb/api'; @@ -115,6 +121,7 @@ interface Props { const initialConnData: Connection = { name: undefined, + protocol: Protocol.TCP, remoteAddr: '', listenAddr: undefined, pomeriumUrl: undefined, @@ -239,7 +246,7 @@ const ConnectForm: FC = () => { useState(false); const saveClientCertFromStore = ( - value: ClientCertFromStore | undefined, + value: ClientCertFromStore | undefined ): void => { setConnection({ ...connection, @@ -265,7 +272,7 @@ const ConnectForm: FC = () => { }; const clientCertFiltersSummary = getClientCertFiltersSummary( - connection?.clientCertFromStore, + connection?.clientCertFromStore ); const saveCertText = (value: string): void => { @@ -310,6 +317,14 @@ const ConnectForm: FC = () => { setShowCertInput(true); }; + const handleChangeProtocol = (evt: SelectChangeEvent) => { + setConnection((oldConnection) => { + oldConnection.protocol = + evt.target.value === 'UDP' ? Protocol.UDP : Protocol.TCP; + return oldConnection; + }); + }; + const saveConnection = (): void => { const record = { tags, @@ -552,6 +567,23 @@ const ConnectForm: FC = () => { helperText="Name of the route." /> + + + Protocol + + + Date: Thu, 26 Dec 2024 09:39:27 -0700 Subject: [PATCH 2/2] fix lint --- package.json | 3 ++- src/renderer/pages/ConnectForm.tsx | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 1d4b316..d200e8d 100644 --- a/package.json +++ b/package.json @@ -311,7 +311,8 @@ } } ], - "singleQuote": true + "singleQuote": true, + "trailingComma": "all" }, "renovate": { "extends": [ diff --git a/src/renderer/pages/ConnectForm.tsx b/src/renderer/pages/ConnectForm.tsx index e1d9684..a6a2ff8 100644 --- a/src/renderer/pages/ConnectForm.tsx +++ b/src/renderer/pages/ConnectForm.tsx @@ -246,7 +246,7 @@ const ConnectForm: FC = () => { useState(false); const saveClientCertFromStore = ( - value: ClientCertFromStore | undefined + value: ClientCertFromStore | undefined, ): void => { setConnection({ ...connection, @@ -272,7 +272,7 @@ const ConnectForm: FC = () => { }; const clientCertFiltersSummary = getClientCertFiltersSummary( - connection?.clientCertFromStore + connection?.clientCertFromStore, ); const saveCertText = (value: string): void => {