public override async ValueTask <IEnumerable <IConnector> > ConnectorsAsync( EndpointSelectionType endptSelection) { Instrumentation.IObserver?observer = Communicator.Observer?.GetEndpointLookupObserver(this); observer?.Attach(); try { INetworkProxy?networkProxy = Communicator.NetworkProxy; int ipVersion = Communicator.IPVersion; if (networkProxy != null) { networkProxy = await networkProxy.ResolveHostAsync(ipVersion).ConfigureAwait(false); if (networkProxy != null) { ipVersion = networkProxy.GetIPVersion(); } } IEnumerable <IPEndPoint> addrs = await Network.GetAddressesForClientEndpointAsync(Host, Port, ipVersion, endptSelection, Communicator.PreferIPv6).ConfigureAwait(false); return(addrs.Select(item => CreateConnector(item, networkProxy))); } catch (Exception ex) { observer?.Failed(ex.GetType().FullName ?? "System.Exception"); throw; } finally { observer?.Detach(); } }
public async ValueTask <INetworkProxy> ResolveHostAsync(CancellationToken cancel) { Debug.Assert(_host != null); // TODO can we support multiple addresses for a socks proxy IEnumerable <IPEndPoint> addresses = await Network.GetAddressesForClientEndpointAsync(_host, _port, IPVersion, cancel).ConfigureAwait(false); return(new HTTPNetworkProxy(addresses.First())); }
public async ValueTask <INetworkProxy> ResolveHostAsync(CancellationToken cancel) { Debug.Assert(_host != null); // Get addresses in random order and use the first one IEnumerable <IPEndPoint> addresses = await Network.GetAddressesForClientEndpointAsync(_host, _port, IPVersion, EndpointSelectionType.Random, cancel).ConfigureAwait(false); return(new SOCKSNetworkProxy(addresses.First())); }