Example #1
0
 public void Release(HostAndPort hostAndPort)
 {
 }
Example #2
0
 public Lease(HostAndPort hostAndPort, int connections)
 {
     HostAndPort = hostAndPort;
     Connections = connections;
 }
Example #3
0
        public Response <DownstreamUrl> Build(string downstreamPath, string downstreamScheme, HostAndPort downstreamHostAndPort)
        {
            if (string.IsNullOrEmpty(downstreamPath))
            {
                return(new ErrorResponse <DownstreamUrl>(new List <Error> {
                    new DownstreamPathNullOrEmptyError()
                }));
            }

            if (string.IsNullOrEmpty(downstreamScheme))
            {
                return(new ErrorResponse <DownstreamUrl>(new List <Error> {
                    new DownstreamSchemeNullOrEmptyError()
                }));
            }

            if (string.IsNullOrEmpty(downstreamHostAndPort.DownstreamHost))
            {
                return(new ErrorResponse <DownstreamUrl>(new List <Error> {
                    new DownstreamHostNullOrEmptyError()
                }));
            }


            var builder = new UriBuilder
            {
                Host   = downstreamHostAndPort.DownstreamHost,
                Path   = downstreamPath,
                Scheme = downstreamScheme
            };

            if (downstreamHostAndPort.DownstreamPort > 0)
            {
                builder.Port = downstreamHostAndPort.DownstreamPort;
            }

            var url = builder.Uri.ToString();

            return(new OkResponse <DownstreamUrl>(new DownstreamUrl(url)));
        }
Example #4
0
 /// <summary>
 /// Start master which has previously been registered at the specified
 /// host and port.
 /// </summary>
 /// <param name="hostPort">Host and port of the master to start back.</param>
 public Task StartMasterAsync(HostAndPort hostPort)
 {
     return(_miniCluster.StartMasterServerAsync(hostPort));
 }
 private void GivenAHostAndPort(HostAndPort hostAndPort)
 {
     _hostAndPort = hostAndPort;
 }
Example #6
0
 /// <summary>
 /// Kills a tablet server identified identified by an host and port.
 /// Does nothing if the server was already dead.
 /// </summary>
 /// <param name="hostPort">Unique host and port identifying the server.</param>
 public Task KillTabletServerAsync(HostAndPort hostPort)
 {
     return(_miniCluster.KillTabletServerAsync(hostPort));
 }
 public override int GetHashCode()
 {
     return(HostAndPort.GetHashCode());
 }
Example #8
0
 public static partial void UnableToConnectToServer(
     this ILogger logger,
     Exception exception,
     HostAndPort HostPort,
     IPAddress Ip,
     string Uuid);
Example #9
0
 private static void UDPSocket_ReceviceData(object sender, byte[] data, HostAndPort host)
 {
     Console.WriteLine(Encoding.UTF8.GetString(data));
 }
Example #10
0
    public static bool TryParse(
        [NotNullWhen(true)] string?addressWithPort,
        int defaultPort,
        [MaybeNullWhen(false)] out HostAndPort result)
    {
        // Adapted from IPEndPointParser in Microsoft.AspNetCore
        // Link: https://github.com/aspnet/BasicMiddleware/blob/f320511b63da35571e890d53f3906c7761cd00a1/src/Microsoft.AspNetCore.HttpOverrides/Internal/IPEndPointParser.cs#L8
        // Copyright (c) .NET Foundation. All rights reserved.
        // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
        if (string.IsNullOrEmpty(addressWithPort))
        {
            result = null;
            return(false);
        }

        string?addressPart;
        string?portPart = null;

        var lastColonIndex = addressWithPort !.LastIndexOf(':');

        if (lastColonIndex > 0)
        {
            // IPv4 with port or IPv6
            var closingIndex = addressWithPort.LastIndexOf(']');
            if (closingIndex > 0)
            {
                // IPv6 with brackets
                addressPart = addressWithPort.Substring(1, closingIndex - 1);
                if (closingIndex < lastColonIndex)
                {
                    // IPv6 with port [::1]:80
                    portPart = addressWithPort.Substring(lastColonIndex + 1);
                }
            }
            else
            {
                // IPv6 without port or IPv4
                var firstColonIndex = addressWithPort.IndexOf(':');
                if (firstColonIndex != lastColonIndex)
                {
                    // IPv6 ::1
                    addressPart = addressWithPort;
                }
                else
                {
                    // IPv4 with port 127.0.0.1:123
                    addressPart = addressWithPort.Substring(0, firstColonIndex);
                    portPart    = addressWithPort.Substring(firstColonIndex + 1);
                }
            }
        }
        else
        {
            // IPv4 without port
            addressPart = addressWithPort;
        }

        int?port = null;

        if (portPart is not null)
        {
            if (TryParseInt32(portPart, out var portVal))
            {
                port = portVal;
            }
            else
            {
                // Invalid port, return
                result = null;
                return(false);
            }
        }

        result = new HostAndPort(addressPart, port ?? defaultPort);
        return(true);
    }