Skip to content

Commit

Permalink
Update dependencies (#163)
Browse files Browse the repository at this point in the history
* Update dependencies

* update dependencies 20230127

* dedup && audit --fix package-lock.json
  • Loading branch information
ItsOnlyBinary authored Jan 27, 2023
1 parent 875fd3a commit c367b73
Show file tree
Hide file tree
Showing 12 changed files with 8,688 additions and 4,691 deletions.
13,277 changes: 8,637 additions & 4,640 deletions package-lock.json

Large diffs are not rendered by default.

50 changes: 24 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,38 @@
"description": "Multi user IRC bouncer",
"main": "src/server.js",
"dependencies": {
"@koa/router": "^8.0.8",
"amqplib": "^0.5.5",
"bcrypt": "^5.0.0",
"better-sqlite3": "^6.0.1",
"commander": "^5.1.0",
"fs-extra": "^8.1.0",
"http-proxy": "^1.18.0",
"ip-cidr": "^2.0.17",
"irc-framework": "^4.4.0",
"@koa/router": "^12.0.0",
"amqplib": "^0.10.3",
"bcrypt": "^5.1.0",
"better-sqlite3": "^8.0.1",
"commander": "^10.0.0",
"fs-extra": "^11.1.0",
"http-proxy": "^1.18.1",
"ip-cidr": "^3.0.11",
"irc-framework": "^4.13.0",
"keyvals": "^1.0.0",
"knex": "^0.21.6",
"koa": "^2.10.0",
"koa-body": "^4.1.1",
"knex": "^2.4.2",
"koa": "^2.14.1",
"koa-body": "^6.0.1",
"koa-mount": "^4.0.0",
"koa-static": "^5.0.0",
"lodash": "^4.17.15",
"lru-cache": "^5.1.1",
"minimatch": "^3.0.4",
"mysql": "^2.17.1",
"lodash": "^4.17.21",
"lru-cache": "^7.14.1",
"minimatch": "^6.1.6",
"mysql": "^2.18.1",
"node-cleanup": "^2.1.2",
"parse-duration": "^0.4.4",
"pg": "^8.3.2",
"parse-duration": "^1.0.2",
"pg": "^8.9.0",
"readline-sync": "^1.4.10",
"request-promise": "^4.2.4",
"rpc-over-ipc": "^1.0.0",
"sqlite3": "^4.0.9",
"strftime": "^0.10.0",
"toml": "^2.3.6",
"unzipper": "^0.10.5",
"uuid": "^3.3.2",
"ws": "^7.1.2"
"strftime": "^0.10.1",
"toml": "^3.0.0",
"unzipper": "^0.10.11",
"uuid": "^9.0.0",
"ws": "^8.12.0"
},
"devDependencies": {
"jest": "^26.3.0"
"jest": "^29.4.1"
},
"scripts": {
"test": "jest",
Expand Down
8 changes: 4 additions & 4 deletions src/actions/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = async function(env, options) {
workerProc.on('exit', spawnWorker);
};

if (process.args.interactive) {
if (process.args.opts().interactive) {
readline.emitKeypressEvents(process.stdin);
process.stdin.setRawMode(true);
process.stdin.on('keypress', (str, key) => {
Expand All @@ -37,14 +37,14 @@ module.exports = async function(env, options) {

if (key.name === 'r' && workerProc) {
l('Reloading worker process...');
workerProc.kill('SIGQUIT');
workerProc.kill('SIGTERM');
}
});
}

process.on('SIGHUP', () => {
l('SIGHUP received. Reloading worker process...');
workerProc.kill('SIGQUIT');
workerProc.kill('SIGTERM');
});

spawnWorker();
Expand All @@ -59,7 +59,7 @@ module.exports = async function(env, options) {
doubleCtrlCTmr = 0;
l('Reloading worker process...');
if (workerProc) {
workerProc.kill('SIGQUIT');
workerProc.kill('SIGTERM');
}
}, 500);

Expand Down
12 changes: 6 additions & 6 deletions src/libs/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const createLogger = require('../libs/logger');

module.exports = async function bootstrap(label) {
process.title = 'kiwibnc-' + label;

await prepareConfig();

// Helper global logger
Expand All @@ -21,7 +21,7 @@ module.exports = async function bootstrap(label) {

l.debug(`Starting ${label}`);

let confPath = process.args.config || './config.ini';
let confPath = process.args.opts().config || './config.ini';
let conf = null;
try {
l.info(`Using config file ${confPath}`);
Expand Down Expand Up @@ -115,20 +115,20 @@ async function initDatabase(app) {

async function prepareConfig() {
let configOption = process.args.options.find(o => o.long === '--config');
let isDefaultConfig = (configOption && process.args.config === configOption.defaultValue);
let configExists = await fs.pathExists(process.args.config);
let isDefaultConfig = (configOption && process.args.opts().config === configOption.defaultValue);
let configExists = await fs.pathExists(process.args.opts().config);

if (configExists) {
return;
}

if (!isDefaultConfig && !configExists) {
console.error('Config file does not exist,', process.args.config);
console.error('Config file does not exist,', process.args.opts().config);
process.exit(1);
}

if (isDefaultConfig) {
let configPath = path.dirname(process.args.config);
let configPath = path.dirname(process.args.opts().config);
console.log('Creating new config profile at ' + configPath);
try {
// Copy the template data folder
Expand Down
6 changes: 3 additions & 3 deletions src/libs/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = class Database {
let dbConf = config.get('database', {});

this.dbConnections = knex({
client: 'sqlite3',
client: 'better-sqlite3',
connection: {
// dbConf.path is legacy
filename: config.relativePath(dbConf.state || dbConf.path || 'connections.db'),
Expand All @@ -17,7 +17,7 @@ module.exports = class Database {

let usersConStr = dbConf.users || 'users.db';
let usersDbCon = {
client: 'sqlite3',
client: 'better-sqlite3',
connection: null,
acquireConnectionTimeout: 10000,
};
Expand All @@ -35,7 +35,7 @@ module.exports = class Database {
usersDbCon = usersConStr;
} else {
// No scheme:// part in the connection string, assume it's an sqlite filename
usersDbCon.client = 'sqlite3';
usersDbCon.client = 'better-sqlite3';
usersDbCon.useNullAsDefault = true;
usersDbCon.connection = { filename: config.relativePath(usersConStr) };
usersDbCon.pool = { propagateCreateError: false };
Expand Down
2 changes: 1 addition & 1 deletion src/libs/tokens.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const uuidv4 = require('uuid/v4');
const { v4: uuidv4 } = require('uuid');

// Different tokens have different prefixes so that we can more easily determine what type of token
// it is. eg. __t1<token> = a user auth token while __t2<token> is a token specific to a network
Expand Down
2 changes: 1 addition & 1 deletion src/sockets/connection.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const net = require('net');
const tls = require('tls');
const { EventEmitter } = require('events');
const uuidv4 = require('uuid/v4');
const { v4: uuidv4 } = require('uuid');
const Throttler = require('../libs/throttler');

module.exports = class SocketConnection extends EventEmitter {
Expand Down
4 changes: 2 additions & 2 deletions src/sockets/socketserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ module.exports = class SocketServer extends EventEmitter {

const proxyCidrStrings = this.appConfig.get('webserver.upstream_proxies', ['127.0.0.1/8']);
proxyCidrStrings.forEach((str) => {
const cidr = new IpCidr(str);
if (!cidr.isValid()) {
if (!IpCidr.isValidAddress(str)) {
l.error('webserver.upstream_proxies CIDR is invalid:', str);
return;
}
const cidr = new IpCidr(str);
this.upstreamProxies.push(cidr);
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/worker/connectionincoming.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const uuidv4 = require('uuid/v4');
const { v4: uuidv4 } = require('uuid');
const IrcMessage = require('irc-framework').Message;
const { ConnectionState } = require('./connectionstate');
const ConnectionOutgoing = require('./connectionoutgoing');
Expand Down
2 changes: 1 addition & 1 deletion src/worker/connectionoutgoing.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const uuidv4 = require('uuid/v4');
const { v4: uuidv4 } = require('uuid');
const Irc = require('irc-framework');
const hooks = require('./hooks');
const Helpers = require('../libs/helpers');
Expand Down
1 change: 0 additions & 1 deletion src/worker/messagestores/sqlite.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class SqliteMessageStore {

this.dataCache = new LRU({
max: 50 * 1000 * 1000, // very roughly 50mb cache
length: (entry, key) => key.length,
});
}

Expand Down
13 changes: 8 additions & 5 deletions src/worker/worker.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const fs = require('fs');
const uuidv4 = require('uuid/v4');
const { v4: uuidv4 } = require('uuid');
const { ircLineParser } = require('irc-framework');
const Koa = require('koa');
const koaStatic = require('koa-static');
const KoaRouter = require('@koa/router');
const KoaMount = require('koa-mount');
const koaBody = require('koa-body');
const { koaBody } = require('koa-body');
const IpCidr = require("ip-cidr");
const MessageStores = require('./messagestores/');
const ConnectionOutgoing = require('./connectionoutgoing');
Expand Down Expand Up @@ -37,6 +37,9 @@ async function run() {
process.on('SIGQUIT', () => {
app.prepareShutdown();
});
process.on('SIGTERM', () => {
app.prepareShutdown();
});

// process.send only exists if we were forked from the sockets layer. Hijack SIGINT so
// that ctrl+c in kiwibnc doesn't do anything to us. Sockets layer will send SIGQUIT to
Expand Down Expand Up @@ -124,7 +127,7 @@ function listenToQueue(app) {
await app.db.dbConnections.raw('DELETE FROM connections WHERE type = ?', [ConnectionDict.TYPE_INCOMING]);

// Since there are now no incoming connections, clear all incoming<>outgoing links
await app.db.dbConnections.raw('UPDATE connections SET linked_con_ids = "[]"');
await app.db.dbConnections.raw(`UPDATE connections SET linked_con_ids = '[]'`);

// If we don't have any connections then we have nothing to clear out. We do
// need to start our servers again though
Expand Down Expand Up @@ -454,11 +457,11 @@ async function statusAuth(ctx, next, role, redirect) {
const allowed = global.config.get('webserver.status_allowed_hosts', ['127.0.0.1/8']);

for (let i = 0; i < allowed.length; i++) {
const cidr = new IpCidr(allowed[i]);
if (!cidr.isValid()) {
if (!IpCidr.isValidAddress(allowed[i])) {
l.error('CIDR is invalid:', allowed[i]);
continue;
}
const cidr = new IpCidr(allowed[i]);
if (cidr.contains(ctx.ip)) {
return await next();
}
Expand Down

0 comments on commit c367b73

Please sign in to comment.