make dns server configurable.

master
Thurloat 6 years ago
parent f69c36d600
commit 02a8d7b686
  1. 27
      config/config.exs
  2. 3
      lib/dough/dohplug.ex

@ -2,29 +2,8 @@
# and its dependencies with the aid of the Mix.Config module. # and its dependencies with the aid of the Mix.Config module.
use Mix.Config use Mix.Config
# This configuration is loaded before any dependency and is restricted config :dough,
# to this project. If another project depends on this project, this # default, an opennic server.
# file won't be loaded nor affect the parent project. For this reason, dns_server: "37.235.1.174"
# if you want to provide default values for your application for
# 3rd-party users, it should be done in your "mix.exs" file.
# You can configure your application as:
#
# config :dough, key: :value
#
# and access this configuration in your application as:
#
# Application.get_env(:dough, :key)
#
# You can also configure a 3rd-party app:
#
# config :logger, level: :info
#
# It is also possible to import configuration files, relative to this
# directory. For example, you can emulate configuration per environment
# by uncommenting the line below and defining dev.exs, test.exs and such.
# Configuration from the imported file will override the ones defined
# here (which is why it is important to import them last).
#
# import_config "#{Mix.env}.exs" # import_config "#{Mix.env}.exs"

@ -83,8 +83,9 @@ defmodule Dough.DoHPlug do
end end
def handoff_dns(dns_message) do def handoff_dns(dns_message) do
dns_server = Application.get_env(:dough, :dns_server)
client = Socket.UDP.open!() client = Socket.UDP.open!()
send!(client, dns_message, {"8.8.8.8", 53}) send!(client, dns_message, {dns_server, 53})
{data, _server} = recv!(client) {data, _server} = recv!(client)
data data
end end

Loading…
Cancel
Save