lib/rubydns.rb in rubydns-1.0.3 vs lib/rubydns.rb in rubydns-2.0.0.pre.rc1
- old
+ new
@@ -16,35 +16,21 @@
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
+require 'async/dns'
+
require_relative 'rubydns/version'
+require_relative 'rubydns/rule_based_server'
-require_relative 'rubydns/message'
-require_relative 'rubydns/server'
-require_relative 'rubydns/resolver'
-require_relative 'rubydns/handler'
-require_relative 'rubydns/logger'
-
module RubyDNS
+ # Backwards compatibility:
+ Resolver = Async::DNS::Resolver
+
# Run a server with the given rules.
- def self.run_server (options = {}, &block)
- server_class = options[:server_class] || RuleBasedServer
+ def self.run_server (server_class: RuleBasedServer, **options, &block)
+ server = server_class.new(**options, &block)
- supervisor = server_class.supervise(options, &block)
-
- supervisor.actors.first.run
- if options[:asynchronous]
- return supervisor
- else
- read, write = IO.pipe
-
- trap(:INT) {
- write.puts
- }
-
- IO.select([read])
- supervisor.terminate
- end
+ server.run
end
end