How to use public-ip - 10 common examples

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 ErlendEllingsen / digitalocean-developer-firewall / modules / Firewall.js View on Github external
if (preSet6 != undefined) self.IPV6 = preSet6;
                resolve(true);
            }
            
            let foundV4 = false;
    
            let prom1 = publicIp.v4().then(ip => {
                foundV4 = ip;
            }).catch(err => {
                foundV4 = false;
            });
             
    
            let foundV6 = false;
    
            let prom2 = publicIp.v6().then(ip => {
                foundV6 = ip;
            }).catch(err => {
                foundV6 = false;
            });
    
            // -- Fetch all -- 
            Promise.all([prom1, prom2]).then(values => {
                
                if (foundV4 === false && foundV6 === false) {
                    throw 'Unable to fetch IP address and no pre defined IP set.';
                }
    
                self.IPV4 = foundV4;
                self.IPV6 = foundV6;
                
                resolve(true);
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 jeppestaerk / alfred-show-network-info / index.js View on Github external
text: {
			copy: ip,
			largetype: ip
		},
		variables: {
			action: 'copy'
		}
	})
}

if (alfy.input.split(" ")[0].toLowerCase() === 'ssh') {
	addOutput(`Type ssh username for ${alfy.input.split(" ")[1]}`, `ssh ${alfy.input.split(" ")[2] || 'root'}@${alfy.input.split(" ")[1]}`, `ssh ${alfy.input.split(" ")[2] || 'root'}@${alfy.input.split(" ")[1]}`, 'Public', 'ssh')
} else if (alfy.input.toLowerCase() === 'scan') {
	promises.push(localDevices().then(devices => devices.forEach(device => addIPOutput('Device', device.ip, device.name, device.mac))).catch(() => addIPOutput('No local devices found', 'Local')));
} else if (alfy.input.toLowerCase() === 'ipv6') {
	if (process.env['show_public'] === 'true') promises.push(publicIp.v6().then(ip => addIPOutput('Public', ip, '', '')).catch(() => addIPOutput('Public', 'IPv6 not found', '', '')));
	if (process.env['show_local'] === 'true') promises.push(internalIp.v6().then(ip => addIPOutput('Internal', ip, '', '')).catch(() => addIPOutput('Internal', 'IPv6 not found', '', '')));
	if (process.env['show_gateway'] === 'true') promises.push(defaultGateway.v6().then(ip => addIPOutput('Gateway', ip.gateway, '', '')).catch(() => addIPOutput('Gateway', 'IPv6 not found', '', '')));
} else {
	if (process.env['show_public'] === 'true') promises.push(publicIp.v4().then(ip => addIPOutput('Public', ip, '', '')).catch(() => addIPOutput('Public', 'IPv4 not found', '', '')));
	if (process.env['show_local'] === 'true') promises.push(internalIp.v4().then(ip => addIPOutput('Internal', ip, '', '')).catch(() => addIPOutput('Internal', 'IPv4 not found', '', '')));
	if (process.env['show_gateway'] === 'true') promises.push(defaultGateway.v4().then(ip => addIPOutput('Gateway', ip.gateway, '', '')).catch(() => addIPOutput('Gateway', 'IPv4 not found', '', '')));
}

Promise.all(promises).then(() => {
	if (!alfy.input) {
		if (process.env['show_scan'] === 'true') addOutput('Discover devices on local network', '', `${process.env['keyword']} scan`, 'Scan', 'rerun');
		if (process.env['show_ipv6'] === 'true') addOutput('See IPv6 network info', '', `${process.env['keyword']} IPv6`, 'IPv6', 'rerun');
		if (process.env['show_contribute'] === 'true') addOutput('Contribute to this workflow on GitHub', 'https://github.com/jeppestaerk/alfred-show-network-info', 'https://github.com/jeppestaerk/alfred-show-network-info#contributions', 'Contribute', 'browser');
	}
	alfy.output(output)
});
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')
    })
}

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