How to use the bns.util.countLabels function in bns

To help you get started, we’ve selected a few bns examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github handshake-org / hsd / lib / dns / records.js View on Github external
function isSingle(label) {
  label = util.fqdn(label);

  if (!isName(label))
    return false;

  if (util.countLabels(label) !== 1)
    return false;

  return true;
}
github handshake-org / hsd / lib / dns / records.js View on Github external
read(br) {
    this.service = readNameBR(br);

    if (util.countLabels(this.service) !== 1)
      throw new Error('Invalid label.');

    this.protocol = readNameBR(br);

    if (util.countLabels(this.protocol) !== 1)
      throw new Error('Invalid label.');

    this.priority = br.readU8();
    this.weight = br.readU8();
    this.target.read(br);
    this.port = br.readU16BE();

    return this;
  }
github handshake-org / hsd / lib / dns / records.js View on Github external
read(br) {
    this.protocol = readNameBR(br);

    if (util.countLabels(this.protocol) !== 1)
      throw new Error('Invalid label.');

    this.port = br.readU16BE();
    this.usage = br.readU8();
    this.selector = br.readU8();
    this.matchingType = br.readU8();
    this.certificate = br.readBytes(br.readU8());

    return this;
  }
github handshake-org / hsd / lib / dns / records.js View on Github external
read(br) {
    this.nid = readNameBR(br);

    if (util.countLabels(this.nid) !== 1)
      throw new Error('Invalid label.');

    const size = br.readU8();
    assert(size <= 64);

    this.nin = br.readString(size, 'hex');

    return this;
  }