Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const mysql = require('mysql2');
- const Promise = require('bluebird');
- const testConfig = {
- 'global.php' : {
- constants : {
- "MYSQL_HOST: "clone-me-prod-20190409.chh6vulasacr.us-east-1.rds.amazonaws.com",
- "MYSQL_USER": "wickr",
- "MYSQL_PASS": "kief4thim1Ahh2qu",
- "MYSQL_DB": "wickrdb",
- }
- }
- }
- //const config = require('/etc/wickr/config/cronjobs-enterprise/config.json');
- const { constants: { MYSQL_HOST, MYSQL_USER, MYSQL_PASS, MYSQL_DB }} = testConfig['global.php']
- const currentTimeStamp = () => Math.round(new Date().getTime() / 1000);
- const DELETE_OLD_SIEM_ENTRY = 'DELETE FROM siem where timestamp < ?';
- async function cleanRateLimiting() {
- try {
- const conn = await getDbConnection();
- conn.query(DELETE_OLD_SIEM_ENTRY, [currentTimeStamp()]);
- }
- }
- async function getDbPool() {
- const pool = await mysql.createPool({
- connectionLimit: 10,
- host: CONFIG.mysql.hostname,
- user: CONFIG.mysql.username,
- password: CONFIG.mysql.password,
- database: CONFIG.mysql.database
- });
- return pool.promise();
- }
- async function getDbConnection() {
- const pool = await getDbPool();
- const { connection } = pool.getConnection();
- return connection;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement