mirror of
https://github.com/fosrl/pangolin.git
synced 2026-09-16 15:50:09 +02:00
Include the sheme in the routing header
This commit is contained in:
@@ -10,7 +10,7 @@ import HttpCode from "@server/types/HttpCode";
|
|||||||
// almost immediately without needing explicit cache invalidation.
|
// almost immediately without needing explicit cache invalidation.
|
||||||
const PROVIDER_TARGETS_TTL_SEC = 7;
|
const PROVIDER_TARGETS_TTL_SEC = 7;
|
||||||
|
|
||||||
// Header gerbil reads to know which host:port (reachable over the
|
// Header gerbil reads to know which scheme://host:port (reachable over the
|
||||||
// WireGuard network) to rewrite an incoming /router/* request to. Must
|
// WireGuard network) to rewrite an incoming /router/* request to. Must
|
||||||
// match gerbil's `pangolinDestHeader` constant.
|
// match gerbil's `pangolinDestHeader` constant.
|
||||||
const PANGOLIN_DEST_HEADER = "p-dest-header";
|
const PANGOLIN_DEST_HEADER = "p-dest-header";
|
||||||
@@ -32,8 +32,9 @@ const SKIP_HEADERS = new Set([
|
|||||||
|
|
||||||
type ResolvedProviderTarget = {
|
type ResolvedProviderTarget = {
|
||||||
targetId: number;
|
targetId: number;
|
||||||
// "<site exitNodeSubnet host>:<internalPort>", passed to gerbil as the
|
// "<scheme>://<site exitNodeSubnet host>:<internalPort>", passed to
|
||||||
// destination to proxy the request to over the WireGuard tunnel.
|
// gerbil as the destination to proxy the request to over the WireGuard
|
||||||
|
// tunnel.
|
||||||
destination: string;
|
destination: string;
|
||||||
// The target's site's exit node HTTP API base URL (gerbil's /router/*).
|
// The target's site's exit node HTTP API base URL (gerbil's /router/*).
|
||||||
gerbilBaseUrl: string;
|
gerbilBaseUrl: string;
|
||||||
@@ -47,6 +48,7 @@ async function fetchProviderTargets(
|
|||||||
targetId: targets.targetId,
|
targetId: targets.targetId,
|
||||||
internalPort: targets.internalPort,
|
internalPort: targets.internalPort,
|
||||||
port: targets.port,
|
port: targets.port,
|
||||||
|
method: targets.method,
|
||||||
exitNodeSubnet: sites.exitNodeSubnet,
|
exitNodeSubnet: sites.exitNodeSubnet,
|
||||||
reachableAt: exitNodes.reachableAt
|
reachableAt: exitNodes.reachableAt
|
||||||
})
|
})
|
||||||
@@ -66,9 +68,10 @@ async function fetchProviderTargets(
|
|||||||
}
|
}
|
||||||
const host = row.exitNodeSubnet.split("/")[0];
|
const host = row.exitNodeSubnet.split("/")[0];
|
||||||
const port = row.internalPort ?? row.port;
|
const port = row.internalPort ?? row.port;
|
||||||
|
const scheme = row.method?.toLowerCase() ?? "https";
|
||||||
resolved.push({
|
resolved.push({
|
||||||
targetId: row.targetId,
|
targetId: row.targetId,
|
||||||
destination: `${host}:${port}`,
|
destination: `${scheme}://${host}:${port}`,
|
||||||
gerbilBaseUrl: row.reachableAt
|
gerbilBaseUrl: row.reachableAt
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user