Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
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 = {
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;
});
};
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')
})
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
},
},
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';
});
}
}
timeout = parseInt(
$h.toStringSafe(
timeout
).trim()
);
if (isNaN(timeout)) {
timeout = 5000;
}
const OPTS = {
timeout: timeout,
};
return v6 ? publicIP.v6(OPTS)
: publicIP.v4(OPTS);
}
);
export function getPublicIp() {
return fetchPublicIp()
.catch(() => getPublicIpViaStun())
.catch(() => {
throw new Error('Failed to retrieve public ip address')
})
}
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;
});
}
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())
})
}