OSDN Git Service
(root)
/
webchat
/
WebChat.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
sequelizeに移行した
[webchat/WebChat.git]
/
ipban.js
diff --git
a/ipban.js
b/ipban.js
index
cd71581
..
2fcad9d
100644
(file)
--- a/
ipban.js
+++ b/
ipban.js
@@
-2,14
+2,7
@@
module.exports = function()
{
var config = require("./configure.js");
module.exports = function()
{
var config = require("./configure.js");
- var MySQLPool = new require("./mysql_pool.js");
- var pool = new MySQLPool({
- host : config.db_host,
- user : config.db_user,
- password : config.db_password,
- port : config.db_port,
- database : config.db_name,
- });
+ var IpBanModel = require("./init").GetIpBanColletion;
var collection = {};
this.IsBaned = function(ip){
return collection[ip] == "r";
var collection = {};
this.IsBaned = function(ip){
return collection[ip] == "r";
@@
-33,7
+26,7
@@
module.exports = function()
var async = require("async");
async.waterfall([
function(next){
var async = require("async");
async.waterfall([
function(next){
-
pool.query("TRUNCATE TABLE ipbanlist",null,
next);
+
IpBanModel.drop().done(
next);
},
function(result,next){
var items = new Array();
},
function(result,next){
var items = new Array();
@@
-50,7
+43,8
@@
module.exports = function()
collection[ip] = token[1];
items.push(new Array(ip,collection[ip]));
}
collection[ip] = token[1];
items.push(new Array(ip,collection[ip]));
}
- pool.query("INSERT INTO ipbanlist VALUES ?",[items],next);
+ newIpBan = IpBanModel.build(items);
+ newIpBan.save().done(next);
},
],callfunc);
}
},
],callfunc);
}
@@
-59,7
+53,7
@@
module.exports = function()
var async = require("async");
async.waterfall([
function(next){
var async = require("async");
async.waterfall([
function(next){
-
pool.query("SELECT * FROM ipbanlist",null,
next);
+
IpBanModel.findAll().done(
next);
},
function(result,next){
for(var i = 0; i < result.length; i++)
},
function(result,next){
for(var i = 0; i < result.length; i++)