How to use the ip.fromLong function in ip

To help you get started, we’ve selected a few ip 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 graalvm / graaljs / deps / npm / node_modules / socks / build / client / socksclient.js View on Github external
else {
            // Read address type
            const addressType = header[3];
            let remoteHost;
            let buff;
            // IPv4
            if (addressType === constants_1.Socks5HostType.IPv4) {
                // Check if data is available.
                const dataNeeded = constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseIPv4;
                if (this._receiveBuffer.length < dataNeeded) {
                    this._nextRequiredPacketBufferSize = dataNeeded;
                    return;
                }
                buff = smart_buffer_1.SmartBuffer.fromBuffer(this._receiveBuffer.get(dataNeeded).slice(4));
                remoteHost = {
                    host: ip.fromLong(buff.readUInt32BE()),
                    port: buff.readUInt16BE()
                };
                // If given host is 0.0.0.0, assume remote proxy ip instead.
                if (remoteHost.host === '0.0.0.0') {
                    remoteHost.host = this._options.proxy.ipaddress;
                }
                // Hostname
            }
            else if (addressType === constants_1.Socks5HostType.Hostname) {
                const hostLength = header[4];
                const dataNeeded = constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseHostname(hostLength); // header + host length + host + port
                // Check if data is available.
                if (this._receiveBuffer.length < dataNeeded) {
                    this._nextRequiredPacketBufferSize = dataNeeded;
                    return;
                }
github borispovod / DAppToolkit / modules / system / sync.js View on Github external
modules.api.transport.getRandomPeer("get", "/blocks/height", null, function (err, res) {
			if (!err && res.body && res.body.success) {
				if (bignum(lastBlock.height).lt(res.body.response)) {
					console.log("found blocks at " + ip.fromLong(res.peer.ip) + ":" + res.peer.port);
					private.findUpdate(lastBlock, res.peer, cb);
				} else {
					//console.log("doesn't found blocks at " + ip.fromLong(res.peer.ip) + ":" + res.peer.port);
					setImmediate(cb);
				}
			} else {
				setImmediate(cb);
			}
		});
	});
github AschPlatform / asch / src / loader.js View on Github external
}, function (err, data) {
    var peerStr = data && data.peer ? ip.fromLong(data.peer.ip) + ":" + data.peer.port : 'unknown';
    if (err || !data.body) {
      library.logger.log("Failed to get height from peer: " + peerStr);
      return cb();
    }

    library.logger.info("Check blockchain on " + peerStr);

    data.body.height = parseInt(data.body.height);

    var report = library.scheme.validate(data.body, {
      type: "object",
      properties: {
        "height": {
          type: "integer",
          minimum: 0
        }
github cloudfoundry-incubator / service-fabrik-broker / data-access-layer / bosh / manifest / Network.js View on Github external
nth(i) {
    return ip.fromLong(ip.toLong(this.ip) + i);
  }
  range(lower, upper) {
github JoshGlazebrook / socks / src / client / socksclient.ts View on Github external
static parseUDPFrame(data: Buffer): SocksUDPFrameDetails {
    const buff = SmartBuffer.fromBuffer(data);
    buff.readOffset = 2;

    const frameNumber = buff.readUInt8();
    const hostType: Socks5HostType = buff.readUInt8();
    let remoteHost;

    if (hostType === Socks5HostType.IPv4) {
      remoteHost = ip.fromLong(buff.readUInt32BE());
    } else if (hostType === Socks5HostType.IPv6) {
      remoteHost = ip.toString(buff.readBuffer(16));
    } else {
      remoteHost = buff.readString(buff.readUInt8());
    }

    const remotePort = buff.readUInt16BE();

    return {
      frameNumber,
      remoteHost: {
        host: remoteHost,
        port: remotePort
      },
      data: buff.readBuffer()
    };
github anchel / weixin-admin / lib / utilLibrary.js View on Github external
int64ToIp: function(i6){
        return ip.fromLong(i6.toNumber());
    },
github DylanPiercey / local-devices / src / index.js View on Github external
function getServers () {
  var interfaces = os.networkInterfaces()
  var result = []

  for (var key in interfaces) {
    var addresses = interfaces[key]
    for (var i = addresses.length; i--;) {
      var address = addresses[i]
      if (address.family === 'IPv4' && !address.internal) {
        var subnet = ip.subnet(address.address, address.netmask)
        var current = ip.toLong(subnet.firstAddress)
        var last = ip.toLong(subnet.lastAddress) - 1
        while (current++ < last) result.push(ip.fromLong(current))
      }
    }
  }

  return result
}
github Ebookcoin / ebookcoin / modules / blocks.js View on Github external
async.eachSeries(blocks, function (block, cb) {
						try {
							block = library.logic.block.objectNormalize(block);
						} catch (e) {
							var peerStr = data.peer ? ip.fromLong(data.peer.ip) + ":" + data.peer.port : 'unknown';
							library.logger.log('Block ' + (block ? block.id : 'null') + ' is not valid, ban 60 min', peerStr);
							modules.peer.state(peer.ip, peer.port, 0, 3600);
							return setImmediate(cb, e);
						}
						self.processBlock(block, false, function (err) {
							if (!err) {
								lastCommonBlockId = block.id;
								lastValidBlock = block;
							} else {
								var peerStr = data.peer ? ip.fromLong(data.peer.ip) + ":" + data.peer.port : 'unknown';
								library.logger.log('Block ' + (block ? block.id : 'null') + ' is not valid, ban 60 min', peerStr);
								modules.peer.state(peer.ip, peer.port, 0, 3600);
							}

							setImmediate(cb, err);
						});