diff --git a/install/config/config.yml b/install/config/config.yml index f7d4552d..5a9df5ba 100644 --- a/install/config/config.yml +++ b/install/config/config.yml @@ -26,7 +26,7 @@ server: cors: origins: ["https://{{.DashboardDomain}}"] methods: ["GET", "POST", "PUT", "DELETE", "PATCH"] - headers: ["X-CSRF-Token", "Content-Type"] + allowed_headers: ["X-CSRF-Token", "Content-Type"] credentials: false traefik: diff --git a/server/db/README.md b/server/db/README.md index 76515b46..36c3730b 100644 --- a/server/db/README.md +++ b/server/db/README.md @@ -31,6 +31,12 @@ docker run -d \ postgres:17 ``` +### Schema + +`server/db/pg/schema.ts` and `server/db/sqlite/schema.ts` contain the database schema definitions. These need to be kept in sync with with each other. + +Stick to common data types and avoid Postgres-specific features to ensure compatibility with SQLite. + ### SQLite To use SQLite, edit `server/db/index.ts` to export all from `server/db/sqlite/index.ts`: diff --git a/server/db/pg/schema.ts b/server/db/pg/schema.ts index 227ceba4..cb641974 100644 --- a/server/db/pg/schema.ts +++ b/server/db/pg/schema.ts @@ -47,7 +47,8 @@ export const sites = pgTable("sites", { megabytesOut: real("bytesOut"), lastBandwidthUpdate: varchar("lastBandwidthUpdate"), type: varchar("type").notNull(), // "newt" or "wireguard" - online: boolean("online").notNull().default(false) + online: boolean("online").notNull().default(false), + dockerSocketEnabled: boolean("dockerSocketEnabled").notNull().default(true) }); export const resources = pgTable("resources", { diff --git a/server/routers/badger/verifySession.ts b/server/routers/badger/verifySession.ts index 2c8b20b9..7ee431d6 100644 --- a/server/routers/badger/verifySession.ts +++ b/server/routers/badger/verifySession.ts @@ -97,7 +97,28 @@ export async function verifyResourceSession( query } = parsedBody.data; - const clientIp = requestIp?.split(":")[0]; + const clientIp = requestIp + ? (() => { + logger.debug("Request IP:", { requestIp }); + if (requestIp.startsWith("[") && requestIp.includes("]")) { + // if brackets are found, extract the IPv6 address from between the brackets + const ipv6Match = requestIp.match(/\[(.*?)\]/); + if (ipv6Match) { + return ipv6Match[1]; + } + } + + // ivp4 + // split at last colon + const lastColonIndex = requestIp.lastIndexOf(":"); + if (lastColonIndex !== -1) { + return requestIp.substring(0, lastColonIndex); + } + return requestIp; + })() + : undefined; + + logger.debug("Client IP:", { clientIp }); let cleanHost = host; // if the host ends with :443 or :80 remove it