mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-02 00:55:48 +02:00
Fix bugs and change makefile
This commit is contained in:
parent
16e2a262e9
commit
002614499b
13 changed files with 150 additions and 159 deletions
|
@ -22,5 +22,6 @@ RUN npm install --omit=dev
|
|||
|
||||
COPY --from=builder /app/.next ./.next
|
||||
COPY --from=builder /app/dist ./dist
|
||||
COPY server/db/names.json /app/dist/names.json
|
||||
|
||||
CMD ["npm", "start"]
|
||||
|
|
9
Makefile
9
Makefile
|
@ -1,6 +1,11 @@
|
|||
|
||||
all:
|
||||
docker build -t pangolin .
|
||||
all: build push
|
||||
|
||||
build:
|
||||
docker build -t fossorial/pangolin:latest .
|
||||
|
||||
push:
|
||||
docker push fossorial/pangolin:latest
|
||||
|
||||
test:
|
||||
docker run -it -p 3000:3000 -p 3001:3001 --env-file=.env -v ./config:/app/config pangolin
|
||||
|
|
|
@ -10,150 +10,150 @@ import db from "@server/db";
|
|||
import { createSuperuserRole } from "@server/db/ensureActions";
|
||||
|
||||
async function insertDummyData() {
|
||||
// Insert dummy orgs
|
||||
const org1 = db
|
||||
.insert(orgs)
|
||||
.values({
|
||||
orgId: "default",
|
||||
name: "Default",
|
||||
domain: "fosrl.io",
|
||||
})
|
||||
.returning()
|
||||
.get();
|
||||
// // Insert dummy orgs
|
||||
// const org1 = db
|
||||
// .insert(orgs)
|
||||
// .values({
|
||||
// orgId: "default",
|
||||
// name: "Default",
|
||||
// domain: "fosrl.io",
|
||||
// })
|
||||
// .returning()
|
||||
// .get();
|
||||
|
||||
await createSuperuserRole(org1.orgId!);
|
||||
// await createSuperuserRole(org1.orgId!);
|
||||
|
||||
const org2 = db
|
||||
.insert(orgs)
|
||||
.values({
|
||||
orgId: "fossorial",
|
||||
name: "Fossorial",
|
||||
domain: "fossorial.io",
|
||||
})
|
||||
.returning()
|
||||
.get();
|
||||
// const org2 = db
|
||||
// .insert(orgs)
|
||||
// .values({
|
||||
// orgId: "fossorial",
|
||||
// name: "Fossorial",
|
||||
// domain: "fossorial.io",
|
||||
// })
|
||||
// .returning()
|
||||
// .get();
|
||||
|
||||
await createSuperuserRole(org2.orgId!);
|
||||
// await createSuperuserRole(org2.orgId!);
|
||||
|
||||
// Insert dummy exit nodes
|
||||
const exitNode1 = db
|
||||
.insert(exitNodes)
|
||||
.values({
|
||||
name: "Exit Node 1",
|
||||
address: "10.0.0.1/24",
|
||||
privateKey: "sKQlCNErB2n+dV8eLp5Yw/avsjK/zkrxJE0n48hjb10=",
|
||||
listenPort: 51820,
|
||||
})
|
||||
.returning()
|
||||
.get();
|
||||
// // Insert dummy exit nodes
|
||||
// const exitNode1 = db
|
||||
// .insert(exitNodes)
|
||||
// .values({
|
||||
// name: "Exit Node 1",
|
||||
// address: "10.0.0.1/24",
|
||||
// privateKey: "sKQlCNErB2n+dV8eLp5Yw/avsjK/zkrxJE0n48hjb10=",
|
||||
// listenPort: 51820,
|
||||
// })
|
||||
// .returning()
|
||||
// .get();
|
||||
|
||||
const exitNode2 = db
|
||||
.insert(exitNodes)
|
||||
.values({
|
||||
name: "Exit Node 2",
|
||||
address: "172.16.1.1/24",
|
||||
privateKey: "ACaw+q5vHVm8Xb0jIgIkMzlkJiriC7cURuOiNbGsGHg=",
|
||||
listenPort: 51820,
|
||||
})
|
||||
.returning()
|
||||
.get();
|
||||
// const exitNode2 = db
|
||||
// .insert(exitNodes)
|
||||
// .values({
|
||||
// name: "Exit Node 2",
|
||||
// address: "172.16.1.1/24",
|
||||
// privateKey: "ACaw+q5vHVm8Xb0jIgIkMzlkJiriC7cURuOiNbGsGHg=",
|
||||
// listenPort: 51820,
|
||||
// })
|
||||
// .returning()
|
||||
// .get();
|
||||
|
||||
// Insert dummy sites
|
||||
const site1 = db
|
||||
.insert(sites)
|
||||
.values({
|
||||
orgId: org1.orgId,
|
||||
exitNode: exitNode1.exitNodeId,
|
||||
name: "Main Site",
|
||||
subdomain: "main",
|
||||
pubKey: "Kn4eD0kvcTwjO//zqH/CtNVkMNdMiUkbqFxysEym2D8=",
|
||||
subnet: "10.0.0.16/28",
|
||||
})
|
||||
.returning()
|
||||
.get();
|
||||
// // Insert dummy sites
|
||||
// const site1 = db
|
||||
// .insert(sites)
|
||||
// .values({
|
||||
// orgId: org1.orgId,
|
||||
// exitNode: exitNode1.exitNodeId,
|
||||
// name: "Main Site",
|
||||
// subdomain: "main",
|
||||
// pubKey: "Kn4eD0kvcTwjO//zqH/CtNVkMNdMiUkbqFxysEym2D8=",
|
||||
// subnet: "10.0.0.16/28",
|
||||
// })
|
||||
// .returning()
|
||||
// .get();
|
||||
|
||||
const site2 = db
|
||||
.insert(sites)
|
||||
.values({
|
||||
orgId: org2.orgId,
|
||||
exitNode: exitNode2.exitNodeId,
|
||||
name: "Dev Site",
|
||||
subdomain: "dev",
|
||||
pubKey: "V329Uf/vhnBwYxAuT/ZlMZuLokHy5tug/sGsLfIMK1w=",
|
||||
subnet: "172.16.1.16/28",
|
||||
})
|
||||
.returning()
|
||||
.get();
|
||||
// const site2 = db
|
||||
// .insert(sites)
|
||||
// .values({
|
||||
// orgId: org2.orgId,
|
||||
// exitNode: exitNode2.exitNodeId,
|
||||
// name: "Dev Site",
|
||||
// subdomain: "dev",
|
||||
// pubKey: "V329Uf/vhnBwYxAuT/ZlMZuLokHy5tug/sGsLfIMK1w=",
|
||||
// subnet: "172.16.1.16/28",
|
||||
// })
|
||||
// .returning()
|
||||
// .get();
|
||||
|
||||
// Insert dummy resources
|
||||
const resource1 = db
|
||||
.insert(resources)
|
||||
.values({
|
||||
resourceId: `web.${site1.subdomain}.${org1.domain}`,
|
||||
siteId: site1.siteId,
|
||||
orgId: site1.orgId,
|
||||
name: "Web Server",
|
||||
subdomain: "web",
|
||||
})
|
||||
.returning()
|
||||
.get();
|
||||
// // Insert dummy resources
|
||||
// const resource1 = db
|
||||
// .insert(resources)
|
||||
// .values({
|
||||
// resourceId: `web.${site1.subdomain}.${org1.domain}`,
|
||||
// siteId: site1.siteId,
|
||||
// orgId: site1.orgId,
|
||||
// name: "Web Server",
|
||||
// subdomain: "web",
|
||||
// })
|
||||
// .returning()
|
||||
// .get();
|
||||
|
||||
const resource2 = db
|
||||
.insert(resources)
|
||||
.values({
|
||||
resourceId: `web2.${site1.subdomain}.${org1.domain}`,
|
||||
siteId: site1.siteId,
|
||||
orgId: site1.orgId,
|
||||
name: "Web Server 2",
|
||||
subdomain: "web2",
|
||||
})
|
||||
.returning()
|
||||
.get();
|
||||
// const resource2 = db
|
||||
// .insert(resources)
|
||||
// .values({
|
||||
// resourceId: `web2.${site1.subdomain}.${org1.domain}`,
|
||||
// siteId: site1.siteId,
|
||||
// orgId: site1.orgId,
|
||||
// name: "Web Server 2",
|
||||
// subdomain: "web2",
|
||||
// })
|
||||
// .returning()
|
||||
// .get();
|
||||
|
||||
const resource3 = db
|
||||
.insert(resources)
|
||||
.values({
|
||||
resourceId: `db.${site2.subdomain}.${org2.domain}`,
|
||||
siteId: site2.siteId,
|
||||
orgId: site2.orgId,
|
||||
name: "Database",
|
||||
subdomain: "db",
|
||||
})
|
||||
.returning()
|
||||
.get();
|
||||
// const resource3 = db
|
||||
// .insert(resources)
|
||||
// .values({
|
||||
// resourceId: `db.${site2.subdomain}.${org2.domain}`,
|
||||
// siteId: site2.siteId,
|
||||
// orgId: site2.orgId,
|
||||
// name: "Database",
|
||||
// subdomain: "db",
|
||||
// })
|
||||
// .returning()
|
||||
// .get();
|
||||
|
||||
// Insert dummy routes
|
||||
await db.insert(routes).values([
|
||||
{ exitNodeId: exitNode1.exitNodeId, subnet: "10.0.0.0/24" },
|
||||
{ exitNodeId: exitNode2.exitNodeId, subnet: "172.16.1.1/24" },
|
||||
]);
|
||||
// // Insert dummy routes
|
||||
// await db.insert(routes).values([
|
||||
// { exitNodeId: exitNode1.exitNodeId, subnet: "10.0.0.0/24" },
|
||||
// { exitNodeId: exitNode2.exitNodeId, subnet: "172.16.1.1/24" },
|
||||
// ]);
|
||||
|
||||
// Insert dummy targets
|
||||
await db.insert(targets).values([
|
||||
{
|
||||
resourceId: resource1.resourceId,
|
||||
ip: "10.0.0.16",
|
||||
method: "http",
|
||||
port: 4200,
|
||||
protocol: "TCP",
|
||||
},
|
||||
{
|
||||
resourceId: resource2.resourceId,
|
||||
ip: "10.0.0.17",
|
||||
method: "https",
|
||||
port: 443,
|
||||
protocol: "TCP",
|
||||
},
|
||||
{
|
||||
resourceId: resource3.resourceId,
|
||||
ip: "172.16.1.16",
|
||||
method: "http",
|
||||
port: 80,
|
||||
protocol: "TCP",
|
||||
},
|
||||
]);
|
||||
// // Insert dummy targets
|
||||
// await db.insert(targets).values([
|
||||
// {
|
||||
// resourceId: resource1.resourceId,
|
||||
// ip: "10.0.0.16",
|
||||
// method: "http",
|
||||
// port: 4200,
|
||||
// protocol: "TCP",
|
||||
// },
|
||||
// {
|
||||
// resourceId: resource2.resourceId,
|
||||
// ip: "10.0.0.17",
|
||||
// method: "https",
|
||||
// port: 443,
|
||||
// protocol: "TCP",
|
||||
// },
|
||||
// {
|
||||
// resourceId: resource3.resourceId,
|
||||
// ip: "172.16.1.16",
|
||||
// method: "http",
|
||||
// port: 80,
|
||||
// protocol: "TCP",
|
||||
// },
|
||||
// ]);
|
||||
|
||||
console.log("Dummy data inserted successfully");
|
||||
// console.log("Dummy data inserted successfully");
|
||||
}
|
||||
|
||||
insertDummyData().catch(console.error);
|
||||
|
|
|
@ -37,7 +37,6 @@ export async function listRoleSites(req: Request, res: Response, next: NextFunct
|
|||
.select({
|
||||
siteId: sites.siteId,
|
||||
name: sites.name,
|
||||
subdomain: sites.subdomain,
|
||||
})
|
||||
.from(roleSites)
|
||||
.innerJoin(sites, eq(roleSites.siteId, sites.siteId))
|
||||
|
|
|
@ -10,7 +10,7 @@ import { ActionsEnum, checkUserActionPermission } from '@server/auth/actions';
|
|||
import logger from '@server/logger';
|
||||
|
||||
const listRolesParamsSchema = z.object({
|
||||
orgId: z.string().optional().transform(Number).pipe(z.number().int().positive()),
|
||||
orgId: z.string()
|
||||
});
|
||||
|
||||
const listRolesSchema = z.object({
|
||||
|
@ -61,14 +61,11 @@ export async function listRoles(req: Request, res: Response, next: NextFunction)
|
|||
orgName: orgs.name,
|
||||
})
|
||||
.from(roles)
|
||||
.leftJoin(orgs, eq(roles.orgId, orgs.orgId));
|
||||
.leftJoin(orgs, eq(roles.orgId, orgs.orgId))
|
||||
.where(eq(roles.orgId, orgId));
|
||||
|
||||
let countQuery: any = db.select({ count: sql<number>`cast(count(*) as integer)` }).from(roles);
|
||||
|
||||
if (orgId) {
|
||||
baseQuery = baseQuery.where(eq(roles.orgId, orgId));
|
||||
countQuery = countQuery.where(eq(roles.orgId, orgId));
|
||||
}
|
||||
let countQuery: any = db.select({ count: sql<number>`cast(count(*) as integer)` }).from(roles)
|
||||
.where(eq(roles.orgId, orgId));
|
||||
|
||||
const rolesList = await baseQuery.limit(limit).offset(offset);
|
||||
const totalCountResult = await countQuery;
|
||||
|
|
|
@ -25,7 +25,7 @@ const createSiteSchema = z.object({
|
|||
subnet: z.string().optional(),
|
||||
});
|
||||
|
||||
export type GetSiteResponse = {
|
||||
export type CreateSiteResponse = {
|
||||
name: string;
|
||||
siteId: number;
|
||||
orgId: string;
|
||||
|
|
|
@ -11,7 +11,7 @@ import { eq } from 'drizzle-orm';
|
|||
|
||||
const addUserSiteSchema = z.object({
|
||||
userId: z.string(),
|
||||
siteId: z.string().optional().transform(stoi).pipe(z.number().int().positive().optional()),
|
||||
siteId: z.string().transform(Number).pipe(z.number().int().positive()),
|
||||
});
|
||||
|
||||
export async function addUserSite(req: Request, res: Response, next: NextFunction): Promise<any> {
|
||||
|
|
|
@ -28,7 +28,6 @@ import {
|
|||
} from "@/components/ui/select"
|
||||
import { Textarea } from "@/components/ui/textarea"
|
||||
import { useSiteContext } from "@app/hooks/useSiteContext"
|
||||
import api from "@app/api"
|
||||
|
||||
const GeneralFormSchema = z.object({
|
||||
name: z.string()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Separator } from "@/components/ui/separator"
|
||||
import { AccountForm } from "@/app/configuration/account/account-form"
|
||||
import { AccountForm } from "./account-form"
|
||||
|
||||
export default function SettingsAccountPage() {
|
||||
return (
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Separator } from "@/components/ui/separator"
|
||||
import { AppearanceForm } from "@/app/configuration/appearance/appearance-form"
|
||||
import { AppearanceForm } from "./appearance-form"
|
||||
|
||||
export default function SettingsAppearancePage() {
|
||||
return (
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Separator } from "@/components/ui/separator"
|
||||
import { DisplayForm } from "@/app/configuration/display/display-form"
|
||||
import { DisplayForm } from "./display-form"
|
||||
|
||||
export default function SettingsDisplayPage() {
|
||||
return (
|
||||
|
|
|
@ -40,16 +40,6 @@ interface SettingsLayoutProps {
|
|||
export default function SettingsLayout({ children }: SettingsLayoutProps) {
|
||||
return (
|
||||
<>
|
||||
|
||||
<div className="w-full bg-stone-200 border-b border-stone-300 mb-6 select-none sm:px-0 px-3">
|
||||
<div className="container mx-auto flex flex-col content-between gap-4 pt-2">
|
||||
<Header
|
||||
email={"user.email"}
|
||||
orgName={"Profile"}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="md:hidden">
|
||||
<Image
|
||||
src="/configuration/forms-light.png"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Separator } from "@/components/ui/separator"
|
||||
import { NotificationsForm } from "@/app/configuration/notifications/notifications-form"
|
||||
import { NotificationsForm } from "./notifications-form"
|
||||
|
||||
export default function SettingsNotificationsPage() {
|
||||
return (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue