2022-01-02 00:23:39 +08:00
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License").
|
|
|
|
// You may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
// https://github.com/FastTunnel/FastTunnel/edit/v2/LICENSE
|
|
|
|
// Copyright (c) 2019 Gui.H
|
|
|
|
|
|
|
|
using FastTunnel.Core.Extensions;
|
2021-10-11 00:14:55 +08:00
|
|
|
using FastTunnel.Core.Models;
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Net;
|
|
|
|
using System.Net.Sockets;
|
|
|
|
using System.Text;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
2022-11-11 22:54:00 +08:00
|
|
|
namespace FastTunnel.Core.Client.Sockets
|
2021-10-11 00:14:55 +08:00
|
|
|
{
|
2022-11-11 22:54:00 +08:00
|
|
|
|
|
|
|
public class DnsSocketFactory
|
2021-10-11 00:14:55 +08:00
|
|
|
{
|
2022-11-11 22:54:00 +08:00
|
|
|
public static async Task<Socket> ConnectAsync(string host, int port)
|
|
|
|
{
|
|
|
|
var Socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
|
|
|
var dnsEndPoint = new DnsEndPoint(host, port);
|
|
|
|
await Socket.ConnectAsync(dnsEndPoint);
|
|
|
|
return Socket;
|
|
|
|
}
|
2021-10-11 00:14:55 +08:00
|
|
|
}
|
2022-11-11 22:54:00 +08:00
|
|
|
|
2021-10-11 00:14:55 +08:00
|
|
|
}
|