How to use the toBuffer function from ip

Find comprehensive JavaScript ip.toBuffer code examples handpicked from public code repositorys.

62
63
64
65
66
67
68
69
70

function parseIP(ip) {
    ip = ip.split('/');
    let addr = ip[0], mask = ip[1];
    return {
        ip: IP.toBuffer(addr),
        prefix: parseInt(mask)
    }
}
fork icon8
star icon27
watch icon3

+ 3 other calls in file

499
500
501
502
503
504
505
506
507
508
509
  if (!buf) buf = Buffer.alloc(ra.encodingLength(host))
  if (!offset) offset = 0


  buf.writeUInt16BE(4, offset)
  offset += 2
  ip.toBuffer(host, buf, offset)
  ra.encode.bytes = 6
  return buf
}

fork icon0
star icon2
watch icon1

345
346
347
348
349
350
351
352
353

  return ip.toString(buff);
};

ip.mask = function(addr, mask) {
  addr = ip.toBuffer(addr);
  mask = ip.toBuffer(mask);

  var result = new Buffer(Math.max(addr.length, mask.length));
fork icon0
star icon0
watch icon1

+ 8 other calls in file

98
99
100
101
102
103
104
105
106
107
  0x00,0x00,0x00,0x00,    // IP: ip dst
])

ipBuffer.writeUInt16BE(parseInt(Math.random()*0xffff), 4) // IP: set identification
ip.toBuffer(src_ip, ipBuffer, 12) // IP: save ip src (src_ip var) into the buffer
ip.toBuffer(dst_ip, ipBuffer, 16) // IP: save ip dst (dst_ip var) into the buffer
raw.writeChecksum(ipBuffer, 10, raw.createChecksum(ipBuffer))</span>

<span class="fragment" data-fragment-index=2>function beforeSend() {
  socket.setOption(
fork icon0
star icon0
watch icon1

+ 3 other calls in file