Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ndn/fw

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ndn/fw - npm Package Compare versions

Comparing version 0.0.20230121 to 0.0.20240113

35

lib/face_browser.js

@@ -1,2 +0,1 @@

import { EventEmitter } from "events";
import { Data, Interest, Nack, Name, NameMultiSet } from "@ndn/packet";

@@ -6,2 +5,4 @@ import { safeIter } from "@ndn/util";

import { filter, pipeline, tap } from "streaming-iterables";
import { TypedEventTarget } from "typescript-event-target";
import { Forwarder } from "./forwarder_browser.js";
function duplexFromRxTx(rxtx) {

@@ -20,10 +21,12 @@ return (iterable) => {

switch (typeof announcement) {
case "number":
case "number": {
return name.getPrefix(announcement);
case "boolean":
}
case "boolean": {
return announcement ? name : undefined;
}
}
return Name.from(announcement);
}
export class FaceImpl extends EventEmitter {
export class FaceImpl extends TypedEventTarget {
fw;

@@ -47,7 +50,7 @@ rxtx;

};
fw.emit("faceadd", this);
fw.dispatchTypedEvent("faceadd", new Forwarder.FaceEvent("faceadd", this));
fw.faces.add(this);
void pipeline(() => this.txLoop(), tap((pkt) => fw.emit("pkttx", this, pkt)), duplexFromRxTx(rxtx), tap((pkt) => fw.emit("pktrx", this, pkt)), this.rxLoop);
rxtx.on?.("up", this.handleLowerUp);
rxtx.on?.("down", this.handleLowerDown);
void pipeline(() => this.txLoop(), tap((pkt) => fw.dispatchPacketEvent("pkttx", this, pkt)), duplexFromRxTx(rxtx), tap((pkt) => fw.dispatchPacketEvent("pktrx", this, pkt)), this.rxLoop);
rxtx.addEventListener?.("up", this.handleLowerUp);
rxtx.addEventListener?.("down", this.handleLowerDown);
}

@@ -59,4 +62,4 @@ close() {

this.running = false;
this.rxtx.off?.("up", this.handleLowerUp);
this.rxtx.off?.("down", this.handleLowerDown);
this.rxtx.removeEventListener?.("up", this.handleLowerUp);
this.rxtx.removeEventListener?.("down", this.handleLowerDown);
this.fw.faces.delete(this);

@@ -70,4 +73,4 @@ for (const [name] of this.routes.multiplicities()) {

this.txQueue.end(new Error("close"));
this.emit("close");
this.fw.emit("facerm", this);
this.dispatchTypedEvent("close", new Event("close"));
this.fw.dispatchTypedEvent("facerm", new Forwarder.FaceEvent("facerm", this));
}

@@ -83,3 +86,3 @@ toString() {

const name = Name.from(nameInput);
this.fw.emit("prefixadd", this, name);
this.fw.dispatchTypedEvent("prefixadd", new Forwarder.PrefixEvent("prefixadd", this, name));
if (this.routes.add(name) === 1) {

@@ -102,3 +105,3 @@ this.fw.fib.insert(this, name.valueHex, this.attributes.routeCapture);

}
this.fw.emit("prefixrm", this, name);
this.fw.dispatchTypedEvent("prefixrm", new Forwarder.PrefixEvent("prefixrm", this, name));
}

@@ -131,6 +134,6 @@ addAnnouncement(nameInput) {

handleLowerUp = () => {
this.emit("up");
this.dispatchTypedEvent("up", new Event("up"));
};
handleLowerDown = () => {
this.emit("down");
this.dispatchTypedEvent("down", new Event("down"));
};

@@ -137,0 +140,0 @@ rxLoop = async (input) => {

@@ -1,2 +0,1 @@

import { EventEmitter } from "node:events";
import { Data, Interest, Nack, Name, NameMultiSet } from "@ndn/packet";

@@ -6,2 +5,4 @@ import { safeIter } from "@ndn/util";

import { filter, pipeline, tap } from "streaming-iterables";
import { TypedEventTarget } from "typescript-event-target";
import { Forwarder } from "./forwarder_node.js";
function duplexFromRxTx(rxtx) {

@@ -20,10 +21,12 @@ return (iterable) => {

switch (typeof announcement) {
case "number":
case "number": {
return name.getPrefix(announcement);
case "boolean":
}
case "boolean": {
return announcement ? name : undefined;
}
}
return Name.from(announcement);
}
export class FaceImpl extends EventEmitter {
export class FaceImpl extends TypedEventTarget {
fw;

@@ -47,7 +50,7 @@ rxtx;

};
fw.emit("faceadd", this);
fw.dispatchTypedEvent("faceadd", new Forwarder.FaceEvent("faceadd", this));
fw.faces.add(this);
void pipeline(() => this.txLoop(), tap((pkt) => fw.emit("pkttx", this, pkt)), duplexFromRxTx(rxtx), tap((pkt) => fw.emit("pktrx", this, pkt)), this.rxLoop);
rxtx.on?.("up", this.handleLowerUp);
rxtx.on?.("down", this.handleLowerDown);
void pipeline(() => this.txLoop(), tap((pkt) => fw.dispatchPacketEvent("pkttx", this, pkt)), duplexFromRxTx(rxtx), tap((pkt) => fw.dispatchPacketEvent("pktrx", this, pkt)), this.rxLoop);
rxtx.addEventListener?.("up", this.handleLowerUp);
rxtx.addEventListener?.("down", this.handleLowerDown);
}

@@ -59,4 +62,4 @@ close() {

this.running = false;
this.rxtx.off?.("up", this.handleLowerUp);
this.rxtx.off?.("down", this.handleLowerDown);
this.rxtx.removeEventListener?.("up", this.handleLowerUp);
this.rxtx.removeEventListener?.("down", this.handleLowerDown);
this.fw.faces.delete(this);

@@ -70,4 +73,4 @@ for (const [name] of this.routes.multiplicities()) {

this.txQueue.end(new Error("close"));
this.emit("close");
this.fw.emit("facerm", this);
this.dispatchTypedEvent("close", new Event("close"));
this.fw.dispatchTypedEvent("facerm", new Forwarder.FaceEvent("facerm", this));
}

@@ -83,3 +86,3 @@ toString() {

const name = Name.from(nameInput);
this.fw.emit("prefixadd", this, name);
this.fw.dispatchTypedEvent("prefixadd", new Forwarder.PrefixEvent("prefixadd", this, name));
if (this.routes.add(name) === 1) {

@@ -102,3 +105,3 @@ this.fw.fib.insert(this, name.valueHex, this.attributes.routeCapture);

}
this.fw.emit("prefixrm", this, name);
this.fw.dispatchTypedEvent("prefixrm", new Forwarder.PrefixEvent("prefixrm", this, name));
}

@@ -131,6 +134,6 @@ addAnnouncement(nameInput) {

handleLowerUp = () => {
this.emit("up");
this.dispatchTypedEvent("up", new Event("up"));
};
handleLowerDown = () => {
this.emit("down");
this.dispatchTypedEvent("down", new Event("down"));
};

@@ -137,0 +140,0 @@ rxLoop = async (input) => {

import { type NameLike } from "@ndn/packet";
import type TypedEmitter from "typed-emitter";
import type { Forwarder, ForwarderImpl } from "./forwarder.js";
import { TypedEventTarget } from "typescript-event-target";
import { Forwarder, type ForwarderImpl } from "./forwarder.js";
import type { FwPacket } from "./packet.js";
type Events = {
type EventMap = {
/** Emitted upon face is up as reported by lower layer. */
up: () => void;
up: Event;
/** Emitted upon face is down as reported by lower layer. */
down: () => void;
down: Event;
/** Emitted upon face is closed. */
close: () => void;
close: Event;
};
/** A socket or network interface associated with forwarding plane. */
export interface FwFace extends TypedEmitter<Events> {
export interface FwFace extends TypedEventTarget<EventMap> {
readonly fw: Forwarder;

@@ -33,3 +33,3 @@ readonly attributes: FwFace.Attributes;

export declare namespace FwFace {
interface Attributes extends Record<string, any> {
interface Attributes extends Record<string, unknown> {
/** Short string to identify the face. */

@@ -49,10 +49,7 @@ describe?: string;

type RouteAnnouncement = boolean | number | NameLike;
type RxTxEvents = {
up: () => void;
down: () => void;
};
type RxTxEventMap = Pick<EventMap, "up" | "down">;
interface RxTxBase {
readonly attributes?: Attributes;
on?: (...args: Parameters<TypedEmitter<RxTxEvents>["on"]>) => void;
off?: (...args: Parameters<TypedEmitter<RxTxEvents>["off"]>) => void;
addEventListener?: <K extends keyof RxTxEventMap>(type: K, listener: (ev: RxTxEventMap[K]) => any, options?: AddEventListenerOptions) => void;
removeEventListener?: <K extends keyof RxTxEventMap>(type: K, listener: (ev: RxTxEventMap[K]) => any, options?: EventListenerOptions) => void;
}

@@ -71,4 +68,3 @@ interface RxTx extends RxTxBase {

}
declare const FaceImpl_base: new () => TypedEmitter<Events>;
export declare class FaceImpl extends FaceImpl_base implements FwFace {
export declare class FaceImpl extends TypedEventTarget<EventMap> implements FwFace {
readonly fw: ForwarderImpl;

@@ -75,0 +71,0 @@ private readonly rxtx;

@@ -1,2 +0,3 @@

import { EventEmitter } from "events";
import { trackEventListener } from "@ndn/util";
import { TypedEventTarget } from "typescript-event-target";
import { FaceImpl } from "./face_browser.js";

@@ -39,4 +40,44 @@ import { Fib } from "./fib_browser.js";

Forwarder.deleteDefault = deleteDefault;
/** Face event. */
class FaceEvent extends Event {
face;
constructor(type, face) {
super(type);
this.face = face;
}
}
Forwarder.FaceEvent = FaceEvent;
/** Prefix registration event. */
class PrefixEvent extends Event {
face;
prefix;
constructor(type, face, prefix) {
super(type);
this.face = face;
this.prefix = prefix;
}
}
Forwarder.PrefixEvent = PrefixEvent;
/** Prefix announcement event. */
class AnnouncementEvent extends Event {
name;
constructor(type, name) {
super(type);
this.name = name;
}
}
Forwarder.AnnouncementEvent = AnnouncementEvent;
/** Packet event. */
class PacketEvent extends Event {
face;
packet;
constructor(type, face, packet) {
super(type);
this.face = face;
this.packet = packet;
}
}
Forwarder.PacketEvent = PacketEvent;
})(Forwarder || (Forwarder = {}));
export class ForwarderImpl extends EventEmitter {
export class ForwarderImpl extends TypedEventTarget {
opts;

@@ -48,2 +89,3 @@ nodeNames = [];

readvertise = new Readvertise(this);
maybeHaveEventListener = trackEventListener(this);
constructor(opts) {

@@ -97,2 +139,7 @@ super();

}
dispatchPacketEvent(type, face, pkt) {
if (this.maybeHaveEventListener[type]) {
this.dispatchTypedEvent(type, new Forwarder.PacketEvent(type, face, pkt));
}
}
}

@@ -1,2 +0,3 @@

import { EventEmitter } from "node:events";
import { trackEventListener } from "@ndn/util";
import { TypedEventTarget } from "typescript-event-target";
import { FaceImpl } from "./face_node.js";

@@ -39,4 +40,44 @@ import { Fib } from "./fib_node.js";

Forwarder.deleteDefault = deleteDefault;
/** Face event. */
class FaceEvent extends Event {
face;
constructor(type, face) {
super(type);
this.face = face;
}
}
Forwarder.FaceEvent = FaceEvent;
/** Prefix registration event. */
class PrefixEvent extends Event {
face;
prefix;
constructor(type, face, prefix) {
super(type);
this.face = face;
this.prefix = prefix;
}
}
Forwarder.PrefixEvent = PrefixEvent;
/** Prefix announcement event. */
class AnnouncementEvent extends Event {
name;
constructor(type, name) {
super(type);
this.name = name;
}
}
Forwarder.AnnouncementEvent = AnnouncementEvent;
/** Packet event. */
class PacketEvent extends Event {
face;
packet;
constructor(type, face, packet) {
super(type);
this.face = face;
this.packet = packet;
}
}
Forwarder.PacketEvent = PacketEvent;
})(Forwarder || (Forwarder = {}));
export class ForwarderImpl extends EventEmitter {
export class ForwarderImpl extends TypedEventTarget {
opts;

@@ -48,2 +89,3 @@ nodeNames = [];

readvertise = new Readvertise(this);
maybeHaveEventListener = trackEventListener(this);
constructor(opts) {

@@ -97,2 +139,7 @@ super();

}
dispatchPacketEvent(type, face, pkt) {
if (this.maybeHaveEventListener[type]) {
this.dispatchTypedEvent(type, new Forwarder.PacketEvent(type, face, pkt));
}
}
}
import type { Data, Interest, Nack, Name } from "@ndn/packet";
import type TypedEmitter from "typed-emitter";
import { type FwFace, FaceImpl } from "./face.js";
import { TypedEventTarget } from "typescript-event-target";
import { FaceImpl, type FwFace } from "./face.js";
import { Fib } from "./fib.js";

@@ -8,22 +8,22 @@ import type { FwPacket } from "./packet.js";

import { Readvertise } from "./readvertise.js";
type Events = {
type EventMap = {
/** Emitted before adding face. */
faceadd: (face: FwFace) => void;
faceadd: Forwarder.FaceEvent;
/** Emitted after removing face. */
facerm: (face: FwFace) => void;
facerm: Forwarder.FaceEvent;
/** Emitted before adding prefix to face. */
prefixadd: (face: FwFace, prefix: Name) => void;
prefixadd: Forwarder.PrefixEvent;
/** Emitted after removing prefix from face. */
prefixrm: (face: FwFace, prefix: Name) => void;
prefixrm: Forwarder.PrefixEvent;
/** Emitted before advertising prefix. */
annadd: (announcement: Name) => void;
annadd: Forwarder.AnnouncementEvent;
/** Emitted before withdrawing prefix. */
annrm: (announcement: Name) => void;
annrm: Forwarder.AnnouncementEvent;
/** Emitted after packet arrival. */
pktrx: (face: FwFace, pkt: FwPacket) => void;
pktrx: Forwarder.PacketEvent;
/** Emitted before packet transmission. */
pkttx: (face: FwFace, pkt: FwPacket) => void;
pkttx: Forwarder.PacketEvent;
};
/** Forwarding plane. */
export interface Forwarder extends TypedEmitter<Events> {
export interface Forwarder extends TypedEventTarget<EventMap> {
/** Node names, used in forwarding hint processing. */

@@ -55,5 +55,26 @@ readonly nodeNames: Name[];

function deleteDefault(): void;
/** Face event. */
class FaceEvent extends Event {
readonly face: FwFace;
constructor(type: string, face: FwFace);
}
/** Prefix registration event. */
class PrefixEvent extends Event {
readonly face: FwFace;
readonly prefix: Name;
constructor(type: string, face: FwFace, prefix: Name);
}
/** Prefix announcement event. */
class AnnouncementEvent extends Event {
readonly name: Name;
constructor(type: string, name: Name);
}
/** Packet event. */
class PacketEvent extends Event {
readonly face: FwFace;
readonly packet: FwPacket;
constructor(type: string, face: FwFace, packet: FwPacket);
}
}
declare const ForwarderImpl_base: new () => TypedEmitter<Events>;
export declare class ForwarderImpl extends ForwarderImpl_base implements Forwarder {
export declare class ForwarderImpl extends TypedEventTarget<EventMap> implements Forwarder {
readonly opts: Required<Forwarder.Options>;

@@ -65,2 +86,3 @@ readonly nodeNames: Name[];

readonly readvertise: Readvertise;
private readonly maybeHaveEventListener;
constructor(opts: Required<Forwarder.Options>);

@@ -78,3 +100,4 @@ addFace(face: FwFace.RxTx | FwFace.RxTxDuplex, attributes?: FwFace.Attributes): FwFace;

close(): void;
dispatchPacketEvent(type: "pktrx" | "pkttx", face: FaceImpl, pkt: FwPacket): void;
}
export {};
export var FwPacket;
(function (FwPacket) {
function create(l3, token) {
return { l3, token };
function create(l3, token, congestionMark) {
return { l3, token, congestionMark };
}

@@ -6,0 +6,0 @@ FwPacket.create = create;

export var FwPacket;
(function (FwPacket) {
function create(l3, token) {
return { l3, token };
function create(l3, token, congestionMark) {
return { l3, token, congestionMark };
}

@@ -6,0 +6,0 @@ FwPacket.create = create;

@@ -7,2 +7,3 @@ import type { Data, Interest, Nack } from "@ndn/packet";

token?: unknown;
congestionMark?: number;
reject?: RejectInterest.Reason;

@@ -12,3 +13,3 @@ cancel?: boolean;

export declare namespace FwPacket {
function create<T extends L3Pkt>(l3: T, token?: unknown): FwPacket<T>;
function create<T extends L3Pkt>(l3: T, token?: unknown, congestionMark?: number): FwPacket<T>;
/** Whether this is a plain packet that can be sent on the wire. */

@@ -15,0 +16,0 @@ function isEncodable({ reject, cancel }: FwPacket): boolean;

@@ -30,3 +30,3 @@ /// <reference types="node" />

/** Entry expiration timer; should match this.lastExpire. */
expireTimer?: NodeJS.Timer | number;
expireTimer?: NodeJS.Timeout | number;
constructor(pit: Pit, key: string, interest: Interest);

@@ -33,0 +33,0 @@ /** Record Interest from downstream. */

@@ -5,2 +5,3 @@ import { __importDefault, __importStar } from "tslib";

import _cjsDefaultImport0 from "retry"; const retry = __importDefault(_cjsDefaultImport0).default;
import { Forwarder } from "./forwarder_browser.js";
/**

@@ -24,3 +25,3 @@ * Manage advertised prefix of the forwarder.

}
this.fw.emit("annadd", name);
this.fw.dispatchTypedEvent("annadd", new Forwarder.AnnouncementEvent("annadd", name));
for (const dest of this.destinations) {

@@ -34,3 +35,3 @@ dest.advertise(name);

}
this.fw.emit("annrm", name);
this.fw.dispatchTypedEvent("annrm", new Forwarder.AnnouncementEvent("annrm", name));
for (const dest of this.destinations) {

@@ -75,3 +76,3 @@ dest.withdraw(name);

for (const [name] of this.readvertise.announcements.associations()) {
this.queue.push(name);
this.advertise(name);
}

@@ -137,3 +138,3 @@ void this.process();

switch (status) {
case ReadvertiseDestination.Status.ADVERTISING:
case ReadvertiseDestination.Status.ADVERTISING: {
try {

@@ -150,3 +151,4 @@ await this.doAdvertise(name, state);

break;
case ReadvertiseDestination.Status.WITHDRAWING:
}
case ReadvertiseDestination.Status.WITHDRAWING: {
try {

@@ -164,2 +166,3 @@ await this.doWithdraw(name, state);

break;
}
}

@@ -166,0 +169,0 @@ }

@@ -5,2 +5,3 @@ import { __importDefault, __importStar } from "tslib";

import _cjsDefaultImport0 from "retry"; const retry = __importDefault(_cjsDefaultImport0).default;
import { Forwarder } from "./forwarder_node.js";
/**

@@ -24,3 +25,3 @@ * Manage advertised prefix of the forwarder.

}
this.fw.emit("annadd", name);
this.fw.dispatchTypedEvent("annadd", new Forwarder.AnnouncementEvent("annadd", name));
for (const dest of this.destinations) {

@@ -34,3 +35,3 @@ dest.advertise(name);

}
this.fw.emit("annrm", name);
this.fw.dispatchTypedEvent("annrm", new Forwarder.AnnouncementEvent("annrm", name));
for (const dest of this.destinations) {

@@ -75,3 +76,3 @@ dest.withdraw(name);

for (const [name] of this.readvertise.announcements.associations()) {
this.queue.push(name);
this.advertise(name);
}

@@ -137,3 +138,3 @@ void this.process();

switch (status) {
case ReadvertiseDestination.Status.ADVERTISING:
case ReadvertiseDestination.Status.ADVERTISING: {
try {

@@ -150,3 +151,4 @@ await this.doAdvertise(name, state);

break;
case ReadvertiseDestination.Status.WITHDRAWING:
}
case ReadvertiseDestination.Status.WITHDRAWING: {
try {

@@ -164,2 +166,3 @@ await this.doWithdraw(name, state);

break;
}
}

@@ -166,0 +169,0 @@ }

import { type Name, NameMap, NameMultiMap } from "@ndn/packet";
import * as retry from "retry";
import type { FaceImpl } from "./face.js";
import type { Forwarder, ForwarderImpl } from "./forwarder.js";
import { Forwarder, type ForwarderImpl } from "./forwarder.js";
/**

@@ -35,3 +35,3 @@ * Manage advertised prefix of the forwarder.

protected readonly table: NameMap<ReadvertiseDestination.Record<State>>;
protected readonly queue: import("it-pushable").Pushable<Name>;
protected readonly queue: import("it-pushable").Pushable<Name, void, unknown>;
protected closed: boolean;

@@ -38,0 +38,0 @@ constructor(retryOptions?: ReadvertiseDestination.RetryOptions);

@@ -15,4 +15,4 @@ import { __importDefault, __importStar } from "tslib";

this.fw = fw;
this.fw.on("pktrx", this.pktrx);
this.fw.on("facerm", this.facerm);
this.fw.addEventListener("pktrx", this.pktrx);
this.fw.addEventListener("facerm", this.facerm);
}

@@ -27,4 +27,4 @@ add(src, dst) {

}
facerm = (src) => {
const dst = this.taps.list(src);
facerm = (evt) => {
const dst = this.taps.list(evt.face);
for (const { rx } of dst) {

@@ -37,11 +37,11 @@ rx.end();

if (this.taps.size === 0) {
this.fw.off("pktrx", this.pktrx);
this.fw.off("facerm", this.facerm);
this.fw.removeEventListener("pktrx", this.pktrx);
this.fw.removeEventListener("facerm", this.facerm);
TapRxController.instances.delete(this.fw);
}
}
pktrx = (src, pkt) => {
const dst = this.taps.list(src);
pktrx = (evt) => {
const dst = this.taps.list(evt.face);
for (const { rx } of dst) {
rx.push(pkt);
rx.push(evt.packet);
}

@@ -48,0 +48,0 @@ };

@@ -15,4 +15,4 @@ import { __importDefault, __importStar } from "tslib";

this.fw = fw;
this.fw.on("pktrx", this.pktrx);
this.fw.on("facerm", this.facerm);
this.fw.addEventListener("pktrx", this.pktrx);
this.fw.addEventListener("facerm", this.facerm);
}

@@ -27,4 +27,4 @@ add(src, dst) {

}
facerm = (src) => {
const dst = this.taps.list(src);
facerm = (evt) => {
const dst = this.taps.list(evt.face);
for (const { rx } of dst) {

@@ -37,11 +37,11 @@ rx.end();

if (this.taps.size === 0) {
this.fw.off("pktrx", this.pktrx);
this.fw.off("facerm", this.facerm);
this.fw.removeEventListener("pktrx", this.pktrx);
this.fw.removeEventListener("facerm", this.facerm);
TapRxController.instances.delete(this.fw);
}
}
pktrx = (src, pkt) => {
const dst = this.taps.list(src);
pktrx = (evt) => {
const dst = this.taps.list(evt.face);
for (const { rx } of dst) {
rx.push(pkt);
rx.push(evt.packet);
}

@@ -48,0 +48,0 @@ };

@@ -19,3 +19,3 @@ import type { FwFace } from "./face.js";

};
readonly rx: import("it-pushable").Pushable<FwPacket<import("@ndn/packet").Interest | import("@ndn/packet").Data | import("@ndn/packet").Nack>>;
readonly rx: import("it-pushable").Pushable<FwPacket<import("@ndn/packet").Interest | import("@ndn/packet").Data | import("@ndn/packet").Nack>, void, unknown>;
private readonly ctrl;

@@ -22,0 +22,0 @@ constructor(face: FwFace);

@@ -15,51 +15,51 @@ import { Data, Interest, Nack } from "@ndn/packet";

if (face) {
this.fw.on("faceadd", this.faceadd);
this.fw.on("facerm", this.facerm);
this.fw.addEventListener("faceadd", this.faceadd);
this.fw.addEventListener("facerm", this.facerm);
}
if (prefix) {
this.fw.on("prefixadd", this.prefixadd);
this.fw.on("prefixrm", this.prefixrm);
this.fw.addEventListener("prefixadd", this.prefixadd);
this.fw.addEventListener("prefixrm", this.prefixrm);
}
if (ann) {
this.fw.on("annadd", this.annadd);
this.fw.on("annrm", this.annrm);
this.fw.addEventListener("annadd", this.annadd);
this.fw.addEventListener("annrm", this.annrm);
}
if (pkt) {
this.fw.on("pktrx", this.pktrx);
this.fw.on("pkttx", this.pkttx);
this.fw.addEventListener("pktrx", this.pktrx);
this.fw.addEventListener("pkttx", this.pkttx);
}
}
disable() {
this.fw.off("faceadd", this.faceadd);
this.fw.off("facerm", this.facerm);
this.fw.off("prefixadd", this.prefixadd);
this.fw.off("prefixrm", this.prefixrm);
this.fw.off("annadd", this.annadd);
this.fw.off("annrm", this.annrm);
this.fw.off("pktrx", this.pktrx);
this.fw.off("pkttx", this.pkttx);
this.fw.removeEventListener("faceadd", this.faceadd);
this.fw.removeEventListener("facerm", this.facerm);
this.fw.removeEventListener("prefixadd", this.prefixadd);
this.fw.removeEventListener("prefixrm", this.prefixrm);
this.fw.removeEventListener("annadd", this.annadd);
this.fw.removeEventListener("annrm", this.annrm);
this.fw.removeEventListener("pktrx", this.pktrx);
this.fw.removeEventListener("pkttx", this.pkttx);
}
faceadd = (face) => {
faceadd = ({ face }) => {
this.output.log(`+Face ${face}`);
};
facerm = (face) => {
facerm = ({ face }) => {
this.output.log(`-Face ${face}`);
};
prefixadd = (face, prefix) => {
prefixadd = ({ face, prefix }) => {
this.output.log(`${face} +Prefix ${prefix}`);
};
prefixrm = (face, prefix) => {
prefixrm = ({ face, prefix }) => {
this.output.log(`${face} -Prefix ${prefix}`);
};
annadd = (name) => {
annadd = ({ name }) => {
this.output.log(`+Announcement ${name}`);
};
annrm = (name) => {
annrm = ({ name }) => {
this.output.log(`-Announcement ${name}`);
};
pktrx = (face, pkt) => {
this.pkt(face, pkt, ">");
pktrx = ({ face, packet }) => {
this.pkt(face, packet, ">");
};
pkttx = (face, pkt) => {
this.pkt(face, pkt, "<");
pkttx = ({ face, packet }) => {
this.pkt(face, packet, "<");
};

@@ -66,0 +66,0 @@ pkt(face, pkt, dir) {

@@ -15,51 +15,51 @@ import { Data, Interest, Nack } from "@ndn/packet";

if (face) {
this.fw.on("faceadd", this.faceadd);
this.fw.on("facerm", this.facerm);
this.fw.addEventListener("faceadd", this.faceadd);
this.fw.addEventListener("facerm", this.facerm);
}
if (prefix) {
this.fw.on("prefixadd", this.prefixadd);
this.fw.on("prefixrm", this.prefixrm);
this.fw.addEventListener("prefixadd", this.prefixadd);
this.fw.addEventListener("prefixrm", this.prefixrm);
}
if (ann) {
this.fw.on("annadd", this.annadd);
this.fw.on("annrm", this.annrm);
this.fw.addEventListener("annadd", this.annadd);
this.fw.addEventListener("annrm", this.annrm);
}
if (pkt) {
this.fw.on("pktrx", this.pktrx);
this.fw.on("pkttx", this.pkttx);
this.fw.addEventListener("pktrx", this.pktrx);
this.fw.addEventListener("pkttx", this.pkttx);
}
}
disable() {
this.fw.off("faceadd", this.faceadd);
this.fw.off("facerm", this.facerm);
this.fw.off("prefixadd", this.prefixadd);
this.fw.off("prefixrm", this.prefixrm);
this.fw.off("annadd", this.annadd);
this.fw.off("annrm", this.annrm);
this.fw.off("pktrx", this.pktrx);
this.fw.off("pkttx", this.pkttx);
this.fw.removeEventListener("faceadd", this.faceadd);
this.fw.removeEventListener("facerm", this.facerm);
this.fw.removeEventListener("prefixadd", this.prefixadd);
this.fw.removeEventListener("prefixrm", this.prefixrm);
this.fw.removeEventListener("annadd", this.annadd);
this.fw.removeEventListener("annrm", this.annrm);
this.fw.removeEventListener("pktrx", this.pktrx);
this.fw.removeEventListener("pkttx", this.pkttx);
}
faceadd = (face) => {
faceadd = ({ face }) => {
this.output.log(`+Face ${face}`);
};
facerm = (face) => {
facerm = ({ face }) => {
this.output.log(`-Face ${face}`);
};
prefixadd = (face, prefix) => {
prefixadd = ({ face, prefix }) => {
this.output.log(`${face} +Prefix ${prefix}`);
};
prefixrm = (face, prefix) => {
prefixrm = ({ face, prefix }) => {
this.output.log(`${face} -Prefix ${prefix}`);
};
annadd = (name) => {
annadd = ({ name }) => {
this.output.log(`+Announcement ${name}`);
};
annrm = (name) => {
annrm = ({ name }) => {
this.output.log(`-Announcement ${name}`);
};
pktrx = (face, pkt) => {
this.pkt(face, pkt, ">");
pktrx = ({ face, packet }) => {
this.pkt(face, packet, ">");
};
pkttx = (face, pkt) => {
this.pkt(face, pkt, "<");
pkttx = ({ face, packet }) => {
this.pkt(face, packet, "<");
};

@@ -66,0 +66,0 @@ pkt(face, pkt, dir) {

{
"name": "@ndn/fw",
"version": "0.0.20230121",
"version": "0.0.20240113",
"description": "NDNts: Forwarding Plane",

@@ -25,14 +25,14 @@ "keywords": [

"dependencies": {
"@ndn/packet": "0.0.20230121",
"@ndn/util": "0.0.20230121",
"@types/retry": "^0.12.2",
"@ndn/packet": "0.0.20240113",
"@ndn/util": "0.0.20240113",
"@types/retry": "^0.12.5",
"hirestime": "^7.0.3",
"it-pushable": "^3.1.2",
"mnemonist": "^0.39.5",
"it-pushable": "^3.2.3",
"mnemonist": "^0.39.7",
"retry": "^0.13.1",
"streaming-iterables": "^7.1.0",
"tslib": "^2.4.1",
"typed-emitter": "^2.1.0"
"streaming-iterables": "^8.0.1",
"tslib": "^2.6.2",
"typescript-event-target": "^1.1.0"
},
"types": "lib/mod.d.ts"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc