Package net.windwards.dnsfrontend.frontend

Source Code of net.windwards.dnsfrontend.frontend.UDPQuery

package net.windwards.dnsfrontend.frontend;


import net.windwards.dnsfrontend.api.Sender;
import org.xbill.DNS.Message;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.InetSocketAddress;


public class UDPQuery extends Query {
    private final DatagramPacket packet;
    private Sender sender;

    public UDPQuery(DatagramPacket packet, Sender sender) {
        this.packet = packet;
        this.sender = sender;
    }

    @Override
    public void interpret() throws IOException {
        this.message = new Message(this.packet.getData());
        this.remote = (InetSocketAddress) this.packet.getSocketAddress();
    }

    @Override
    protected void reply(Message message) throws IOException {
        message.getHeader().setID(this.message.getHeader().getID());
        this.sender.send(message.toWire(), this.getRemote());
    }
}
TOP

Related Classes of net.windwards.dnsfrontend.frontend.UDPQuery

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.