move max connections from config to db

This commit is contained in:
miloschwartz 2025-06-17 15:53:57 -04:00
parent a0001aaa74
commit 21e9edd201
No known key found for this signature in database
4 changed files with 6 additions and 5 deletions

View file

@ -113,7 +113,8 @@ export const exitNodes = pgTable("exitNodes", {
endpoint: varchar("endpoint").notNull(), endpoint: varchar("endpoint").notNull(),
publicKey: varchar("publicKey").notNull(), publicKey: varchar("publicKey").notNull(),
listenPort: integer("listenPort").notNull(), listenPort: integer("listenPort").notNull(),
reachableAt: varchar("reachableAt") reachableAt: varchar("reachableAt"),
maxConnections: integer("maxConnections")
}); });
export const users = pgTable("user", { export const users = pgTable("user", {

View file

@ -117,7 +117,8 @@ export const exitNodes = sqliteTable("exitNodes", {
endpoint: text("endpoint").notNull(), // this is how to reach gerbil externally - gets put into the wireguard config endpoint: text("endpoint").notNull(), // this is how to reach gerbil externally - gets put into the wireguard config
publicKey: text("publicKey").notNull(), publicKey: text("publicKey").notNull(),
listenPort: integer("listenPort").notNull(), listenPort: integer("listenPort").notNull(),
reachableAt: text("reachableAt") // this is the internal address of the gerbil http server for command control reachableAt: text("reachableAt"), // this is the internal address of the gerbil http server for command control
maxConnections: integer("maxConnections")
}); });
export const users = sqliteTable("user", { export const users = sqliteTable("user", {

View file

@ -162,7 +162,6 @@ export const configSchema = z
gerbil: z gerbil: z
.object({ .object({
exit_node_name: z.string().optional(), exit_node_name: z.string().optional(),
max_connections: z.number().positive().gt(0).optional(),
start_port: portSchema start_port: portSchema
.optional() .optional()
.default(51820) .default(51820)

View file

@ -25,8 +25,8 @@ export const handleNewtPingRequestMessage: MessageHandler = async (context) => {
// higher = more desirable // higher = more desirable
let weight = 1; let weight = 1;
const maxConnections = config.getRawConfig().gerbil.max_connections; const maxConnections = node.maxConnections;
if (maxConnections !== undefined) { if (maxConnections !== null && maxConnections !== undefined) {
const [currentConnections] = await db const [currentConnections] = await db
.select({ .select({
count: count() count: count()