2014-02-17 10:04:01 -08:00
|
|
|
'use strict';
|
|
|
|
|
2014-03-05 18:03:56 -08:00
|
|
|
var imports = require('soop').imports();
|
|
|
|
var fs = require('fs');
|
|
|
|
var buffertools = require('buffertools');
|
|
|
|
var db = imports.db || JSON.parse( fs.readFileSync(imports.poolMatchFile || './poolMatchFile.json'));
|
|
|
|
|
|
|
|
var PoolMatch = function() {
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
self.strings = {};
|
|
|
|
db.forEach(function(pool) {
|
|
|
|
pool.searchStrings.forEach(function(s) {
|
|
|
|
self.strings[s] = {
|
|
|
|
poolName: pool.poolName,
|
|
|
|
url: pool.url
|
|
|
|
};
|
2014-02-17 10:04:01 -08:00
|
|
|
});
|
2014-03-05 18:03:56 -08:00
|
|
|
});
|
|
|
|
};
|
2014-02-17 10:04:01 -08:00
|
|
|
|
2014-02-17 22:40:55 -08:00
|
|
|
|
2014-03-05 18:03:56 -08:00
|
|
|
PoolMatch.prototype.match = function(buffer) {
|
|
|
|
var self = this;
|
|
|
|
for(var k in self.strings) {
|
|
|
|
if (buffertools.indexOf(buffer, k) >= 0) {
|
|
|
|
return self.strings[k];
|
2014-02-24 20:44:19 -08:00
|
|
|
}
|
2014-03-05 18:03:56 -08:00
|
|
|
}
|
|
|
|
};
|
2014-02-17 10:04:01 -08:00
|
|
|
|
2014-03-05 18:03:56 -08:00
|
|
|
module.exports = require('soop')(PoolMatch);
|