NetworkInspector.Plugins
0.23.0
dotnet add package NetworkInspector.Plugins --version 0.23.0
NuGet\Install-Package NetworkInspector.Plugins -Version 0.23.0
<PackageReference Include="NetworkInspector.Plugins" Version="0.23.0" />
<PackageVersion Include="NetworkInspector.Plugins" Version="0.23.0" />
<PackageReference Include="NetworkInspector.Plugins" />
paket add NetworkInspector.Plugins --version 0.23.0
#r "nuget: NetworkInspector.Plugins, 0.23.0"
#:package NetworkInspector.Plugins@0.23.0
#addin nuget:?package=NetworkInspector.Plugins&version=0.23.0
#tool nuget:?package=NetworkInspector.Plugins&version=0.23.0
NetworkInspector.Plugins
The plugin contract of the kind networkinspector. A plugin is a class library with one entry class that implements
IPlugin. It adds protocols, heuristic parsers, post-parsers, sources, exporters, and settings to every application
that loads it, such as the ni command-line tool or your own application with
NetworkInspector.Plugins.Loader. Sources and exporters are the Core
types (IFrameSource, IFrameListener, IPacketListener), and options and settings are Core settings, so there is no
second set of interfaces to learn.
Install
dotnet add package NetworkInspector.Plugins
The application that loads your plugin already contains this package and NetworkInspector.Core, so reference them with
Private="false" in a project reference (or exclude their runtime assets in a package reference): the application
provides them at run time, the license inventory of your plugin leaves a Private="false" project out, and copies next
to your plugin are ignored by the loader. Add NetworkInspector.Licensing.Build to embed the plugin's license inventory.
Write a plugin
[PluginEntry("My.Plugin", "My plugin", "My protocol on UDP 40000.")]
public sealed class MyPlugin : IPlugin
{
public void Configure(IPluginBuilder builder)
{
// Runs for every stack the application builds: create fresh protocol objects in every call.
builder.AddStackContribution(static stack =>
{
MyProtocol protocol = new();
ProtocolId id = stack.RegisterProtocol(protocol);
protocol.RegisterFields(stack, id);
stack.WhenProtocolTableRegistered("udp.port", table => stack.RegisterParserInU64Table(table, 40000, id));
});
builder.AddSettings(SettingScope.Application, static registrar =>
{
registrar.RegisterGroup("my", "My plugin", "Settings of My.Plugin.");
registrar.RegisterStringSetting("my.greeting", "Greeting", "my", "Hello");
});
}
}
The entry class carries [PluginEntry] (name, UI name, description; rules in
NetworkInspector.Plugins.Abstractions), and it must be
public, non-abstract, non-generic, have a public parameterless constructor, and list IPlugin
in its own interface list (a class that only inherits the interface from a base class is not found). Build the plugin
against the same minor NetworkInspector version as the application that loads it (before 1.0 a minor release may change
the binary contract of Core); its version is the assembly's informational version and must be a semantic version, and
NetworkInspector.Licensing.Build embeds its license inventory (see the plugin guide).
Register the folder with
ni settings set plugins.paths <folder> --scope application and check the result with ni plugins list:
My.Plugin 1.0.0 - networkinspector Loaded - /opt/ni-plugins/my/My.Plugin.dll MIT load 6.0 ms Protocol 1, Setting 1
From then on every ni command decodes the protocol, filters on its fields, and lists the setting in ni settings.
What the contract contains
| Type | Purpose |
|---|---|
IPlugin |
the kind interface of the entry class; identity from [PluginEntry], version from the informational version, licenses from the embedded inventory |
IPluginBuilder |
declares stack contributions, settings, sources, and exporters while the plugin is configured |
IPluginContext, IPluginLog (from NetworkInspector.Plugins.Abstractions) |
what a started plugin gets: log, data folder, settings, stop signal |
PluginEntryAttribute, PluginRequiresHostAttribute, SemanticVersion (from NetworkInspector.Plugins.Abstractions) |
the entry type's identity and the application versions it runs on |
SourceRegistration, SourceCreate, SourceRequest |
a source kind that creates a Core IFrameSource |
ExporterRegistration<TListener>, ExporterCreation<TListener>, StreamExportRequest, FileExportRequest |
an export format that creates a Core listener from a target of streams or a prepared file path |
PluginError, PluginErrorCode |
expected failures of registrations, returned instead of thrown |
The sample plugin samples/Sample.Protocol uses every part of the contract.
Read the plugin guide for the steps from project setup to distribution, the
protocol chapter for writing protocols, and the
contract reference for one entry per type.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- InvariantStringHelper (>= 1.0.0)
- NetworkInspector.Core (>= 0.23.0)
- NetworkInspector.Plugins.Abstractions (>= 0.23.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on NetworkInspector.Plugins:
| Package | Downloads |
|---|---|
|
NetworkInspector.BuiltInPlugins
Built-in core-tier plugins: standard protocols, file and random sources, and the nine exporters on the plugin contract. |
|
|
NetworkInspector.Plugins.Loader
Plugin pre-scan, scan cache, load contexts, registry, and lifecycle for NetworkInspector applications. |
GitHub repositories
This package is not used by any popular GitHub repositories.