Compare commits

..

No commits in common. "da5a029161d26563083fc17ae845218428c2f5fa" and "3f0ff73d596d9f29d7929445ac683f0b282afc74" have entirely different histories.

3 changed files with 26 additions and 56 deletions

View file

@ -1071,23 +1071,6 @@ const genCall = (req, res, apiKey, ani, number) => {
conn.query('SELECT * FROM routes WHERE block_start <= ? AND block_start + block_length >= ?', [number, number]).then((rows) => {
const row = rows[0];
// Check blocklist. Type 1 is exact match, Type 2 is prefix match NNNXXXX where NNN is the prefix value.
// Check if the ANI is blocked from calling this route
const routeId = row ? row.id : null;
if (!routeId) {
res.status(404).send(`${process.env.MSG_ROUTE_ADDRESS}/404`);
return;
}
conn.query('SELECT * FROM blocklist WHERE (blockType = 1 AND blockValue = ?) OR (blockType = 2 AND ? BETWEEN blockValue AND blockValue + ?);', [ani, ani, row.block_length]).then((blockRows) => {
if (blockRows.length > 0) {
// ANI is blocked from calling this route
console.log(`Blocked Call Attempt: ${ani} -> ${number}`);
res.status(403).send(`${process.env.MSG_ROUTE_ADDRESS}/403`);
return;
}
if (row) {
// Check if the ANI is within the block range
// If it is, return `local`
@ -1104,11 +1087,6 @@ const genCall = (req, res, apiKey, ani, number) => {
} else {
res.status(404).send(`${process.env.MSG_ROUTE_ADDRESS}/404`);
}
}).catch(err => {
console.error('Error checking blocklist:', err);
res.status(500).send(`${process.env.MSG_ROUTE_ADDRESS}/500`);
return;
});
}).catch(err => {
console.error('Error getting route:', err);
res.status(500).send(`${process.env.MSG_ROUTE_ADDRESS}/500`)

View file

@ -59,7 +59,7 @@ function runMigrations(pool) {
resolve();
})
.catch(err => {
console.error('Error running migrations:', err);
console.errorr('Error running migrations:', err);
reject(err);
})
.finally(() => {

View file

@ -1,8 +0,0 @@
CREATE TABLE IF NOT EXISTS blocklist (
id INT AUTO_INCREMENT PRIMARY KEY,
ownerId INT NOT NULL,
blockType INT NOT NULL,
blockValue VARCHAR(255) NOT NULL,
createdAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (ownerId) REFERENCES routes(id) ON DELETE CASCADE
);