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());
}
}