mirror of
https://github.com/fosrl/pangolin.git
synced 2025-07-27 22:25:58 +02:00
update selection algorithm
This commit is contained in:
parent
f3b44a3085
commit
d45443258b
4 changed files with 117 additions and 85 deletions
|
@ -3,7 +3,7 @@ import { MessageHandler } from "../ws";
|
|||
import { exitNodes, Newt } from "@server/db";
|
||||
import logger from "@server/logger";
|
||||
import config from "@server/lib/config";
|
||||
import { ne, eq, and, count } from "drizzle-orm";
|
||||
import { ne, eq, or, and, count } from "drizzle-orm";
|
||||
|
||||
export const handleNewtPingRequestMessage: MessageHandler = async (context) => {
|
||||
const { message, client, sendToClient } = context;
|
||||
|
@ -17,10 +17,11 @@ export const handleNewtPingRequestMessage: MessageHandler = async (context) => {
|
|||
}
|
||||
|
||||
// TODO: pick which nodes to send and ping better than just all of them
|
||||
const exitNodesList = await db
|
||||
let exitNodesList = await db
|
||||
.select()
|
||||
.from(exitNodes)
|
||||
.where(ne(exitNodes.maxConnections, 0));
|
||||
.from(exitNodes);
|
||||
|
||||
exitNodesList = exitNodesList.filter((node) => node.maxConnections !== 0);
|
||||
|
||||
let lastExitNodeId = null;
|
||||
if (newt.siteId) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue