2 module.exports = function()
4 var config = require("./configure.js");
5 var IpBanModel = require("./init").GetIpBanColletion;
7 this.IsBaned = function(ip){
8 return collection[ip] == "r";
10 this.IsBlockedToWrite = function(ip){
11 return ip in collection;
13 this.GetText = function(){
15 for(var key in collection)
17 if(collection[key] == "")
20 text += key + ":" + collection[key] + "\r\n";
24 this.Update = function(text,callfunc){
26 var async = require("async");
29 IpBanModel.drop().done(next);
31 function(result,next){
32 var items = new Array();
33 lines = text.split("\r\n");
34 for(var i = 0; i < lines.length; i++)
36 var token = lines[i].split(":");
43 collection[ip] = token[1];
44 items.push(new Array(ip,collection[ip]));
46 newIpBan = IpBanModel.build(items);
47 newIpBan.save().done(next);
51 function GetIpBanList(callfunc)
53 var async = require("async");
56 IpBanModel.findAll().done(next);
58 function(result,next){
59 for(var i = 0; i < result.length; i++)
60 collection[result[i].ip] = result[i].type;