1
0
Fork 0
mirror of https://github.com/middleman/middleman.git synced 2022-11-09 12:20:27 -05:00
middleman--middleman/middleman-cli/fixtures/preview-server-app/bin/dns_server.rb
Marc Anguera 3c34c18bdf
Minify JS: migrate from Uglifier to Terser gem to support ES6 (#2532)
* Minify JS: migrate from Uglifier to Terser gem to support ES6

* rebase and bundle update

Co-authored-by: Thomas Reynolds <me@tdreyno.com>
2022-01-30 19:37:53 +00:00

33 lines
628 B
Ruby
Executable file

#!/usr/bin/env ruby
# frozen_string_literal: true
require 'rubydns'
require 'psych'
db_file = ARGV[0]
port = ARGV[1] || 5300
db = if File.file? db_file
warn 'Found dns db'
Psych.load_file(db_file)
else
warn 'Found no dns db. Use default db.'
{
/www\.example\.org/ => '1.1.1.1'
}
end
interfaces = [
[:udp, '127.0.0.1', port],
[:tcp, '127.0.0.1', port]
]
# Start the RubyDNS server
RubyDNS.run_server(interfaces) do
db.each do |matcher, result|
match(matcher, Resolv::DNS::Resource::IN::A) do |transaction|
transaction.respond!(result)
end
end
end