001/* 002 * Copyright 2015-2020 the original author or authors 003 * 004 * This software is licensed under the Apache License, Version 2.0, 005 * the GNU Lesser General Public License version 2 or later ("LGPL") 006 * and the WTFPL. 007 * You may choose either license to govern your use of this software only 008 * upon the condition that you accept all of the terms of either 009 * the Apache License 2.0, the LGPL 2.1+ or the WTFPL. 010 */ 011package org.minidns.edns; 012 013import java.nio.charset.StandardCharsets; 014 015import org.minidns.edns.Edns.OptionCode; 016import org.minidns.util.Hex; 017 018public class Nsid extends EdnsOption { 019 020 public static final Nsid REQUEST = new Nsid(); 021 022 private Nsid() { 023 this(new byte[0]); 024 } 025 026 public Nsid(byte[] payload) { 027 super(payload); 028 } 029 030 @Override 031 public OptionCode getOptionCode() { 032 return OptionCode.NSID; 033 } 034 035 @Override 036 protected CharSequence toStringInternal() { 037 String res = OptionCode.NSID + ": "; 038 res += new String(optionData, StandardCharsets.US_ASCII); 039 return res; 040 } 041 042 @Override 043 protected CharSequence asTerminalOutputInternal() { 044 return Hex.from(optionData); 045 } 046 047}