Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const cluster = require('cluster')
const opentracing = require('opentracing')
const address = require('address')
const SpanContext = require('./span_context')
const WORKER_ID = cluster.worker ? cluster.worker.id : 0
const IPV4 = address.ip()
const IPV6 = address.ipv6()
class Span extends opentracing.Span {
constructor (tracer, spanOptions = {}) {
super()
this.TRACER = tracer
this._startTime = spanOptions.startTime || Date.now()
this._finishTime = null
this._tags = spanOptions.tags || {}
this._references = spanOptions.references || []
this._parentSpanContext = null
// for test
this.CONTEXT = spanOptions.context
if (!this.CONTEXT && this._references.length > 0) {
function resolveLoopback(proxy) {
const o = url.parse(proxy);
o.host = undefined;
if (o.hostname !== 'localhost') {
return proxy;
}
try {
o.hostname = address.ipv6() ? '::1' : '127.0.0.1';
} catch (_ignored) {
o.hostname = '127.0.0.1';
}
return url.format(o);
}
exports.getIPv6 = function (interfaceName) {
return address.ipv6(interfaceName);
};