|
1 | | -// Smdn.Net.MuninNode.dll (Smdn.Net.MuninNode-2.1.0) |
| 1 | +// Smdn.Net.MuninNode.dll (Smdn.Net.MuninNode-2.2.0) |
2 | 2 | // 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 |
5 | 5 | // TargetFramework: .NETCoreApp,Version=v8.0 |
6 | 6 | // Configuration: Release |
7 | 7 | // 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 |
9 | 9 | // 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 |
10 | 11 | // Smdn.Fundamental.Exception, Version=3.0.0.0, Culture=neutral |
11 | 12 | // System.Collections, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a |
12 | 13 | // System.ComponentModel, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a |
|
21 | 22 | #nullable enable annotations |
22 | 23 |
|
23 | 24 | using System; |
| 25 | +using System.Buffers; |
24 | 26 | using System.Collections.Generic; |
| 27 | +using System.Collections.ObjectModel; |
25 | 28 | using System.Net; |
26 | 29 | using System.Net.Sockets; |
27 | 30 | using System.Text; |
|
30 | 33 | using Microsoft.Extensions.DependencyInjection; |
31 | 34 | using Microsoft.Extensions.Logging; |
32 | 35 | using Smdn.Net.MuninNode; |
| 36 | +using Smdn.Net.MuninNode.DependencyInjection; |
| 37 | +using Smdn.Net.MuninNode.Transport; |
33 | 38 | using Smdn.Net.MuninPlugin; |
34 | 39 |
|
35 | 40 | namespace Smdn.Net.MuninNode { |
36 | 41 | public interface IAccessRule { |
37 | 42 | bool IsAcceptable(IPEndPoint remoteEndPoint); |
38 | 43 | } |
39 | 44 |
|
| 45 | + public interface IMuninNode { |
| 46 | + EndPoint EndPoint { get; } |
| 47 | + string HostName { get; } |
| 48 | + |
| 49 | + Task RunAsync(CancellationToken cancellationToken); |
| 50 | + } |
| 51 | + |
40 | 52 | public static class IAccessRuleServiceCollectionExtensions { |
41 | 53 | public static IServiceCollection AddMuninNodeAccessRule(this IServiceCollection services, IAccessRule accessRule) {} |
42 | 54 | 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) {} |
43 | 57 | } |
44 | 58 |
|
45 | 59 | public abstract class LocalNode : NodeBase { |
46 | 60 | public static LocalNode Create(IPluginProvider pluginProvider, int port, string? hostName = null, IReadOnlyList<IPAddress>? addressListAllowFrom = null, IServiceProvider? serviceProvider = null) {} |
47 | 61 | public static LocalNode Create(IReadOnlyCollection<IPlugin> plugins, int port, string? hostName = null, IReadOnlyList<IPAddress>? addressListAllowFrom = null, IServiceProvider? serviceProvider = null) {} |
48 | 62 |
|
| 63 | + [Obsolete("Use a constructor overload that takes IMuninNodeListenerFactory as an argument.")] |
49 | 64 | protected LocalNode(IAccessRule? accessRule, ILogger? logger = null) {} |
| 65 | + protected LocalNode(IMuninNodeListenerFactory? listenerFactory, IAccessRule? accessRule, ILogger? logger) {} |
50 | 66 |
|
| 67 | + [Obsolete("Use IMuninNodeListenerFactory and StartAsync instead.")] |
51 | 68 | 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) {} |
53 | 90 | } |
54 | 91 |
|
55 | 92 | public abstract class NodeBase : |
56 | 93 | IAsyncDisposable, |
57 | | - IDisposable |
| 94 | + IDisposable, |
| 95 | + IMuninNode |
58 | 96 | { |
| 97 | + [Obsolete("Use a constructor overload that takes IMuninNodeListenerFactory as an argument.")] |
59 | 98 | protected NodeBase(IAccessRule? accessRule, ILogger? logger) {} |
| 99 | + protected NodeBase(IMuninNodeListenerFactory listenerFactory, IAccessRule? accessRule, ILogger? logger) {} |
60 | 100 |
|
61 | 101 | public virtual Encoding Encoding { get; } |
| 102 | + public EndPoint EndPoint { get; } |
62 | 103 | public abstract string HostName { get; } |
| 104 | + protected IMuninNodeListener? Listener { get; } |
| 105 | + [Obsolete("Use EndPoint instead.")] |
63 | 106 | public EndPoint LocalEndPoint { get; } |
64 | 107 | protected ILogger? Logger { get; } |
65 | 108 | public virtual Version NodeVersion { get; } |
66 | 109 | public abstract IPluginProvider PluginProvider { get; } |
67 | 110 |
|
68 | 111 | public async ValueTask AcceptAsync(bool throwIfCancellationRequested, CancellationToken cancellationToken) {} |
69 | 112 | public async ValueTask AcceptSingleSessionAsync(CancellationToken cancellationToken = default) {} |
70 | | - protected abstract Socket CreateServerSocket(); |
| 113 | + [Obsolete("Use IMuninNodeListenerFactory and StartAsync instead.")] |
| 114 | + protected virtual Socket CreateServerSocket() {} |
71 | 115 | protected virtual void Dispose(bool disposing) {} |
72 | 116 | public void Dispose() {} |
73 | 117 | public async ValueTask DisposeAsync() {} |
74 | 118 | 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.")] |
75 | 122 | public void Start() {} |
| 123 | + public ValueTask StartAsync(CancellationToken cancellationToken = default) {} |
| 124 | + protected void ThrowIfDisposed() {} |
76 | 125 | protected void ThrowIfPluginProviderIsNull() {} |
77 | 126 | } |
78 | 127 | } |
79 | 128 |
|
| 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 | + |
80 | 197 | namespace Smdn.Net.MuninPlugin { |
81 | 198 | public interface INodeSessionCallback { |
82 | 199 | ValueTask ReportSessionClosedAsync(string sessionId, CancellationToken cancellationToken); |
@@ -125,6 +242,20 @@ public enum PluginFieldGraphStyle : int { |
125 | 242 | Stack = 2, |
126 | 243 | } |
127 | 244 |
|
| 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 | + |
128 | 259 | public class Plugin : |
129 | 260 | INodeSessionCallback, |
130 | 261 | IPlugin, |
|
0 commit comments