Comparing version 0.0.20200909 to 0.0.20210203
@@ -0,7 +1,8 @@ | ||
import { __importDefault, __importStar } from "tslib"; | ||
import { Data, Interest, Nack } from "@ndn/packet"; | ||
import { toHex } from "@ndn/tlv"; | ||
import { EventEmitter } from "events"; | ||
import MultiSet from "mnemonist/multi-set"; | ||
import pDefer from "p-defer"; | ||
import Fifo from "p-fifo"; | ||
import _cjsDefaultImport0 from "mnemonist/multi-set.js"; const MultiSet = __importDefault(_cjsDefaultImport0).default; | ||
import _cjsDefaultImport1 from "p-defer"; const pDefer = __importDefault(_cjsDefaultImport1).default; | ||
import _cjsDefaultImport2 from "p-fifo"; const Fifo = __importDefault(_cjsDefaultImport2).default; | ||
import { buffer, filter, pipeline, tap } from "streaming-iterables"; | ||
@@ -87,2 +88,6 @@ const STOP = Symbol("FaceImpl.Stop"); | ||
} | ||
/** Determine if a route is present on the face. */ | ||
hasRoute(name) { | ||
return this.routes.has(toHex(name.value)); | ||
} | ||
/** Add a route toward the face. */ | ||
@@ -89,0 +94,0 @@ addRoute(name, announcement = true) { |
@@ -1,11 +0,9 @@ | ||
import { createRequire } from "module"; | ||
const require = createRequire(import.meta.url); | ||
const { __importDefault } = require("tslib"); | ||
import { __importDefault, __importStar } from "tslib"; | ||
import { Data, Interest, Nack } from "@ndn/packet"; | ||
import { toHex } from "@ndn/tlv"; | ||
import { EventEmitter } from "events"; | ||
const MultiSet = __importDefault(require("mnemonist/multi-set")).default; | ||
const pDefer = __importDefault(require("p-defer")).default; | ||
const Fifo = __importDefault(require("p-fifo")).default; | ||
const { buffer, filter, pipeline, tap } = require("streaming-iterables"); | ||
import _cjsDefaultImport0 from "mnemonist/multi-set.js"; const MultiSet = __importDefault(_cjsDefaultImport0).default; | ||
import _cjsDefaultImport1 from "p-defer"; const pDefer = __importDefault(_cjsDefaultImport1).default; | ||
import _cjsDefaultImport2 from "p-fifo"; const Fifo = __importDefault(_cjsDefaultImport2).default; | ||
import { buffer, filter, pipeline, tap } from "streaming-iterables"; | ||
const STOP = Symbol("FaceImpl.Stop"); | ||
@@ -90,2 +88,6 @@ function computeAnnouncement(name, announcement) { | ||
} | ||
/** Determine if a route is present on the face. */ | ||
hasRoute(name) { | ||
return this.routes.has(toHex(name.value)); | ||
} | ||
/** Add a route toward the face. */ | ||
@@ -92,0 +94,0 @@ addRoute(name, announcement = true) { |
import { Name } from "@ndn/packet"; | ||
import TypedEmitter from "typed-emitter"; | ||
import type TypedEmitter from "typed-emitter"; | ||
import type { Forwarder, ForwarderImpl } from "./forwarder"; | ||
@@ -23,2 +23,4 @@ import type { FwPacket } from "./packet"; | ||
toString(): string; | ||
/** Determine if a route is present on the face. */ | ||
hasRoute(name: Name): boolean; | ||
/** Add a route toward the face. */ | ||
@@ -45,3 +47,3 @@ addRoute(name: Name, announcement?: FwFace.RouteAnnouncement): void; | ||
/** A socket or network interface associated with forwarding plane. */ | ||
export interface FwFace extends Pick<FaceImpl, "attributes" | "close" | "toString" | "addRoute" | "removeRoute" | "addAnnouncement" | "removeAnnouncement" | Exclude<keyof TypedEmitter<Events>, "emit">> { | ||
export interface FwFace extends Pick<FaceImpl, "attributes" | "close" | "toString" | "hasRoute" | "addRoute" | "removeRoute" | "addAnnouncement" | "removeAnnouncement" | Exclude<keyof TypedEmitter<Events>, "emit">> { | ||
readonly fw: Forwarder; | ||
@@ -48,0 +50,0 @@ readonly running: boolean; |
@@ -1,4 +0,5 @@ | ||
import { toHex } from "@ndn/tlv"; | ||
import assert from "minimalistic-assert"; | ||
import DefaultMap from "mnemonist/default-map"; | ||
import { __importDefault, __importStar } from "tslib"; | ||
import { lpm } from "@ndn/packet"; | ||
import _cjsDefaultImport0 from "minimalistic-assert"; const assert = __importDefault(_cjsDefaultImport0).default; | ||
import _cjsDefaultImport1 from "mnemonist/default-map.js"; const DefaultMap = __importDefault(_cjsDefaultImport1).default; | ||
class FibEntry { | ||
@@ -26,18 +27,8 @@ constructor() { | ||
lpm(name) { | ||
const prefixStrs = [""]; | ||
let s = ""; | ||
for (let i = 0; i < name.length; ++i) { | ||
s += toHex(name.get(i).tlv); | ||
prefixStrs.push(s); | ||
const entry = lpm(name, (prefixHex) => this.table.peek(prefixHex)); | ||
if (entry) { | ||
assert(entry.nexthops.size > 0); | ||
} | ||
for (let prefixLen = name.length; prefixLen >= 0; --prefixLen) { | ||
const prefixStr = prefixStrs.pop(); | ||
const entry = this.table.peek(prefixStr); | ||
if (entry) { | ||
assert(entry.nexthops.size > 0); | ||
return entry; | ||
} | ||
} | ||
return undefined; | ||
return entry; | ||
} | ||
} |
@@ -1,7 +0,5 @@ | ||
import { createRequire } from "module"; | ||
const require = createRequire(import.meta.url); | ||
const { __importDefault } = require("tslib"); | ||
import { toHex } from "@ndn/tlv"; | ||
const assert = __importDefault(require("minimalistic-assert")).default; | ||
const DefaultMap = __importDefault(require("mnemonist/default-map")).default; | ||
import { __importDefault, __importStar } from "tslib"; | ||
import { lpm } from "@ndn/packet"; | ||
import _cjsDefaultImport0 from "minimalistic-assert"; const assert = __importDefault(_cjsDefaultImport0).default; | ||
import _cjsDefaultImport1 from "mnemonist/default-map.js"; const DefaultMap = __importDefault(_cjsDefaultImport1).default; | ||
class FibEntry { | ||
@@ -29,18 +27,8 @@ constructor() { | ||
lpm(name) { | ||
const prefixStrs = [""]; | ||
let s = ""; | ||
for (let i = 0; i < name.length; ++i) { | ||
s += toHex(name.get(i).tlv); | ||
prefixStrs.push(s); | ||
const entry = lpm(name, (prefixHex) => this.table.peek(prefixHex)); | ||
if (entry) { | ||
assert(entry.nexthops.size > 0); | ||
} | ||
for (let prefixLen = name.length; prefixLen >= 0; --prefixLen) { | ||
const prefixStr = prefixStrs.pop(); | ||
const entry = this.table.peek(prefixStr); | ||
if (entry) { | ||
assert(entry.nexthops.size > 0); | ||
return entry; | ||
} | ||
} | ||
return undefined; | ||
return entry; | ||
} | ||
} |
import { Name } from "@ndn/packet"; | ||
import DefaultMap from "mnemonist/default-map"; | ||
import DefaultMap from "mnemonist/default-map.js"; | ||
import type { FaceImpl } from "./face"; | ||
@@ -4,0 +4,0 @@ declare class FibEntry { |
import { Data, Interest, Nack, Name } from "@ndn/packet"; | ||
import TypedEmitter from "typed-emitter"; | ||
import type TypedEmitter from "typed-emitter"; | ||
import { FaceImpl, FwFace } from "./face"; | ||
@@ -4,0 +4,0 @@ import { Fib } from "./fib"; |
@@ -30,4 +30,4 @@ import type { Data, Interest, Nack } from "@ndn/packet"; | ||
constructor(l3: Interest, token?: unknown); | ||
cancel: boolean; | ||
readonly cancel = true; | ||
} | ||
export {}; |
@@ -0,5 +1,6 @@ | ||
import { __importDefault, __importStar } from "tslib"; | ||
import { Interest } from "@ndn/packet"; | ||
import { toHex } from "@ndn/tlv"; | ||
import hirestime from "hirestime"; | ||
import DefaultMap from "mnemonist/default-map"; | ||
import _cjsDefaultImport0 from "hirestime"; const hirestime = __importDefault(_cjsDefaultImport0).default; | ||
import _cjsDefaultImport1 from "mnemonist/default-map.js"; const DefaultMap = __importDefault(_cjsDefaultImport1).default; | ||
import { filter, flatMap, pipeline, reduce, tap } from "streaming-iterables"; | ||
@@ -50,4 +51,7 @@ import { FwPacket, RejectInterest } from "./packet_browser.js"; | ||
forwardInterest(face) { | ||
const now = getNow(); | ||
this.interest.lifetime = this.lastExpire - now; | ||
const lifetime = this.lastExpire - getNow(); | ||
if (lifetime <= 0) { | ||
return; | ||
} | ||
this.interest.lifetime = lifetime; | ||
face.send(FwPacket.create(this.interest, this.token)); | ||
@@ -113,6 +117,5 @@ } | ||
insertEntry(entry) { | ||
var _a; | ||
this.byName.set(entry.key, entry); | ||
if (!entry.token) { | ||
entry.token = this.generateToken(); | ||
} | ||
(_a = entry.token) !== null && _a !== void 0 ? _a : (entry.token = this.generateToken()); | ||
this.byToken.set(entry.token, entry); | ||
@@ -137,6 +140,3 @@ } | ||
async satisfy(face, { l3: data, token }) { | ||
const nSentData = await pipeline(() => this.findPotentialMatches(data, token), filter(({ interest }) => data.canSatisfy(interest)), flatMap((entry) => entry.returnData(face)), tap(({ dn, token: dnToken }) => { | ||
dn.send(FwPacket.create(data, dnToken)); | ||
// this Promise resolves when packet is sent, don't wait for it | ||
}), reduce((count) => count + 1, 0)); | ||
const nSentData = await pipeline(() => this.findPotentialMatches(data, token), filter(({ interest }) => data.canSatisfy(interest)), flatMap((entry) => entry.returnData(face)), tap(({ dn, token: dnToken }) => dn.send(FwPacket.create(data, dnToken))), reduce((count) => count + 1, 0)); | ||
return nSentData > 0; | ||
@@ -143,0 +143,0 @@ } |
@@ -1,9 +0,7 @@ | ||
import { createRequire } from "module"; | ||
const require = createRequire(import.meta.url); | ||
const { __importDefault } = require("tslib"); | ||
import { __importDefault, __importStar } from "tslib"; | ||
import { Interest } from "@ndn/packet"; | ||
import { toHex } from "@ndn/tlv"; | ||
const hirestime = __importDefault(require("hirestime")).default; | ||
const DefaultMap = __importDefault(require("mnemonist/default-map")).default; | ||
const { filter, flatMap, pipeline, reduce, tap } = require("streaming-iterables"); | ||
import _cjsDefaultImport0 from "hirestime"; const hirestime = __importDefault(_cjsDefaultImport0).default; | ||
import _cjsDefaultImport1 from "mnemonist/default-map.js"; const DefaultMap = __importDefault(_cjsDefaultImport1).default; | ||
import { filter, flatMap, pipeline, reduce, tap } from "streaming-iterables"; | ||
import { FwPacket, RejectInterest } from "./packet_node.js"; | ||
@@ -53,4 +51,7 @@ const getNow = hirestime(); | ||
forwardInterest(face) { | ||
const now = getNow(); | ||
this.interest.lifetime = this.lastExpire - now; | ||
const lifetime = this.lastExpire - getNow(); | ||
if (lifetime <= 0) { | ||
return; | ||
} | ||
this.interest.lifetime = lifetime; | ||
face.send(FwPacket.create(this.interest, this.token)); | ||
@@ -116,6 +117,5 @@ } | ||
insertEntry(entry) { | ||
var _a; | ||
this.byName.set(entry.key, entry); | ||
if (!entry.token) { | ||
entry.token = this.generateToken(); | ||
} | ||
(_a = entry.token) !== null && _a !== void 0 ? _a : (entry.token = this.generateToken()); | ||
this.byToken.set(entry.token, entry); | ||
@@ -140,6 +140,3 @@ } | ||
async satisfy(face, { l3: data, token }) { | ||
const nSentData = await pipeline(() => this.findPotentialMatches(data, token), filter(({ interest }) => data.canSatisfy(interest)), flatMap((entry) => entry.returnData(face)), tap(({ dn, token: dnToken }) => { | ||
dn.send(FwPacket.create(data, dnToken)); | ||
// this Promise resolves when packet is sent, don't wait for it | ||
}), reduce((count) => count + 1, 0)); | ||
const nSentData = await pipeline(() => this.findPotentialMatches(data, token), filter(({ interest }) => data.canSatisfy(interest)), flatMap((entry) => entry.returnData(face)), tap(({ dn, token: dnToken }) => dn.send(FwPacket.create(data, dnToken))), reduce((count) => count + 1, 0)); | ||
return nSentData > 0; | ||
@@ -146,0 +143,0 @@ } |
/// <reference types="node" /> | ||
import { Data, Interest } from "@ndn/packet"; | ||
import DefaultMap from "mnemonist/default-map"; | ||
import DefaultMap from "mnemonist/default-map.js"; | ||
import type { FaceImpl } from "./face"; | ||
@@ -5,0 +5,0 @@ import { FwPacket } from "./packet"; |
@@ -0,6 +1,7 @@ | ||
import { __importDefault, __importStar } from "tslib"; | ||
import { Name } from "@ndn/packet"; | ||
import { fromHex } from "@ndn/tlv"; | ||
import pushable from "it-pushable"; | ||
import MultiMap from "mnemonist/multi-map"; | ||
import * as retry from "retry"; | ||
import _cjsDefaultImport0 from "it-pushable"; const pushable = __importDefault(_cjsDefaultImport0).default; | ||
import _cjsDefaultImport1 from "mnemonist/multi-map.js"; const MultiMap = __importDefault(_cjsDefaultImport1).default; | ||
import _cjsDefaultImport2 from "retry"; const retry = __importDefault(_cjsDefaultImport2).default; | ||
/** | ||
@@ -34,3 +35,3 @@ * Manage advertised prefix of the forwarder. | ||
} | ||
name = name !== null && name !== void 0 ? name : new Name(fromHex(nameHex)); | ||
name !== null && name !== void 0 ? name : (name = new Name(fromHex(nameHex))); | ||
this.fw.emit("annrm", name); | ||
@@ -37,0 +38,0 @@ for (const dest of this.destinations) { |
@@ -1,9 +0,7 @@ | ||
import { createRequire } from "module"; | ||
const require = createRequire(import.meta.url); | ||
const { __importDefault } = require("tslib"); | ||
import { __importDefault, __importStar } from "tslib"; | ||
import { Name } from "@ndn/packet"; | ||
import { fromHex } from "@ndn/tlv"; | ||
const pushable = __importDefault(require("it-pushable")).default; | ||
const MultiMap = __importDefault(require("mnemonist/multi-map")).default; | ||
const retry = __importDefault(require("retry")).default; | ||
import _cjsDefaultImport0 from "it-pushable"; const pushable = __importDefault(_cjsDefaultImport0).default; | ||
import _cjsDefaultImport1 from "mnemonist/multi-map.js"; const MultiMap = __importDefault(_cjsDefaultImport1).default; | ||
import _cjsDefaultImport2 from "retry"; const retry = __importDefault(_cjsDefaultImport2).default; | ||
/** | ||
@@ -37,3 +35,3 @@ * Manage advertised prefix of the forwarder. | ||
} | ||
name = name !== null && name !== void 0 ? name : new Name(fromHex(nameHex)); | ||
name !== null && name !== void 0 ? name : (name = new Name(fromHex(nameHex))); | ||
this.fw.emit("annrm", name); | ||
@@ -40,0 +38,0 @@ for (const dest of this.destinations) { |
import { Name } from "@ndn/packet"; | ||
import MultiMap from "mnemonist/multi-map"; | ||
import MultiMap from "mnemonist/multi-map.js"; | ||
import * as retry from "retry"; | ||
@@ -4,0 +4,0 @@ import type { FaceImpl } from "./face"; |
@@ -1,5 +0,6 @@ | ||
import pushable from "it-pushable"; | ||
import assert from "minimalistic-assert"; | ||
import DefaultWeakMap from "mnemonist/default-weak-map"; | ||
import MultiMap from "mnemonist/multi-map"; | ||
import { __importDefault, __importStar } from "tslib"; | ||
import _cjsDefaultImport0 from "it-pushable"; const pushable = __importDefault(_cjsDefaultImport0).default; | ||
import _cjsDefaultImport1 from "minimalistic-assert"; const assert = __importDefault(_cjsDefaultImport1).default; | ||
import _cjsDefaultImport2 from "mnemonist/default-weak-map.js"; const DefaultWeakMap = __importDefault(_cjsDefaultImport2).default; | ||
import _cjsDefaultImport3 from "mnemonist/multi-map.js"; const MultiMap = __importDefault(_cjsDefaultImport3).default; | ||
import { Forwarder } from "./forwarder_browser.js"; | ||
@@ -6,0 +7,0 @@ class TapRxController { |
@@ -1,8 +0,6 @@ | ||
import { createRequire } from "module"; | ||
const require = createRequire(import.meta.url); | ||
const { __importDefault } = require("tslib"); | ||
const pushable = __importDefault(require("it-pushable")).default; | ||
const assert = __importDefault(require("minimalistic-assert")).default; | ||
const DefaultWeakMap = __importDefault(require("mnemonist/default-weak-map")).default; | ||
const MultiMap = __importDefault(require("mnemonist/multi-map")).default; | ||
import { __importDefault, __importStar } from "tslib"; | ||
import _cjsDefaultImport0 from "it-pushable"; const pushable = __importDefault(_cjsDefaultImport0).default; | ||
import _cjsDefaultImport1 from "minimalistic-assert"; const assert = __importDefault(_cjsDefaultImport1).default; | ||
import _cjsDefaultImport2 from "mnemonist/default-weak-map.js"; const DefaultWeakMap = __importDefault(_cjsDefaultImport2).default; | ||
import _cjsDefaultImport3 from "mnemonist/multi-map.js"; const MultiMap = __importDefault(_cjsDefaultImport3).default; | ||
import { Forwarder } from "./forwarder_node.js"; | ||
@@ -9,0 +7,0 @@ class TapRxController { |
import { Data, Interest, Nack } from "@ndn/packet"; | ||
import log from "loglevel"; | ||
import { Forwarder } from "./forwarder_browser.js"; | ||
export const logger = log.getLogger("@ndn/fw"); | ||
logger.setLevel(log.levels.TRACE); | ||
import { makeTracerOutput } from "./tracer-output_browser.js"; | ||
/** Print trace logs from Forwarder events. */ | ||
export class Tracer { | ||
constructor(opts) { | ||
var _a; | ||
constructor({ output = makeTracerOutput(), fw = Forwarder.getDefault(), face = true, prefix = true, ann = true, pkt = true, }) { | ||
this.faceadd = (face) => { | ||
logger.debug(`+Face ${face}`); | ||
this.output.log(`+Face ${face}`); | ||
}; | ||
this.facerm = (face) => { | ||
logger.debug(`-Face ${face}`); | ||
this.output.log(`-Face ${face}`); | ||
}; | ||
this.prefixadd = (face, prefix) => { | ||
logger.debug(`${face} +Prefix ${prefix}`); | ||
this.output.log(`${face} +Prefix ${prefix}`); | ||
}; | ||
this.prefixrm = (face, prefix) => { | ||
logger.debug(`${face} -Prefix ${prefix}`); | ||
this.output.log(`${face} -Prefix ${prefix}`); | ||
}; | ||
this.annadd = (name) => { | ||
logger.debug(`+Announcement ${name}`); | ||
this.output.log(`+Announcement ${name}`); | ||
}; | ||
this.annrm = (name) => { | ||
logger.debug(`-Announcement ${name}`); | ||
this.output.log(`-Announcement ${name}`); | ||
}; | ||
@@ -33,5 +31,6 @@ this.pktrx = (face, pkt) => { | ||
}; | ||
this.fw = (_a = opts.fw) !== null && _a !== void 0 ? _a : Forwarder.getDefault(); | ||
this.output = output; | ||
this.fw = fw; | ||
/* istanbul ignore else */ | ||
if (opts.face !== false) { | ||
if (face) { | ||
this.fw.on("faceadd", this.faceadd); | ||
@@ -41,3 +40,3 @@ this.fw.on("facerm", this.facerm); | ||
/* istanbul ignore else */ | ||
if (opts.prefix !== false) { | ||
if (prefix) { | ||
this.fw.on("prefixadd", this.prefixadd); | ||
@@ -47,3 +46,3 @@ this.fw.on("prefixrm", this.prefixrm); | ||
/* istanbul ignore else */ | ||
if (opts.ann !== false) { | ||
if (ann) { | ||
this.fw.on("annadd", this.annadd); | ||
@@ -53,3 +52,3 @@ this.fw.on("annrm", this.annrm); | ||
/* istanbul ignore else */ | ||
if (opts.pkt !== false) { | ||
if (pkt) { | ||
this.fw.on("pktrx", this.pktrx); | ||
@@ -78,3 +77,3 @@ this.fw.on("pkttx", this.pkttx); | ||
"I"; | ||
logger.debug(`${face} ${dir}${act} ${interestToString(pkt.l3)}`); | ||
this.output.log(`${face} ${dir}${act} ${interestToString(pkt.l3)}`); | ||
break; | ||
@@ -84,3 +83,3 @@ } | ||
const { name } = pkt.l3; | ||
logger.debug(`${face} ${dir}D ${name}`); | ||
this.output.log(`${face} ${dir}D ${name}`); | ||
break; | ||
@@ -90,3 +89,3 @@ } | ||
const { interest, reason } = pkt.l3; | ||
logger.debug(`${face} ${dir}N ${interestToString(interest)}~${reason}`); | ||
this.output.log(`${face} ${dir}N ${interestToString(interest)}~${reason}`); | ||
break; | ||
@@ -100,4 +99,1 @@ } | ||
} | ||
(function (Tracer) { | ||
Tracer.internalLogger = logger; | ||
})(Tracer || (Tracer = {})); |
@@ -1,29 +0,24 @@ | ||
import { createRequire } from "module"; | ||
const require = createRequire(import.meta.url); | ||
const { __importDefault } = require("tslib"); | ||
import { Data, Interest, Nack } from "@ndn/packet"; | ||
const log = __importDefault(require("loglevel")).default; | ||
import { Forwarder } from "./forwarder_node.js"; | ||
export const logger = log.getLogger("@ndn/fw"); | ||
logger.setLevel(log.levels.TRACE); | ||
import { makeTracerOutput } from "./tracer-output_node.js"; | ||
/** Print trace logs from Forwarder events. */ | ||
export class Tracer { | ||
constructor(opts) { | ||
var _a; | ||
constructor({ output = makeTracerOutput(), fw = Forwarder.getDefault(), face = true, prefix = true, ann = true, pkt = true, }) { | ||
this.faceadd = (face) => { | ||
logger.debug(`+Face ${face}`); | ||
this.output.log(`+Face ${face}`); | ||
}; | ||
this.facerm = (face) => { | ||
logger.debug(`-Face ${face}`); | ||
this.output.log(`-Face ${face}`); | ||
}; | ||
this.prefixadd = (face, prefix) => { | ||
logger.debug(`${face} +Prefix ${prefix}`); | ||
this.output.log(`${face} +Prefix ${prefix}`); | ||
}; | ||
this.prefixrm = (face, prefix) => { | ||
logger.debug(`${face} -Prefix ${prefix}`); | ||
this.output.log(`${face} -Prefix ${prefix}`); | ||
}; | ||
this.annadd = (name) => { | ||
logger.debug(`+Announcement ${name}`); | ||
this.output.log(`+Announcement ${name}`); | ||
}; | ||
this.annrm = (name) => { | ||
logger.debug(`-Announcement ${name}`); | ||
this.output.log(`-Announcement ${name}`); | ||
}; | ||
@@ -36,5 +31,6 @@ this.pktrx = (face, pkt) => { | ||
}; | ||
this.fw = (_a = opts.fw) !== null && _a !== void 0 ? _a : Forwarder.getDefault(); | ||
this.output = output; | ||
this.fw = fw; | ||
/* istanbul ignore else */ | ||
if (opts.face !== false) { | ||
if (face) { | ||
this.fw.on("faceadd", this.faceadd); | ||
@@ -44,3 +40,3 @@ this.fw.on("facerm", this.facerm); | ||
/* istanbul ignore else */ | ||
if (opts.prefix !== false) { | ||
if (prefix) { | ||
this.fw.on("prefixadd", this.prefixadd); | ||
@@ -50,3 +46,3 @@ this.fw.on("prefixrm", this.prefixrm); | ||
/* istanbul ignore else */ | ||
if (opts.ann !== false) { | ||
if (ann) { | ||
this.fw.on("annadd", this.annadd); | ||
@@ -56,3 +52,3 @@ this.fw.on("annrm", this.annrm); | ||
/* istanbul ignore else */ | ||
if (opts.pkt !== false) { | ||
if (pkt) { | ||
this.fw.on("pktrx", this.pktrx); | ||
@@ -81,3 +77,3 @@ this.fw.on("pkttx", this.pkttx); | ||
"I"; | ||
logger.debug(`${face} ${dir}${act} ${interestToString(pkt.l3)}`); | ||
this.output.log(`${face} ${dir}${act} ${interestToString(pkt.l3)}`); | ||
break; | ||
@@ -87,3 +83,3 @@ } | ||
const { name } = pkt.l3; | ||
logger.debug(`${face} ${dir}D ${name}`); | ||
this.output.log(`${face} ${dir}D ${name}`); | ||
break; | ||
@@ -93,3 +89,3 @@ } | ||
const { interest, reason } = pkt.l3; | ||
logger.debug(`${face} ${dir}N ${interestToString(interest)}~${reason}`); | ||
this.output.log(`${face} ${dir}N ${interestToString(interest)}~${reason}`); | ||
break; | ||
@@ -103,4 +99,1 @@ } | ||
} | ||
(function (Tracer) { | ||
Tracer.internalLogger = logger; | ||
})(Tracer || (Tracer = {})); |
@@ -1,15 +0,8 @@ | ||
import log from "loglevel"; | ||
import { Forwarder } from "./forwarder"; | ||
export declare const logger: log.Logger; | ||
interface Options { | ||
fw?: Forwarder; | ||
face?: boolean; | ||
prefix?: boolean; | ||
ann?: boolean; | ||
pkt?: boolean; | ||
} | ||
/** Print trace logs from Forwarder events. */ | ||
export declare class Tracer { | ||
static enable(opts?: Options): Tracer; | ||
static enable(opts?: Tracer.Options): Tracer; | ||
private readonly output; | ||
private readonly fw; | ||
constructor(opts: Options); | ||
constructor({ output, fw, face, prefix, ann, pkt, }: Tracer.Options); | ||
disable(): void; | ||
@@ -27,4 +20,37 @@ private faceadd; | ||
export declare namespace Tracer { | ||
const internalLogger: log.Logger; | ||
interface Output { | ||
log(str: string): void; | ||
} | ||
interface Options { | ||
/** | ||
* Where to write log entries. | ||
* Default is stderr in Node and developer console in browser. | ||
*/ | ||
output?: Output; | ||
/** | ||
* Logical Forwarder instance. | ||
* @default Forwarder.getDefault() | ||
*/ | ||
fw?: Forwarder; | ||
/** | ||
* Whether to log face creations and deletions. | ||
* @default true | ||
*/ | ||
face?: boolean; | ||
/** | ||
* Whether to log prefix registrations. | ||
* @default true | ||
*/ | ||
prefix?: boolean; | ||
/** | ||
* Whether to log prefix announcements. | ||
* @default true | ||
*/ | ||
ann?: boolean; | ||
/** | ||
* Whether to log packets. | ||
* @default true | ||
*/ | ||
pkt?: boolean; | ||
} | ||
} | ||
export {}; |
{ | ||
"name": "@ndn/fw", | ||
"version": "0.0.20200909", | ||
"version": "0.0.20210203", | ||
"description": "NDNts: Forwarding Plane", | ||
@@ -26,17 +26,16 @@ "keywords": [ | ||
"@types/retry": "^0.12.0", | ||
"@ndn/packet": "0.0.20200909", | ||
"@ndn/tlv": "0.0.20200909", | ||
"@ndn/packet": "0.0.20210203", | ||
"@ndn/tlv": "0.0.20210203", | ||
"hirestime": "^6.1.0", | ||
"it-pushable": "^1.4.0", | ||
"loglevel": "^1.7.0", | ||
"it-pushable": "1.4.0", | ||
"minimalistic-assert": "^1.0.1", | ||
"mnemonist": "^0.38.0", | ||
"mnemonist": "^0.38.1", | ||
"p-defer": "^3.0.0", | ||
"p-fifo": "^1.0.0", | ||
"retry": "^0.12.0", | ||
"streaming-iterables": "^5.0.2", | ||
"tslib": "^2.0.1", | ||
"typed-emitter": "^1.3.0" | ||
"streaming-iterables": "^5.0.4", | ||
"tslib": "^2.1.0", | ||
"typed-emitter": "^1.3.1" | ||
}, | ||
"types": "lib/mod.d.ts" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
77681
13
33
2055
0
0
+ Added@ndn/packet@0.0.20210203(transitive)
+ Added@ndn/tlv@0.0.20210203(transitive)
+ Addedit-pushable@1.4.0(transitive)
- Removedloglevel@^1.7.0
- Removed@ndn/packet@0.0.20200909(transitive)
- Removed@ndn/tlv@0.0.20200909(transitive)
- Removedit-pushable@1.4.2(transitive)
- Removedloglevel@1.9.2(transitive)
Updated@ndn/packet@0.0.20210203
Updated@ndn/tlv@0.0.20210203
Updatedit-pushable@1.4.0
Updatedmnemonist@^0.38.1
Updatedstreaming-iterables@^5.0.4
Updatedtslib@^2.1.0
Updatedtyped-emitter@^1.3.1