How to use the public-ip.v4 function in public-ip

To help you get started, we’ve selected a few public-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 PRINTR3D / formide-client / src / modules / cloud / index.js View on Github external
this.cloud.on('connect', () => {
			let getMac = getmac.getMac;
			if (self.tools && self.tools.mac instanceof Function)
				getMac = self.tools.mac;

			let getIp = callback => {
				setImmediate(() => callback(null, internalIp()));
			};
			if (self.tools && self.tools.ip instanceof Function)
				getIp = self.tools.ip;

			// authenticate formideos based on mac address and api token, also
			// sends permissions for faster blocking via cloud
			publicIp.v4().then((publicIpAddress) => {
				getIp((err, internalIpAddress) => {
					getMac((err, macAddress) => {
						self.cloud.emit('authenticate', {
							type: 		 'client',
							ip: 		 publicIpAddress,
							ip_internal: internalIpAddress,
							version:     require('../../../package.json').version,
							environment: FormideClient.config.environment,
							mac: 		 macAddress,
							port:        FormideClient.config.get('app.port')
						}, response => {
							if (response.success) {
								FormideClient.log('Cloud connected')

								// forward all events to the cloud
								FormideClient.events.onAny(forwardEvents)
github alex73630 / Floatplane-Downloader / rewrite.js View on Github external
db.config.find({}, function (err, docs) {
		if (docs.length === 0){
			// Config is not setup
			publicIp.v4().then(publicip => {
				const configID = uuidv4();

				var configURL = 'http://' + publicip + ':8000/setup/' + configID;
				var localConfigURL = 'http://' + ip.address() + ':8000/setup/' + configID;

				console.log('First start or app not setup, go to this URL to config:');
				console.log('External server:',configURL);
				console.log('Local server:',localConfigURL);

				app.route('/setup/'+configID)
					.get(function(req,res){
						res.sendFile(__dirname + '/web/html/setup.html');
					})
					.post(function(req,res){
						console.log(req.query);
						config = {
github pmenager / synology-dns-route53-updater / synoDNSUpdater.js View on Github external
var getPublicIP = function () {
    return publicIp.v4()
	    .then(function(ip) {
	        currentIP = ip;
	        console.log("Current public IP is " + currentIP);
    	}).catch(function(err) {
	        console.log("Unable to get public IP");
	        console.log(err);
	        throw err;
    	});
};
github layr-team / Layr / start.js View on Github external
const kad_bat = require('./kadence_plugin').kad_bat;
const stellar_account = require('./kadence_plugin').stellar_account;
const seed = require('./constants').SEED_NODE;
const cliServer = require('./constants').CLI_SERVER;
const batNodePort = require('./constants').BATNODE_SERVER_PORT
const kadNodePort = require('./constants').KADNODE_PORT
const publicIp = require('public-ip');
const fs = require('fs');
const fileUtils = require('./utils/file').fileSystem;
const JSONStream = require('JSONStream');
const backoff = require('backoff');
const crypto = require('crypto');
const base32 = require('base32');


publicIp.v4().then(ip => {
 const kademliaNode = new kad.KademliaNode({
    transport: new kad.HTTPTransport(),
    storage: levelup(encoding(leveldown('./dbbb'))),
    contact: {hostname: ip, port: kadNodePort}
  })

  kademliaNode.plugin(kad_bat)
  kademliaNode.plugin(stellar_account)
  kademliaNode.listen(kadNodePort)
  const batNode = new BatNode(kademliaNode)
  kademliaNode.batNode = batNode

  const nodeConnectionCallback = (serverConnection) => {
    serverConnection.on('end', () => {
      console.log('end')
    })
github aragon / aragon-cli / packages / cli / src / commands / ipfs_cmds / status.js View on Github external
task: async ctx => {
          const [publicIP, internalIP] = await Promise.all([
            publicIp.v4(),
            internalIp.v4(),
          ])

          ctx.publicSwarmMultiAddr =
            '/ip4/' + publicIP + '/tcp/4001/ipfs' + ctx.peerID
          ctx.internalSwarmMultiAddr =
            '/ip4/' + internalIP + '/tcp/4001/ipfs' + ctx.peerID
          ctx.localSwarmMultiAddr =
            '/ip4/' + '127.0.0.1' + '/tcp/4001/ipfs' + ctx.peerID
        },
      },
github datarhei / restreamer / src / classes / Restreamer.js View on Github external
static getPublicIp() {
        logger.info('Retrieving public IP ...', 'publicIP');
        publicIp.v4().then(ip => {
            Restreamer.data.publicIp = ip;
            logger.info('Found public IP: ' + ip, 'publicIP');
        }).catch(err => {
            logger.warn('Failed to get public IP', 'publicIP');
            Restreamer.data.publicIp = '127.0.0.1';
        });
    }
}
github egodigital / vscode-powertools / src / tools / quickcode.ts View on Github external
timeout = parseInt(
                $h.toStringSafe(
                    timeout
                ).trim()
            );
            if (isNaN(timeout)) {
                timeout = 5000;
            }

            const OPTS = {
                timeout: timeout,
            };

            return v6 ? publicIP.v6(OPTS)
                : publicIP.v4(OPTS);
        }
    );
github dgreif / ring / api / rtp-utils.ts View on Github external
export function getPublicIp() {
  return fetchPublicIp()
    .catch(() => getPublicIpViaStun())
    .catch(() => {
      throw new Error('Failed to retrieve public ip address')
    })
}
github nasa / cumulus / packages / cmrjs / utils.js View on Github external
async function getIp() {
  deprecate('@cumulus/cmrjs/utils#getIp', '1.11.3');
  return publicIp.v4({ https: true })
    .catch((err) => {
      if (err.message === 'Query timed out') {
        return process.env.USER_IP_ADDRESS || '10.0.0.0';
      }

      throw err;
    });
}
github ArkEcosystem / core / api / public / v2 / controllers / peers.js View on Github external
const me = (req, res, next) => {
  publicIp.v4().then(ip => {
    blockchain.networkInterface
      .getPeers()
      .then(peers => utils.respondWithResource(req, res, peers.find(p => p.ip === ip), 'peer'))
      .then(() => next())
  })
}

public-ip

Get your public IP address — very fast!

MIT
Latest version published 1 month ago

Package Health Score

83 / 100
Full package analysis

Popular public-ip functions