示例#1
0
        public RaftEmbeddedCluster(IServiceProvider services)
            : base(services, out var members)
        {
            var config = services.GetRequiredService <IOptions <RaftEmbeddedClusterMemberConfiguration> >().Value;

            ProtocolPath = config.ResourcePath;
            foreach (var memberUri in config.Members)
            {
                members.Add(CreateMember(memberUri));
            }
            server = services.GetRequiredService <IServer>();
            config.SetupHostAddressHint(server.Features);
        }
示例#2
0
        internal static ICollection <IPEndPoint> GetHostingAddresses(this IServer server)
        {
            var feature = server.Features.Get <IServerAddresses>();

            if (feature is null || feature.Addresses.Count == 0)
            {
                return(Array.Empty <IPEndPoint>());
            }
            var result = new HashSet <IPEndPoint>();
            var hint   = server.Features.Get <HostAddressHintFeature>()?.Address;

            foreach (var address in feature.Addresses)
            {
                if (Uri.TryCreate(address, UriKind.Absolute, out var uri))
                {
                    var endpoint = uri.ToEndPoint();
                    if (endpoint is null)
                    {
                        continue;
                    }
                    else if (endpoint.Address.IsOneOf(IPAddress.Any, IPAddress.IPv6Any))
                    {
                        foreach (var nic in NetworkInterface.GetAllNetworkInterfaces())
                        {
                            foreach (var nicAddr in nic.GetIPProperties().UnicastAddresses)
                            {
                                result.Add(new IPEndPoint(nicAddr.Address, endpoint.Port));
                            }
                        }
                    }
                    else
                    {
                        result.Add(endpoint);
                    }

                    // add host address hint if it is available
                    if (!(hint is null))
                    {
                        result.Add(new IPEndPoint(hint, endpoint.Port));
                    }
                }
            }

            return(result);
        }
 public GenericWebHostService(Microsoft.Extensions.Options.IOptions <Microsoft.AspNetCore.Hosting.GenericWebHostServiceOptions> options, Microsoft.AspNetCore.Hosting.Server.IServer server, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory, System.Diagnostics.DiagnosticListener diagnosticListener, Microsoft.AspNetCore.Http.IHttpContextFactory httpContextFactory, Microsoft.AspNetCore.Hosting.Builder.IApplicationBuilderFactory applicationBuilderFactory, System.Collections.Generic.IEnumerable <Microsoft.AspNetCore.Hosting.IStartupFilter> startupFilters, Microsoft.Extensions.Configuration.IConfiguration configuration, Microsoft.AspNetCore.Hosting.IWebHostEnvironment hostingEnvironment)
 {
 }
示例#4
0
 public static Microsoft.AspNetCore.Hosting.IWebHostBuilder UseServer(this Microsoft.AspNetCore.Hosting.IWebHostBuilder hostBuilder, Microsoft.AspNetCore.Hosting.Server.IServer server)
 {
     throw null;
 }