mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-05 02:24:59 +02:00
Working on getting targets connected to newt
This commit is contained in:
parent
ab6d59c163
commit
a170466f91
8 changed files with 300 additions and 72 deletions
|
@ -22,6 +22,7 @@ const createSiteSchema = z
|
|||
subdomain: z.string().min(1).max(255).optional(),
|
||||
pubKey: z.string().optional(),
|
||||
subnet: z.string(),
|
||||
type: z.string(),
|
||||
})
|
||||
.strict();
|
||||
|
||||
|
@ -48,7 +49,7 @@ export async function createSite(
|
|||
);
|
||||
}
|
||||
|
||||
const { name, subdomain, exitNodeId, pubKey, subnet } = parsedBody.data;
|
||||
const { name, type, exitNodeId, pubKey, subnet } = parsedBody.data;
|
||||
|
||||
const parsedParams = createSiteParamsSchema.safeParse(req.params);
|
||||
if (!parsedParams.success) {
|
||||
|
@ -76,6 +77,7 @@ export async function createSite(
|
|||
name,
|
||||
niceId,
|
||||
subnet,
|
||||
type,
|
||||
};
|
||||
|
||||
if (pubKey) {
|
||||
|
@ -114,10 +116,17 @@ export async function createSite(
|
|||
|
||||
if (pubKey) {
|
||||
// add the peer to the exit node
|
||||
await addPeer(exitNodeId, {
|
||||
publicKey: pubKey,
|
||||
allowedIps: [],
|
||||
});
|
||||
if (type == "newt") {
|
||||
await addPeer(exitNodeId, {
|
||||
publicKey: pubKey,
|
||||
allowedIps: [subnet],
|
||||
});
|
||||
} else if (type == "wireguard") {
|
||||
await addPeer(exitNodeId, {
|
||||
publicKey: pubKey,
|
||||
allowedIps: [],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return response(res, {
|
||||
|
|
|
@ -17,11 +17,11 @@ const updateSiteBodySchema = z
|
|||
.object({
|
||||
name: z.string().min(1).max(255).optional(),
|
||||
subdomain: z.string().min(1).max(255).optional(),
|
||||
pubKey: z.string().optional(),
|
||||
subnet: z.string().optional(),
|
||||
exitNode: z.number().int().positive().optional(),
|
||||
megabytesIn: z.number().int().nonnegative().optional(),
|
||||
megabytesOut: z.number().int().nonnegative().optional(),
|
||||
// pubKey: z.string().optional(),
|
||||
// subnet: z.string().optional(),
|
||||
// exitNode: z.number().int().positive().optional(),
|
||||
// megabytesIn: z.number().int().nonnegative().optional(),
|
||||
// megabytesOut: z.number().int().nonnegative().optional(),
|
||||
})
|
||||
.strict()
|
||||
.refine((data) => Object.keys(data).length > 0, {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue