Added additional query to block hosts in blocked file
This commit is contained in:
parent
d27d048d7a
commit
7ab1ca6ae0
12
lib/db.js
12
lib/db.js
@ -1,6 +1,7 @@
|
||||
var sqlite3 = require('sqlite3').verbose();
|
||||
var db = new sqlite3.Database("./proxy.db");
|
||||
var winston = require("winston");
|
||||
var url = require("url");
|
||||
|
||||
var fs = require('fs');
|
||||
|
||||
@ -97,6 +98,17 @@ function addHostToTable(hostname) {
|
||||
*/
|
||||
exports.visitHost = function (hostname, callbackFn) {
|
||||
return db.serialize(() => {
|
||||
|
||||
// let host = new url.URL(hostname).hostname
|
||||
// console.log(hostname)
|
||||
|
||||
db.get("select * from blocked_hosts where hostname = ?", [hostname], (err, row) => {
|
||||
if (row !== undefined) {
|
||||
logger.info("Blocked " + hostname + " due to blocked.json")
|
||||
callbackFn(false)
|
||||
}
|
||||
})
|
||||
|
||||
db.get("select * from hosts where hostname = ?", [hostname], (err, row) => {
|
||||
if (row === undefined) {
|
||||
addHostToTable(hostname);
|
||||
|
Loading…
Reference in New Issue
Block a user