mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-22 02:08:31 +02:00
Traefik config & gerbil config working?
This commit is contained in:
parent
f7b82f0a7a
commit
6600de7320
5 changed files with 12 additions and 13 deletions
|
@ -22,14 +22,6 @@ export async function createHybridClientServer() {
|
||||||
|
|
||||||
await monitor.start();
|
await monitor.start();
|
||||||
|
|
||||||
if (
|
|
||||||
!config.getRawConfig().hybrid?.id ||
|
|
||||||
!config.getRawConfig().hybrid?.secret ||
|
|
||||||
!config.getRawConfig().hybrid?.endpoint
|
|
||||||
) {
|
|
||||||
throw new Error("Hybrid configuration is not defined");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create client
|
// Create client
|
||||||
const client = createWebSocketClient(
|
const client = createWebSocketClient(
|
||||||
token,
|
token,
|
||||||
|
|
|
@ -36,6 +36,8 @@ export const proxyToRemote = async (
|
||||||
validateStatus: () => true // Don't throw on non-2xx status codes
|
validateStatus: () => true // Don't throw on non-2xx status codes
|
||||||
});
|
});
|
||||||
|
|
||||||
|
logger.debug(`Proxy response: ${JSON.stringify(response.data)}`);
|
||||||
|
|
||||||
// Forward the response status and data
|
// Forward the response status and data
|
||||||
return res.status(response.status).json(response.data);
|
return res.status(response.status).json(response.data);
|
||||||
|
|
||||||
|
|
|
@ -120,6 +120,8 @@ export class TraefikConfigManager {
|
||||||
const validCertificates =
|
const validCertificates =
|
||||||
await this.getValidCertificatesForDomains(domains);
|
await this.getValidCertificatesForDomains(domains);
|
||||||
|
|
||||||
|
// logger.debug(`Valid certs array: ${JSON.stringify(validCertificates)}`);
|
||||||
|
|
||||||
// Download and decrypt new certificates
|
// Download and decrypt new certificates
|
||||||
await this.processValidCertificates(validCertificates);
|
await this.processValidCertificates(validCertificates);
|
||||||
|
|
||||||
|
|
|
@ -104,7 +104,7 @@ export async function getConfig(
|
||||||
|
|
||||||
// STOP HERE IN HYBRID MODE
|
// STOP HERE IN HYBRID MODE
|
||||||
if (config.isHybridMode()) {
|
if (config.isHybridMode()) {
|
||||||
return proxyToRemote(req, res, next, "gerbil/get-config");
|
return proxyToRemote(req, res, next, "hybrid/gerbil/get-config");
|
||||||
}
|
}
|
||||||
|
|
||||||
const configResponse = await generateGerbilConfig(exitNode[0]);
|
const configResponse = await generateGerbilConfig(exitNode[0]);
|
||||||
|
|
|
@ -55,27 +55,30 @@ if (config.isHybridMode()) {
|
||||||
// Use proxy router to forward requests to remote cloud server
|
// Use proxy router to forward requests to remote cloud server
|
||||||
// Proxy endpoints for each gerbil route
|
// Proxy endpoints for each gerbil route
|
||||||
gerbilRouter.post("/receive-bandwidth", (req, res, next) =>
|
gerbilRouter.post("/receive-bandwidth", (req, res, next) =>
|
||||||
proxyToRemote(req, res, next, "gerbil/receive-bandwidth")
|
proxyToRemote(req, res, next, "hybrid/gerbil/receive-bandwidth")
|
||||||
);
|
);
|
||||||
|
|
||||||
gerbilRouter.post("/update-hole-punch", (req, res, next) =>
|
gerbilRouter.post("/update-hole-punch", (req, res, next) =>
|
||||||
proxyToRemote(req, res, next, "gerbil/update-hole-punch")
|
proxyToRemote(req, res, next, "hybrid/gerbil/update-hole-punch")
|
||||||
);
|
);
|
||||||
|
|
||||||
gerbilRouter.post("/get-all-relays", (req, res, next) =>
|
gerbilRouter.post("/get-all-relays", (req, res, next) =>
|
||||||
proxyToRemote(req, res, next, "gerbil/get-all-relays")
|
proxyToRemote(req, res, next, "hybrid/gerbil/get-all-relays")
|
||||||
);
|
);
|
||||||
|
|
||||||
// GET CONFIG IS HANDLED IN THE ORIGINAL HANDLER
|
// GET CONFIG IS HANDLED IN THE ORIGINAL HANDLER
|
||||||
// SO IT CAN REGISTER THE LOCAL EXIT NODE
|
// SO IT CAN REGISTER THE LOCAL EXIT NODE
|
||||||
} else {
|
} else {
|
||||||
// Use local gerbil endpoints
|
// Use local gerbil endpoints
|
||||||
gerbilRouter.post("/get-config", gerbil.getConfig);
|
|
||||||
gerbilRouter.post("/receive-bandwidth", gerbil.receiveBandwidth);
|
gerbilRouter.post("/receive-bandwidth", gerbil.receiveBandwidth);
|
||||||
gerbilRouter.post("/update-hole-punch", gerbil.updateHolePunch);
|
gerbilRouter.post("/update-hole-punch", gerbil.updateHolePunch);
|
||||||
gerbilRouter.post("/get-all-relays", gerbil.getAllRelays);
|
gerbilRouter.post("/get-all-relays", gerbil.getAllRelays);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WE HANDLE THE PROXY INSIDE OF THIS FUNCTION
|
||||||
|
// SO IT REGISTERS THE EXIT NODE LOCALLY AS WELL
|
||||||
|
gerbilRouter.post("/get-config", gerbil.getConfig);
|
||||||
|
|
||||||
// Badger routes
|
// Badger routes
|
||||||
const badgerRouter = Router();
|
const badgerRouter = Router();
|
||||||
internalRouter.use("/badger", badgerRouter);
|
internalRouter.use("/badger", badgerRouter);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue