Skip to content

Commit 08e899a

Browse files
authored
Merge pull request #19 from smdn/releases/Smdn.Net.MuninNode-2.2.0-1746108196
Release main/Smdn.Net.MuninNode-2.2.0
2 parents 04e5ff3 + f34f78a commit 08e899a

File tree

2 files changed

+277
-15
lines changed

2 files changed

+277
-15
lines changed

doc/api-list/Smdn.Net.MuninNode/Smdn.Net.MuninNode-net8.0.apilist.cs

Lines changed: 138 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
// Smdn.Net.MuninNode.dll (Smdn.Net.MuninNode-2.1.0)
1+
// Smdn.Net.MuninNode.dll (Smdn.Net.MuninNode-2.2.0)
22
// Name: Smdn.Net.MuninNode
3-
// AssemblyVersion: 2.1.0.0
4-
// InformationalVersion: 2.1.0+16b4425cbed9d9331220cdef22e4c3e669122124
3+
// AssemblyVersion: 2.2.0.0
4+
// InformationalVersion: 2.2.0+04e5ff38096e4d62b2c9bc5a716d8b2c5a6ad72d
55
// TargetFramework: .NETCoreApp,Version=v8.0
66
// Configuration: Release
77
// Referenced assemblies:
8-
// Microsoft.Extensions.DependencyInjection.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
8+
// Microsoft.Extensions.DependencyInjection.Abstractions, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
99
// Microsoft.Extensions.Logging.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
10+
// Microsoft.Extensions.Options, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
1011
// Smdn.Fundamental.Exception, Version=3.0.0.0, Culture=neutral
1112
// System.Collections, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
1213
// System.ComponentModel, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
@@ -21,7 +22,9 @@
2122
#nullable enable annotations
2223

2324
using System;
25+
using System.Buffers;
2426
using System.Collections.Generic;
27+
using System.Collections.ObjectModel;
2528
using System.Net;
2629
using System.Net.Sockets;
2730
using System.Text;
@@ -30,53 +33,167 @@
3033
using Microsoft.Extensions.DependencyInjection;
3134
using Microsoft.Extensions.Logging;
3235
using Smdn.Net.MuninNode;
36+
using Smdn.Net.MuninNode.DependencyInjection;
37+
using Smdn.Net.MuninNode.Transport;
3338
using Smdn.Net.MuninPlugin;
3439

3540
namespace Smdn.Net.MuninNode {
3641
public interface IAccessRule {
3742
bool IsAcceptable(IPEndPoint remoteEndPoint);
3843
}
3944

45+
public interface IMuninNode {
46+
EndPoint EndPoint { get; }
47+
string HostName { get; }
48+
49+
Task RunAsync(CancellationToken cancellationToken);
50+
}
51+
4052
public static class IAccessRuleServiceCollectionExtensions {
4153
public static IServiceCollection AddMuninNodeAccessRule(this IServiceCollection services, IAccessRule accessRule) {}
4254
public static IServiceCollection AddMuninNodeAccessRule(this IServiceCollection services, IReadOnlyList<IPAddress> addressListAllowFrom) {}
55+
public static IServiceCollection AddMuninNodeAccessRule(this IServiceCollection services, IReadOnlyList<IPAddress> addressListAllowFrom, bool shouldConsiderIPv4MappedIPv6Address) {}
56+
public static IServiceCollection AddMuninNodeLoopbackOnlyAccessRule(this IServiceCollection services) {}
4357
}
4458

4559
public abstract class LocalNode : NodeBase {
4660
public static LocalNode Create(IPluginProvider pluginProvider, int port, string? hostName = null, IReadOnlyList<IPAddress>? addressListAllowFrom = null, IServiceProvider? serviceProvider = null) {}
4761
public static LocalNode Create(IReadOnlyCollection<IPlugin> plugins, int port, string? hostName = null, IReadOnlyList<IPAddress>? addressListAllowFrom = null, IServiceProvider? serviceProvider = null) {}
4862

63+
[Obsolete("Use a constructor overload that takes IMuninNodeListenerFactory as an argument.")]
4964
protected LocalNode(IAccessRule? accessRule, ILogger? logger = null) {}
65+
protected LocalNode(IMuninNodeListenerFactory? listenerFactory, IAccessRule? accessRule, ILogger? logger) {}
5066

67+
[Obsolete("Use IMuninNodeListenerFactory and StartAsync instead.")]
5168
protected override Socket CreateServerSocket() {}
52-
protected virtual EndPoint GetLocalEndPointToBind() {}
69+
}
70+
71+
public sealed class MuninNodeOptions {
72+
public const string DefaultHostName = "munin-node.localhost";
73+
public const int DefaultPort = 4949;
74+
75+
public static IPAddress DefaultAddress { get; }
76+
77+
public MuninNodeOptions() {}
78+
79+
public IAccessRule? AccessRule { get; set; }
80+
public IPAddress Address { get; set; }
81+
public string HostName { get; set; }
82+
public int Port { get; set; }
83+
84+
public MuninNodeOptions AllowFrom(IReadOnlyList<IPAddress> addresses, bool shouldConsiderIPv4MappedIPv6Address = true) {}
85+
public MuninNodeOptions AllowFromLoopbackOnly() {}
86+
public MuninNodeOptions UseAnyAddress() {}
87+
public MuninNodeOptions UseAnyAddress(int port) {}
88+
public MuninNodeOptions UseLoopbackAddress() {}
89+
public MuninNodeOptions UseLoopbackAddress(int port) {}
5390
}
5491

5592
public abstract class NodeBase :
5693
IAsyncDisposable,
57-
IDisposable
94+
IDisposable,
95+
IMuninNode
5896
{
97+
[Obsolete("Use a constructor overload that takes IMuninNodeListenerFactory as an argument.")]
5998
protected NodeBase(IAccessRule? accessRule, ILogger? logger) {}
99+
protected NodeBase(IMuninNodeListenerFactory listenerFactory, IAccessRule? accessRule, ILogger? logger) {}
60100

61101
public virtual Encoding Encoding { get; }
102+
public EndPoint EndPoint { get; }
62103
public abstract string HostName { get; }
104+
protected IMuninNodeListener? Listener { get; }
105+
[Obsolete("Use EndPoint instead.")]
63106
public EndPoint LocalEndPoint { get; }
64107
protected ILogger? Logger { get; }
65108
public virtual Version NodeVersion { get; }
66109
public abstract IPluginProvider PluginProvider { get; }
67110

68111
public async ValueTask AcceptAsync(bool throwIfCancellationRequested, CancellationToken cancellationToken) {}
69112
public async ValueTask AcceptSingleSessionAsync(CancellationToken cancellationToken = default) {}
70-
protected abstract Socket CreateServerSocket();
113+
[Obsolete("Use IMuninNodeListenerFactory and StartAsync instead.")]
114+
protected virtual Socket CreateServerSocket() {}
71115
protected virtual void Dispose(bool disposing) {}
72116
public void Dispose() {}
73117
public async ValueTask DisposeAsync() {}
74118
protected virtual async ValueTask DisposeAsyncCore() {}
119+
protected virtual EndPoint GetLocalEndPointToBind() {}
120+
public Task RunAsync(CancellationToken cancellationToken) {}
121+
[Obsolete("This method will be deprecated in the future.Use IMuninNodeListenerFactory and StartAsync instead.Make sure to override CreateServerSocket if you need to use this method.")]
75122
public void Start() {}
123+
public ValueTask StartAsync(CancellationToken cancellationToken = default) {}
124+
protected void ThrowIfDisposed() {}
76125
protected void ThrowIfPluginProviderIsNull() {}
77126
}
78127
}
79128

129+
namespace Smdn.Net.MuninNode.DependencyInjection {
130+
public interface IMuninNodeBuilder {
131+
string ServiceKey { get; }
132+
IServiceCollection Services { get; }
133+
134+
IMuninNode Build(IServiceProvider serviceProvider);
135+
}
136+
137+
public interface IMuninServiceBuilder {
138+
IServiceCollection Services { get; }
139+
}
140+
141+
public static class IMuninNodeBuilderExtensions {
142+
public static IMuninNodeBuilder AddPlugin(this IMuninNodeBuilder builder, Func<IServiceProvider, IPlugin> buildPlugin) {}
143+
public static IMuninNodeBuilder AddPlugin(this IMuninNodeBuilder builder, IPlugin plugin) {}
144+
public static IMuninNodeBuilder UseListenerFactory(this IMuninNodeBuilder builder, Func<IServiceProvider, EndPoint, IMuninNode, CancellationToken, ValueTask<IMuninNodeListener>> createListenerAsyncFunc) {}
145+
public static IMuninNodeBuilder UseListenerFactory(this IMuninNodeBuilder builder, Func<IServiceProvider, IMuninNodeListenerFactory> buildListenerFactory) {}
146+
public static IMuninNodeBuilder UseListenerFactory(this IMuninNodeBuilder builder, IMuninNodeListenerFactory listenerFactory) {}
147+
public static IMuninNodeBuilder UsePluginProvider(this IMuninNodeBuilder builder, Func<IServiceProvider, IPluginProvider> buildPluginProvider) {}
148+
public static IMuninNodeBuilder UsePluginProvider(this IMuninNodeBuilder builder, IPluginProvider pluginProvider) {}
149+
public static IMuninNodeBuilder UseSessionCallback(this IMuninNodeBuilder builder, Func<IServiceProvider, INodeSessionCallback> buildSessionCallback) {}
150+
public static IMuninNodeBuilder UseSessionCallback(this IMuninNodeBuilder builder, Func<string, CancellationToken, ValueTask>? reportSessionStartedAsyncFunc, Func<string, CancellationToken, ValueTask>? reportSessionClosedAsyncFunc) {}
151+
public static IMuninNodeBuilder UseSessionCallback(this IMuninNodeBuilder builder, INodeSessionCallback sessionCallback) {}
152+
}
153+
154+
public static class IMuninServiceBuilderExtensions {
155+
public static IMuninNodeBuilder AddNode(this IMuninServiceBuilder builder) {}
156+
public static IMuninNodeBuilder AddNode(this IMuninServiceBuilder builder, Action<MuninNodeOptions> configure) {}
157+
}
158+
159+
public static class IServiceCollectionExtensions {
160+
public static IServiceCollection AddMunin(this IServiceCollection services, Action<IMuninServiceBuilder> configure) {}
161+
}
162+
}
163+
164+
namespace Smdn.Net.MuninNode.Transport {
165+
public interface IMuninNodeClient :
166+
IAsyncDisposable,
167+
IDisposable
168+
{
169+
EndPoint? EndPoint { get; }
170+
171+
ValueTask DisconnectAsync(CancellationToken cancellationToken);
172+
ValueTask<int> ReceiveAsync(IBufferWriter<byte> buffer, CancellationToken cancellationToken);
173+
ValueTask SendAsync(ReadOnlyMemory<byte> buffer, CancellationToken cancellationToken);
174+
}
175+
176+
public interface IMuninNodeListener :
177+
IAsyncDisposable,
178+
IDisposable
179+
{
180+
EndPoint? EndPoint { get; }
181+
182+
ValueTask<IMuninNodeClient> AcceptAsync(CancellationToken cancellationToken);
183+
ValueTask StartAsync(CancellationToken cancellationToken);
184+
}
185+
186+
public interface IMuninNodeListenerFactory {
187+
ValueTask<IMuninNodeListener> CreateAsync(EndPoint endPoint, IMuninNode node, CancellationToken cancellationToken);
188+
}
189+
190+
public sealed class MuninNodeClientDisconnectedException : InvalidOperationException {
191+
public MuninNodeClientDisconnectedException() {}
192+
public MuninNodeClientDisconnectedException(string message) {}
193+
public MuninNodeClientDisconnectedException(string message, Exception innerException) {}
194+
}
195+
}
196+
80197
namespace Smdn.Net.MuninPlugin {
81198
public interface INodeSessionCallback {
82199
ValueTask ReportSessionClosedAsync(string sessionId, CancellationToken cancellationToken);
@@ -125,6 +242,20 @@ public enum PluginFieldGraphStyle : int {
125242
Stack = 2,
126243
}
127244

245+
public sealed class AggregatePluginProvider :
246+
ReadOnlyCollection<IPluginProvider>,
247+
INodeSessionCallback,
248+
IPluginProvider
249+
{
250+
public AggregatePluginProvider(IList<IPluginProvider> pluginProviders) {}
251+
252+
public IReadOnlyCollection<IPlugin> Plugins { get; }
253+
INodeSessionCallback? IPluginProvider.SessionCallback { get; }
254+
255+
async ValueTask INodeSessionCallback.ReportSessionClosedAsync(string sessionId, CancellationToken cancellationToken) {}
256+
async ValueTask INodeSessionCallback.ReportSessionStartedAsync(string sessionId, CancellationToken cancellationToken) {}
257+
}
258+
128259
public class Plugin :
129260
INodeSessionCallback,
130261
IPlugin,

0 commit comments

Comments
 (0)