Skip to content

Commit

Permalink
add udp support
Browse files Browse the repository at this point in the history
  • Loading branch information
calebdoxsey committed Dec 26, 2024
1 parent 5c9fe2f commit 7e71de9
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 3 deletions.
11 changes: 10 additions & 1 deletion api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
36 changes: 34 additions & 2 deletions src/renderer/pages/ConnectForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@ import {
CardContent,
Chip,
Container,
FormControl,
FormControlLabel,
FormHelperText,
Grid,
IconButton,
InputLabel,
MenuItem,
Select,
SelectChangeEvent,
styled,
Switch,
Typography,
Expand All @@ -38,6 +43,7 @@ import { formatTag } from '../../shared/validators';
import {
ClientCertFromStore,
Connection,
Protocol,
Record,
Selector,
} from '../../shared/pb/api';
Expand Down Expand Up @@ -115,6 +121,7 @@ interface Props {

const initialConnData: Connection = {
name: undefined,
protocol: Protocol.TCP,
remoteAddr: '',
listenAddr: undefined,
pomeriumUrl: undefined,
Expand Down Expand Up @@ -239,7 +246,7 @@ const ConnectForm: FC<Props> = () => {
useState(false);

const saveClientCertFromStore = (
value: ClientCertFromStore | undefined,
value: ClientCertFromStore | undefined

Check failure on line 249 in src/renderer/pages/ConnectForm.tsx

View workflow job for this annotation

GitHub Actions / release (ubuntu-latest)

Insert `,`
): void => {
setConnection({
...connection,
Expand All @@ -265,7 +272,7 @@ const ConnectForm: FC<Props> = () => {
};

const clientCertFiltersSummary = getClientCertFiltersSummary(
connection?.clientCertFromStore,
connection?.clientCertFromStore

Check failure on line 275 in src/renderer/pages/ConnectForm.tsx

View workflow job for this annotation

GitHub Actions / release (ubuntu-latest)

Insert `,`
);

const saveCertText = (value: string): void => {
Expand Down Expand Up @@ -310,6 +317,14 @@ const ConnectForm: FC<Props> = () => {
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,
Expand Down Expand Up @@ -552,6 +567,23 @@ const ConnectForm: FC<Props> = () => {
helperText="Name of the route."
/>
</Grid>
<Grid item xs={12}>
<FormControl fullWidth>
<InputLabel id="protocol-label">Protocol</InputLabel>
<Select
labelId="protocol-label"
id="demo-simple-select"
value={
connection?.protocol === Protocol.UDP ? 'UDP' : 'TCP'
}
label="Age"
onChange={handleChangeProtocol}
>
<MenuItem value="TCP">TCP</MenuItem>
<MenuItem value="UDP">UDP</MenuItem>
</Select>
</FormControl>
</Grid>
<Grid item xs={12}>
<TextField
fullWidth
Expand Down
57 changes: 57 additions & 0 deletions src/shared/pb/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,45 @@ import * as _m0 from 'protobufjs/minimal';

export const protobufPackage = 'pomerium.cli';

export enum Protocol {
UNKNOWN = 0,
TCP = 1,
UDP = 2,
UNRECOGNIZED = -1,
}

export function protocolFromJSON(object: any): Protocol {
switch (object) {
case 0:
case 'UNKNOWN':
return Protocol.UNKNOWN;
case 1:
case 'TCP':
return Protocol.TCP;
case 2:
case 'UDP':
return Protocol.UDP;
case -1:
case 'UNRECOGNIZED':
default:
return Protocol.UNRECOGNIZED;
}
}

export function protocolToJSON(object: Protocol): string {
switch (object) {
case Protocol.UNKNOWN:
return 'UNKNOWN';
case Protocol.TCP:
return 'TCP';
case Protocol.UDP:
return 'UDP';
case Protocol.UNRECOGNIZED:
default:
return 'UNRECOGNIZED';
}
}

/** Record represents a single tunnel record in the configuration */
export interface Record {
/** if omitted, a new record would be created */
Expand Down Expand Up @@ -322,6 +361,8 @@ export interface ClientCertFromStore {
export interface Connection {
/** name is a user friendly connection name that a user may define */
name?: string | undefined;
/** the protocol to use for the connection */
protocol?: Protocol | undefined;
/** remote_addr is a remote pomerium host:port */
remoteAddr: string;
/** listen_address, if not provided, will assign a random port each time */
Expand Down Expand Up @@ -2332,6 +2373,7 @@ export const ClientCertFromStore = {
function createBaseConnection(): Connection {
return {
name: undefined,
protocol: undefined,
remoteAddr: '',
listenAddr: undefined,
pomeriumUrl: undefined,
Expand All @@ -2350,6 +2392,9 @@ export const Connection = {
if (message.name !== undefined) {
writer.uint32(10).string(message.name);
}
if (message.protocol !== undefined) {
writer.uint32(80).int32(message.protocol);
}
if (message.remoteAddr !== '') {
writer.uint32(18).string(message.remoteAddr);
}
Expand Down Expand Up @@ -2387,6 +2432,9 @@ export const Connection = {
case 1:
message.name = reader.string();
break;
case 10:
message.protocol = reader.int32() as any;
break;
case 2:
message.remoteAddr = reader.string();
break;
Expand Down Expand Up @@ -2422,6 +2470,9 @@ export const Connection = {
fromJSON(object: any): Connection {
return {
name: isSet(object.name) ? String(object.name) : undefined,
protocol: isSet(object.protocol)
? protocolFromJSON(object.protocol)
: undefined,
remoteAddr: isSet(object.remoteAddr) ? String(object.remoteAddr) : '',
listenAddr: isSet(object.listenAddr)
? String(object.listenAddr)
Expand All @@ -2445,6 +2496,11 @@ export const Connection = {
toJSON(message: Connection): unknown {
const obj: any = {};
message.name !== undefined && (obj.name = message.name);
message.protocol !== undefined &&
(obj.protocol =
message.protocol !== undefined
? protocolToJSON(message.protocol)
: undefined);
message.remoteAddr !== undefined && (obj.remoteAddr = message.remoteAddr);
message.listenAddr !== undefined && (obj.listenAddr = message.listenAddr);
message.pomeriumUrl !== undefined &&
Expand Down Expand Up @@ -2472,6 +2528,7 @@ export const Connection = {
): Connection {
const message = createBaseConnection();
message.name = object.name ?? undefined;
message.protocol = object.protocol ?? undefined;
message.remoteAddr = object.remoteAddr ?? '';
message.listenAddr = object.listenAddr ?? undefined;
message.pomeriumUrl = object.pomeriumUrl ?? undefined;
Expand Down

0 comments on commit 7e71de9

Please sign in to comment.