服务器节点js上的dns反向查询

时间:2019-04-04 18:36:10

标签: node.js

我在NodeJS服务器(server.js)上遇到问题

我发现这两个函数startBindings()不时为同一用户重复运行

 dns.reverse(client.__store.address, (function (user, store) {
                 return function (err, hostnames) {
                     store.hostname = (Array.isArray(hostnames) && hostnames[0] ? hostnames[0] : user.request.connection.remoteAddress);
                     if (store.hostname === store.address) {
                        startBindings(user, data, store.address, null); // Here it will display the IP.
                      } else {
                      // If not, he must display the hostname with store.hostname
                        dns.lookup(store.hostname, { all: true }, function (err, ips, family) {
                            startBindings(user, data, store.address, ((ips || []).some(function (e) { return e.address == store.address }) ? store.hostname : null));
                        });
                     }
                 }
             })(client, client.__store));

startBinding()函数将数据发送到客户端,似乎有时dns.reverse()重复执行,而客户端甚至不再连接,或者由于在客户端上存在用户虚影而导致的某些不合逻辑的操作服务器。

有解决方案吗?

0 个答案:

没有答案