Giter VIP home page Giter VIP logo

mattipv4 / dns-over-discord Goto Github PK

View Code? Open in Web Editor NEW
275.0 5.0 27.0 4.12 MB

1.1.1.1 works from a Discord server, thanks to the 1.1.1.1 bot. Invite the bot to your Discord server to start using DNS over Discord.

Home Page: https://dns-over-discord.v4.wtf/invite

License: Apache License 2.0

JavaScript 99.48% Makefile 0.52%
cloudflare cloudflare-dns cloudflare-dns-api dns dns-over-https doh doh-json discord discord-bot discord-api hacktoberfest discord-slash-commands discord-interactions javascript cloudflare-workers cloudflare-worker discord-message-components

dns-over-discord's Introduction

DNS over Discord

A 1.1.1.1 DNS resolver built for Discord

This documentation is also available on Cloudflare's developer documentation site


1.1.1.1 works from a Discord server, thanks to the 1.1.1.1 bot. Invite the bot to your Discord server to start using DNS over Discord.

Perform DNS lookups

Once the bot is in your server, type /dig to start performing DNS lookups. This will provide a native interface within Discord that allows you to specify the domain to lookup, an optional DNS record type and an optional flag for a short result.

If only a domain is given for the command, the bot will default to looking for A DNS records, and will return the full format result, not the short form.

Example:

/dig domain: cloudflare.com

Supported record types

Discord has a limit of 25 options in slash commands, so DNS over Discord offers the 25 most common DNS record types to choose from.

Supported DNS record types
  • A
  • AAAA
  • CAA
  • CDNSKEY
  • CDS
  • CERT
  • CNAME
  • DNSKEY
  • DS
  • HINFO
  • HTTPS
  • LOC
  • MX
  • NAPTR
  • NS
  • PTR
  • SMIMEA
  • SOA
  • SPF
  • SRV
  • SSHFP
  • SVCB
  • TLSA
  • TXT
  • URI

To query other DNS record types, or multiple record types at once, use the /multi-dig command.

Short form response

DNS over Discord has an optional flag in the /dig command that allows the user to request a response in the short form.

When you request a response in the short form, the name and TTL columns will be excluded. The command only returns the data column without formatting, similar to the equivalent dig command-line interface response.

Example:

/dig domain: cloudflare.com type: AAAA records short: True

Disable DNSSEC checking

You can disable DNSSEC checking in the dig command by passing cdflag as true. This will get the records even if validation fails.

Example:

/dig domain: cloudflare.com type: AAAA records cdflag: True

Refreshing existing results

You can refresh the DNS lookup results by clicking the Refresh button. Clicking it will trigger the bot to re-request the DNS query in the message, and update the results in the message. Any user can click this button.

The refresh button is available on all responses to the /dig command, including those that resulted in an error, such as an unknown domain or no records found.

Refreshing dig domain: cloudflare.com

Changing DNS provider

By default, the DNS over Discord bot uses Cloudflare's 1.1.1.1 DNS service. You can run the DNS lookup with alternate DNS providers by selecting the dropdown below the result. This shows you a list of available providers. Selecting a new provider updates the results in the message. Any user can change the DNS provider.

Supported DNS providers

Changing DNS provider (1.1.1.1 -> 8.8.8.8) for dig domain: cloudflare.com

multi-dig command

If you want to look up multiple DNS record types at once, use the /multi-dig command. This allows you to specify any supported DNS record type, and multiple types separated by a space.

Example:

/multi-dig domain: cloudflare.com types: A AAAA

Supported record types

When providing DNS record types for the /multi-dig command, Discord will not prompt you with options. You have to provide a space-separated list of valid DNS record types to lookup, as any invalid options will be silently dropped. A records will be used as the default if no valid types are given.

DNS record types supported and considered valid by the bot

Use a * (asterisk) in place of a record type to get DNS results for all supported types.

  • A
  • AAAA
  • AFSDB
  • APL
  • CAA
  • CDNSKEY
  • CDS
  • CERT
  • CNAME
  • CSYNC
  • DHCID
  • DLV
  • DNAME
  • DNSKEY
  • DS
  • EUI48
  • EUI64
  • HINFO
  • HIP
  • HTTPS
  • IPSECKEY
  • KEY
  • KX
  • LOC
  • MX
  • NAPTR
  • NS
  • NSEC
  • NSEC3
  • NSEC3PARAM
  • OPENPGPKEY
  • PTR
  • RP
  • SMIMEA
  • SOA
  • SPF
  • SRV
  • SSHFP
  • SVCB
  • TA
  • TKEY
  • TLSA
  • TXT
  • URI
  • ZONEMD

Short form response

Like the main /dig command, the /multi-dig command also supports the optional short flag after the types have been specified in the slash command.

Example:

/multi-dig domain: cloudflare.com types: CDS CDNSKEY short: True

Disable DNSSEC checking

Exactly like dig command, you can disable dns checking by passing cdflag as true. This will get the records even if validation fails.

Example:

/multi-dig domain: cloudflare.com type: AAAA records cdflag: True

Refreshing existing results

The /multi-dig command also provides a refresh button below each set of DNS results requested (or after each block of 10 DNS record types, if you requested more than 10).

As with the /dig command, any user can press the refresh button to refresh the displayed DNS results, including for DNS queries that had previously failed.

Refreshing multi-dig domain: cloudflare.com types: A AAAA

Changing DNS provider

Like the /dig command, you can change the DNS provider when using the /multi-dig command. The menu appears after each set of DNS results (or after each block of results if more than 10 record types are requested).

This menu can be used be any user to change the DNS provider used for the lookup.

Supported DNS providers

Changing DNS provider (1.1.1.1 -> 8.8.8.8) for multi-dig domain: cloudflare.com types: A AAAA

whois command

The /whois command allows you to perform a RDAP/WHOIS lookup right in Discord for a given domain, IP or ASN.

Examples:

/whois query: cloudflare.com
/whois query: 104.16.132.229
/whois query: 2606:4700::6810:84e5
/whois query: 13335

Other commands

The bot also has a set of helper commands available to get more information about the bot and quick links.

help command

The /help command provides in-Discord documentation about all the commands available in the 1.1.1.1 DNS over Discord bot.

Example:

/help

privacy command

The /privacy command displays the Privacy Policy notice for using the 1.1.1.1 DNS over Discord bot. You can also refer to the Privacy Policy page to access it.

Example:

/privacy

terms command

The /terms command displays the Terms of Service notice for using the 1.1.1.1 DNS over Discord bot. You can also refer to the Terms of Service page to access it.

Example:

/terms

github command

The DNS over Discord bot is open-source, and the /github command provides a quick link to access the GitHub repository. The GitHub repository can be accessed at https://github.com/MattIPv4/DNS-over-Discord/.

Example:

/github

invite command

The /invite command provides the user with a quick link to invite the 1.1.1.1 DNS over Discord bot to another Discord server. The bot can be invited at any time with https://dns-over-discord.v4.wtf/invite.

/invite

Development

  1. Create your test Discord application at https://discord.com/developers/applications (this does not need a bot account, just the application).
  2. Create your development.env file.
    • Copy development.env.sample and fill out the information from your Discord application, plus the ID of your test server/guild.
    • A Sentry DSN is required, but the token/org/project can be set to empty if source map uploads are not required.
  3. Authenticate with Wrangler by running npx wrangler login.
  4. Update wrangler.toml for your account.
    • Use npx wrangler whoami to get your account ID, update the value in wrangler.toml to match.
    • Use npx wrangler kv:namespace create "CACHE" to create the KV namespace, update the id and preview_id in wrangler.toml to match.
  5. Develop with the worker by running npm run dev.
  6. (Optional) Start an HTTP tunnel to your local development server by running npm run tunnel, using cloudflared.

Deployments

wrangler.toml and this repository is currently designed for a staging deployment and a production deployment.

Ensure that you've created and configured staging.env and production.env appropriately (staging.env has a test server/guild by default, but this can be removed to stage global commands).

Ensure that the staging/production environments in wrangler.toml have been updated with your zone IDs and routes for the workers.

Ensure that the KV namespaces are created for staging/production environments and are configured in wrangler.toml. Use npx wrangler kv:namespace create "CACHE" --env <staging/production>.

To deploy from local, run npm run publish:staging to deploy to staging, and npm run publish:production to deploy to the production environment.

To deploy using GitHub, run make deploy-staging to force push and deploy to staging, and make deploy-production to force push and deploy to the production environment.

Live logs for both environments can be accessed with npm run logs:staging and npm run logs:production as needed.

Contributing

Contributions are always welcome to this project!
Take a look at any existing issues on this repository for starting places to help contribute towards, or simply create your own new contribution to the project.

Please make sure to follow the existing standards within the project such as code styles, naming conventions and commenting/documentation.

When you are ready, simply create a pull request for your contribution and I will review it whenever I can!

Donating

You can also help me and the project out by sponsoring me through GitHub Sponsors (preferred), contributing through a donation on PayPal or by supporting me monthly on my Patreon page.

GitHub Sponsors Patreon PayPal

Discussion, Support and Issues

Need support with this project, have found an issue or want to chat with others about contributing to the project?

Please check the project's issues page first for support & bugs!

Not found what you need here?

  • If you have an issue, please create a GitHub issue here to report the situation, include as much detail as you can!
  • or, You can join our Slack workspace to discuss any issue, to get support for the project or to chat with contributors and myself:
Slack

dns-over-discord's People

Contributors

advaith1 avatar dependabot[bot] avatar dhravya avatar mattipv4 avatar mohan-13 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

dns-over-discord's Issues

TLDs are not considered valid domain names

Summary

TLDs should be considered valid domain names because they are able to have DNS records. For example, the ai TLD does in fact have A and MX records.

Examples

Bot doesn't consider TLDs a valid domain

Invalid domain image

ai TLD does have DNS records

ai TLD has an A record
ai TLD has an MX record

Unformatted dates in cached whois responses

Look at the following screenshot:

image

Here's the root cause (I think so):

await CACHE.put(key, JSON.stringify(res), {

When an uncached lookup is executed, it is cached and returned (without using JSON.stringify) here. As a result, these dates are displayed in a valid format (here). But when the result is cached (as a result of JSON.stringify), the date loses its type and therefore being toString()'d here (well, I'm not sure, I personally don't like JS btw).

Deploy via GitHub Actions

Create a GitHub Actions workflow the runs on pushes to a branch named production. This workflow should deploy the production environment of the worker to Cloudflare.

As a follow-up, once this initial workflow has been created, duplicate it for a branch named staging, and have it deploy the staging environment of the worker to Cloudflare.

Resolve panic in production caused by cache config

Recently the bot moved to using disgord and initially used a cache config disabling all caches within the bot, as it only needs to respond to messages on-demand without anything being held in the cache.

However, in the production environment, this cache config resulted in the bot panicking and exiting. Commenting out the cache config resolve this for now but results in more memory usage for the bot.

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x7789d7]

goroutine 52 [running]:
github.com/andersfylling/disgord.(*Cache).UpdateMemberAndUser(0xc000118330, 0x530f8633f820003, 0x8e2734314800029, 0xc0008062c0, 0x14f, 0x160)
        C:/Users/Administrator/go/pkg/mod/github.com/andersfylling/[email protected]/cache.go:783 +0x57
github.com/andersfylling/disgord.cacheEvent(0x9a71e0, 0xc000118330, 0xc0001503e0, 0x13, 0x879ae0, 0xc0000da230, 0xc0008062c0, 0x14f, 0x160, 0x0, ...)
        C:/Users/Administrator/go/pkg/mod/github.com/andersfylling/[email protected]/events.go:109 +0x184c
github.com/andersfylling/disgord.demultiplexer(0xc0000d2940, 0xc000108420, 0xc000118330)
        C:/Users/Administrator/go/pkg/mod/github.com/andersfylling/[email protected]/reactor.go:73 +0x207
created by github.com/andersfylling/disgord.(*Client).setupConnectEnv
        C:/Users/Administrator/go/pkg/mod/github.com/andersfylling/[email protected]/client.go:393 +0x216

(Yes, production is a Windows server environment, don't @ me)

User-Installable App

I suggest enabling the "User Install" authorization method for the bot (at Discord Developer Portal)

image

Implement sharding

As the bot begins to grow, there will be a point where it needs to support sharding.

It'd be great if it was still a single executable to be run, that handled spawning all the required shards.

Implement whois with rdap.cloud

Add WHOIS support for domains and IP addresses to the bot.

We should use the rdap.cloud service, specifically https://rdap.cloud/api/v1/xxx, which appears to provide a far more in-depth parsed whois object for both domains and IP addresses. The bot should then be able to return a formatted set of information when the domain whois command is used.

Allow setting the cd flag

Similar to how one can currently set the +short flag for requests, allow the user to set the +cdflag option to disable DNSSEC checking.

This should be exposed as an optional option on both the dig and multi-dig commands. It should map to +cdflag in dig command that is rendered/parsed, similar to how short maps to +short.

README documentation should be updated to explain using the checking disabled option and what it does.

When checking is disabled for a query, a warning should be appended to the embed, indicating that checking was disabled for the query. :warning: cd bit set for request, DNSSEC validation disabled..

Getting started

Hey, I just signed up for cloudflare thing that you told me to do, NPM is not available and nodejs is not available too, can I have a tutorial on the setting the bot up?

UnhandledPromiseRejectionWarning: TypeError: discordCommands is not iterable

Hey.

tried installing the bot myself and failed when doing npm run dev.

here is the full error log:

(node:47656) UnhandledPromiseRejectionWarning: TypeError: discordCommands is not iterable
at module.exports.registerCommands (C:\Users\CENSORED\Desktop\DNS-over-Discord-2\src\build\commands.js:77:27)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async module.exports (C:\Users\CENSORED\Desktop\DNS-over-Discord-2\src\build\index.js:20:29)
(Use node.EXE --trace-warnings ... to show where the warning was created)
(node:47656) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:47656) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
thread 'main' panicked at 'could not parse wranglerjs output: Error("EOF while parsing a value", line: 1, column: 0)', src\wranglerjs\mod.rs:49:43
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
Note: This command was run via npm module 'win-node-env'
npm ERR! code ELIFECYCLE
npm ERR! errno 3221226505
npm ERR! [email protected] dev: NODE_ENV=development wrangler dev
npm ERR! Exit status 3221226505
npm ERR!
npm ERR! Failed at the [email protected] dev script.

Add eslint configuration

As the title suggests, add an eslint configuration to the project based on the existing code style present in the project.

This should be exposed as npm run test:eslint and npm run test:eslint:fix. npm run test & npm run test:fix should also be added, calling npm run test:eslint & npm run test:eslint:fix respectively .

Add end-to-end testing for dig command

For now, I'm only worried about testing the dig command. This will lay the ground-work for testing other commands down the road.

Implement end-to-end testing that simulates a valid interaction call from Discord to the worker (likely using wrangler in the dry-run mode and miniflare to run it in a simulated Workers environment), and ensure that the expected response is received. This will also need network calls mocked so that we can ensure the correct follow-up API calls are made to Discord, as the dig command handles responding asynchronously after the request.

To be clear, this is a pretty complex issue that involves setting up all the ground-work for testing in this repo, as well as fully mocking the Discord API calls involved in the interactions flow.

The end goal here is to have a test suite that can call the dig command (with any domain, any types, any options) as if it were a Discord user running a command, and we can validate that the bot will respond as we expect.

Manage records

Add an option to set your API key from cloudflare and that you can manage records for your zones.

Expose comments in dig result embed

When a DNS lookup is run, some resolvers (such as 1.1.1.1) return comments with additional information, such as warning about DNSSEC failures. We should expose these comments to the end user in the embed generated by the dig command.

curl -H "Accept: application/dns-json" https://cloudflare-dns.com/dns-query\?name\=yumi.dev

{"Status":2,"TC":false,"RD":true,"RA":true,"AD":false,"CD":false,"Question":[{"name":"yumi.dev","type":1}],"Comment":["EDE(9): DNSKEY Missing (no SEP matching the DS found for yumi.dev.)"]}

curl -H "Accept: application/dns-json" https://cloudflare-dns.com/dns-query\?name\=maven.yumi.dev\&cd\=true

{"Status":0,"TC":false,"RD":true,"RA":true,"AD":false,"CD":true,"Question":[{"name":"maven.yumi.dev","type":1}],"Answer":[{"name":"maven.yumi.dev","type":1,"TTL":300,"data":"104.21.73.112"},{"name":"maven.yumi.dev","type":1,"TTL":300,"data":"172.67.162.66"}],"Comment":["EDE(9): DNSKEY Missing (no SEP matching the DS found for yumi.dev.)"]}
curl -H "Accept: application/dns-json" https://dns.google/resolve\?name\=yumi.dev

{"Status":2,"TC":false,"RD":true,"RA":true,"AD":false,"CD":false,"Question":[{"name":"yumi.dev.","type":1}],"Comment":"DNSSEC validation failure. Check http://dnsviz.net/d/yumi.dev/dnssec/ and http://dnssec-debugger.verisignlabs.com/yumi.dev for errors"}

Note that Comment may be a string, or an array of strings, so the logic will need to handle both. Note that comments may be included even when a lookup is successful, such as if there was a DNSSEC error, but checking was disabled.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.