added caching for complex lookups

This commit is contained in:
2020-12-29 13:15:27 -05:00
parent bce23ab9fe
commit 1ff7d3cb4f
5 changed files with 230 additions and 27 deletions
+9 -1
View File
@@ -8,7 +8,15 @@ const conf = require('../app').conf;
const socket = new SocketServerJson({
socketFile: conf.socketFile,
onData: function(data, clientSocket) {
clientSocket.write(JSON.stringify(Host.lookUp(data['domain']) || {host: 'none'}));
let host = Host.lookUp(data['domain']);
clientSocket.write(JSON.stringify(host || {host: 'none'}));
if(host){
try{
Host.addCache(data['domain'], host)
}catch(error){
console.error('Should never get this error...', error)
}
}
},
onListen: function(){
console.log('listening')