Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions messages/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -2116,6 +2116,7 @@
"domainPickerFreeProvidedDomain": "Free Provided Domain",
"domainPickerVerified": "Verified",
"domainPickerUnverified": "Unverified",
"domainPickerManual": "Manual",
"domainPickerInvalidSubdomainStructure": "This subdomain contains invalid characters or structure. It will be sanitized automatically when you save.",
"domainPickerError": "Error",
"domainPickerErrorLoadDomains": "Failed to load organization domains",
Expand Down
9 changes: 9 additions & 0 deletions server/lib/readConfigFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,11 @@ export const configSchema = z
.default(21820)
.transform(stoi)
.pipe(portSchema),
wss_relay_port: portSchema
.optional()
.default(4430)
.transform(stoi)
.pipe(portSchema),
base_endpoint: z
.string()
.optional()
Expand All @@ -289,6 +294,10 @@ export const configSchema = z
.optional()
.default(30)
})
.transform((cfg) => ({
...cfg,
wss_relay_port: cfg.wss_relay_port ?? cfg.wss_relay_port ?? 4430
}))
.optional()
.prefault({}),
orgs: z
Expand Down
16 changes: 15 additions & 1 deletion server/routers/olm/getOlmToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ import logger from "@server/logger";
import config from "@server/lib/config";
import { APP_VERSION } from "@server/lib/consts";

function buildRelayEndpointWss() {
const dashboardUrl = (
config.getRawConfig().app.dashboard_url || "http://localhost:3000"
).replace(/\/$/, "");
return `${dashboardUrl.replace(/^http/i, "ws")}/api/v1/relay-tunnel`;
}

export const olmGetTokenBodySchema = z.object({
olmId: z.string(),
secret: z.string().optional(),
Expand Down Expand Up @@ -253,6 +260,7 @@ export async function getOlmToken(
publicKey: exitNode.publicKey,
relayPort: config.getRawConfig().gerbil.clients_start_port,
endpoint: exitNode.endpoint,
relayEndpointWss: buildRelayEndpointWss(),
siteIds: exitNodeIdToSiteIds[exitNode.exitNodeId] ?? []
};
});
Expand All @@ -261,7 +269,13 @@ export async function getOlmToken(

return response<{
token: string;
exitNodes: { publicKey: string; endpoint: string }[];
exitNodes: {
publicKey: string;
endpoint: string;
relayPort: number;
relayEndpointWss: string;
siteIds: number[];
}[];
serverVersion: string;
}>(res, {
data: {
Expand Down
10 changes: 9 additions & 1 deletion server/routers/olm/handleOlmRelayMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ import { updatePeer as newtUpdatePeer } from "../newt/peers";
import logger from "@server/logger";
import config from "@server/lib/config";

function buildRelayEndpointWss() {
const dashboardUrl = (
config.getRawConfig().app.dashboard_url || "http://localhost:3000"
).replace(/\/$/, "");
return `${dashboardUrl.replace(/^http/i, "ws")}/api/v1/relay-tunnel`;
}

export const handleOlmRelayMessage: MessageHandler = async (context) => {
const { message, client: c, sendToClient } = context;
const olm = c as Olm;
Expand Down Expand Up @@ -91,7 +98,8 @@ export const handleOlmRelayMessage: MessageHandler = async (context) => {
siteId: siteId,
relayEndpoint: exitNode.endpoint,
relayPort: config.getRawConfig().gerbil.clients_start_port,
chainId
chainId,
relayEndpointWss: buildRelayEndpointWss()
}
},
broadcast: false,
Expand Down
Loading