Compare commits
No commits in common. "da5a029161d26563083fc17ae845218428c2f5fa" and "3f0ff73d596d9f29d7929445ac683f0b282afc74" have entirely different histories.
da5a029161
...
3f0ff73d59
22
index.js
22
index.js
|
|
@ -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) => {
|
conn.query('SELECT * FROM routes WHERE block_start <= ? AND block_start + block_length >= ?', [number, number]).then((rows) => {
|
||||||
const row = rows[0];
|
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) {
|
if (row) {
|
||||||
// Check if the ANI is within the block range
|
// Check if the ANI is within the block range
|
||||||
// If it is, return `local`
|
// If it is, return `local`
|
||||||
|
|
@ -1104,11 +1087,6 @@ const genCall = (req, res, apiKey, ani, number) => {
|
||||||
} else {
|
} else {
|
||||||
res.status(404).send(`${process.env.MSG_ROUTE_ADDRESS}/404`);
|
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 => {
|
}).catch(err => {
|
||||||
console.error('Error getting route:', err);
|
console.error('Error getting route:', err);
|
||||||
res.status(500).send(`${process.env.MSG_ROUTE_ADDRESS}/500`)
|
res.status(500).send(`${process.env.MSG_ROUTE_ADDRESS}/500`)
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ function runMigrations(pool) {
|
||||||
resolve();
|
resolve();
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.error('Error running migrations:', err);
|
console.errorr('Error running migrations:', err);
|
||||||
reject(err);
|
reject(err);
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
|
|
|
||||||
|
|
@ -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
|
|
||||||
);
|
|
||||||
Loading…
Reference in a new issue