package zeptodns;

import zeptodns.handlers.QueryHandler;
import zeptodns.nio.NioServer;
import zeptodns.protocol.fluent.MessageBuilder;
import zeptodns.protocol.messages.Message;
import zeptodns.protocol.messages.Response;

import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * ZeptoDNS server main class.
 */
public class ZeptoDNS implements Runnable {
    private static final Logger LOGGER = Logger.getLogger(ZeptoDNS.class.getName());

    private NioServer server;
    private QueryHandler queryHandler;

    public ZeptoDNS() {
        server = new NioServer();

        queryHandler = query -> {
            Message message = MessageBuilder
                    .begin()
                    .asResponse(query.getMessage())
                    .authoritative(true)
                    .withARecord(query.getMessage().getQuestions().get(0).getQuestionName(), "192.168.13.37")
                    .withARecord(query.getMessage().getQuestions().get(0).getQuestionName(), "192.168.13.38")
                    .end();

            return new Response(message);
        };

        server.setQueryHandler(queryHandler);
    }

    /**
     * Program entry point.
     *
     * @param args command line arguments
     */
    public static void main(String[] args) {
        ZeptoDNS zeptoDns = new ZeptoDNS();
        zeptoDns.run();
    }

    @Override
    public void run() {
        LOGGER.log(Level.INFO, "Starting ZeptoDNS server connection loop...");

        server.run();
    }
}

@@ -218,16 +218,45 @@
 ponse;%0A%0A
+import java.net.InetAddress;%0A
 import j
@@ -494,19 +494,22 @@
 private 
-Nio
+final 
 Server s
@@ -527,16 +527,22 @@
 private 
+final 
 QueryHan
@@ -585,54 +585,590 @@
 DNS(
-) %7B%0A        server = new NioServer();%0A%0A       
+Server server, QueryHandler queryHandler) %7B%0A        this.server = server;%0A        this.queryHandler = queryHandler;%0A%0A        server.setQueryHandler(queryHandler);%0A    %7D%0A%0A    @Override%0A    public void run() %7B%0A        LOGGER.log(Level.INFO, %22Starting ZeptoDNS server...%22);%0A%0A        server.run();%0A    %7D%0A%0A    /**%0A     * Program entry point.%0A     *%0A     * @param args command line arguments%0A     */%0A    public static void main(String%5B%5D args) %7B%0A        NioServer server = new NioServer(InetAddress.getLoopbackAddress(), 53);%0A%0A        // TODO: this is only for testing%0A        QueryHandler
  que
@@ -1672,398 +1672,80 @@
     
-server.setQueryHandler(queryHandler);%0A    %7D%0A%0A    /**%0A     * Program entry point.%0A     *%0A     * @param args command line arguments%0A     */%0A    public static void main(String%5B%5D args) %7B%0A        ZeptoDNS zeptoDns = new ZeptoDNS();%0A        zeptoDns.run();%0A    %7D%0A%0A    @Override%0A    public void run() %7B%0A        LOGGER.log(Level.INFO, %22Starting ZeptoDNS server connection loop...%22);%0A%0A        server
+ZeptoDNS zeptoDns = new ZeptoDNS(server, queryHandler);%0A        zeptoDns
 .run

Restructure ZeptoDNS class