Skip to content

Commit

Permalink
Check queried host as well as MX host for blocklists
Browse files Browse the repository at this point in the history
  • Loading branch information
MattIPv4 committed Jan 3, 2024
1 parent 10f0dea commit 55ab523
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
17 changes: 13 additions & 4 deletions src/dns-lookup/blocklists.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2019 DigitalOcean
Copyright 2024 DigitalOcean
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -48,14 +48,23 @@ const checkDomainBlocklists = (domain: string) => {
}

// Gets any blocklists that the IP/domain is in.
const getBlocklists = async (ip: string, domain: string) => {
const getBlocklists = async (ip?: string | string[], domain?: string | string[]) => {
const blocklists = {
ip: [],
domain: [],
} as any

const promises = [...checkIpBlocklists(ip)]
if (domain) promises.push(...checkDomainBlocklists(domain))
const promises = []
if (ip) {
Array.isArray(ip)
? ip.forEach(item => promises.push(...checkIpBlocklists(item)))
: promises.push(...checkIpBlocklists(ip))
}
if (domain) {
Array.isArray(domain)
? domain.forEach(item => promises.push(...checkDomainBlocklists(item)))
: promises.push(...checkDomainBlocklists(domain))
}

const data = await Promise.all(promises)
data.forEach(item => {
Expand Down
6 changes: 3 additions & 3 deletions src/dns-lookup/templates/record.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
Copyright 2022 DigitalOcean
Copyright 2024 DigitalOcean
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -62,11 +62,11 @@ limitations under the License.
</div>
<div v-else>
{{ value.result }}
<div v-if="value.hostname">
<div v-if="value.ip">
<hr />
<WHOIS :ip="value.ip"></WHOIS>
<div v-if="recordType === 'MX'">
<MXBlocklist :ip="value.ip" :hostname="value.hostname ? value.hostname : ''"></MXBlocklist>
<MXBlocklist :ip="value.ip" :hostname="[ value.hostname, data ]" />
</div>
</div>
</div>
Expand Down

0 comments on commit 55ab523

Please sign in to comment.