Package us.codecraft.blackhole.container

Source Code of us.codecraft.blackhole.container.HeaderHandler

package us.codecraft.blackhole.container;

import org.springframework.stereotype.Component;
import org.xbill.DNS.Flags;
import org.xbill.DNS.Record;
import org.xbill.DNS.Section;

/**
* @author yihua.huang@dianping.com
* @date Dec 14, 2012
*/
@Component
public class HeaderHandler implements Handler {

  /*
   * (non-Javadoc)
   *
   * @see us.codecraft.blackhole.server.Handler#handle(org.xbill.DNS.Message,
   * org.xbill.DNS.Message)
   */
  @Override
  public boolean handle(MessageWrapper request, MessageWrapper response) {
    response.getMessage().getHeader().setFlag(Flags.QR);
    if (request.getMessage().getHeader().getFlag(Flags.RD)) {
      response.getMessage().getHeader().setFlag(Flags.RD);
    }
    Record queryRecord = request.getMessage().getQuestion();
    response.getMessage().addRecord(queryRecord, Section.QUESTION);
    return true;
  }
}
TOP

Related Classes of us.codecraft.blackhole.container.HeaderHandler

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.