Firebase反向DNS查找ENOTFOUND错误node.js dns [英] Firebase reverse dns lookup ENOTFOUND error node.js dns

查看:86
本文介绍了Firebase反向DNS查找ENOTFOUND错误node.js dns的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好Stackoverflow社区! :)

Hello Stackoverflow community! :)

我有一个运行在Firebase上的云功能,该功能用作API,还有另一个服务器(fitbit.com),偶尔将数据发布到我的服务器上.

I have a cloud function running on Firebase, which serves as an API and there is another server (fitbit.com), which occasionally POSTs data to my server.

作为安全功能之一,我想做一个前向确认反向DNS,基本上是以下内容:

As one of the security features, I'd like to do a Forward-Confirmed Reverse DNS, which is basically the following:

  1. 我在IP 169.45.142.104的端点上收到POST.
  2. 我执行反向DNS查找以检索服务器的主机名.
  3. 验证是否返回了fitbit.com的子域(示例中的IP应该解析为['api-169-45-141-216.fitbit.com']).
  4. 然后,我在该主机名上进行DNS查找,并验证它是否可以解析 到原始请求的IP地址.
  1. I receive a POST on an endpoint from IP 169.45.142.104.
  2. I do a reverse DNS lookup to retrieve the hostname of the server.
  3. Verify that this returns a subdomain of fitbit.com (the IP in the example should resolve into ['api-169-45-141-216.fitbit.com']).
  4. Then, I do a DNS lookup on that hostname and verify if it resolves to the IP address of the original request.

这是为节点v6.11.1编写的源代码(在Util类中.:))

Here's the source code written for node v6.11.1 (it's in a Util class.. :))

static fcrDns(ipAddress, cb) {
        const reverse = Q.denodeify(dns.reverse);
        const resolve4 = Q.denodeify(dns.resolve4);
        return reverse(ipAddress).then(hostNames => {
            console.log("hostNames: ", hostNames);

            if (!hostNames.every(SecurityUtils._isFitbitSubDomain)) {
                return Promise.reject("Hostname did not end with .fitbit.com");
            } else {
                return Promise.all([...hostNames.map(hostName => {
                    return resolve4(hostName)
                        .then(resolvedAddresses => {
                            if (resolvedAddresses.every(address => address === ipAddress)) {
                                return Promise.resolve(true);
                            } else {
                                return Promise.reject("Resolved address did not equal to initial IP address");
                            }
                        })
                })]);
            }
        });
    }

    static _isFitbitSubDomain(hostName) {
        return hostName.endsWith(".fitbit.com");
    };

现在,问题是:如果我执行firebase服务,则仅在Windows和Linux主机上的本地主机上运行--only函数时,此方法就可以完美地工作.

Now, the problem is: this works perfectly if I do firebase serve --only functions on localhost, both on windows and linux hosts.

但是,将其部署到Firebase并执行后,出现以下错误:

However, once it's deployed to Firebase and executed, I get the following error:

{ Error: getHostByAddr ENOTFOUND 169.45.142.104
    at errnoException (dns.js:28:10)
    at QueryReqWrap.onresolve [as oncomplete] (dns.js:219:19)
  code: 'ENOTFOUND',
  errno: 'ENOTFOUND',
  syscall: 'getHostByAddr',
  hostname: '169.45.142.104' }

据我所知,节点的源代码意味着它无法执行反向IP查找.

Which, as far as I understood node's source code it means that it could not perform reverse IP lookup.

但是,正如我所测试的那样,解析主机名是正确的.

However, as I've tested, resolving the hostname works properly.

可能存在服务器设置,该设置可以防止进行反向dns查找,但可以解析吗?

Might there be a server setting, which could prevent doing reverse dns lookup, but allows resolving?

推荐答案

我与Cloud Functions后端团队进行了交谈,他们目前不允许反向DNS查找.这是可以更改的内容,因此,我鼓励您提交功能请求,详细说明为什么这对您很重要.还提供有关此问题的链接.

I talked to the Cloud Functions backend team, and they currently don't allow reverse DNS lookups. This is something that could be changed, so I will encourage you to file a feature request with the details of why this is important to you. Also provide a link to this issue on SO.

看起来已经进行了更改以允许此操作,但是我不清楚它是否已经可用,或者何时将其提供.

It looks like the change was made to allow this, but it's not clear to me if it's already available, or when it will be made available.

这篇关于Firebase反向DNS查找ENOTFOUND错误node.js dns的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆