mirror of
https://github.com/FastTunnel/FastTunnel.git
synced 2025-02-08 02:39:29 +08:00
remove suidao project
This commit is contained in:
parent
3c96e40127
commit
b28eab2ee4
|
@ -5,6 +5,19 @@
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
<ApplicationIcon />
|
<ApplicationIcon />
|
||||||
<StartupObject />
|
<StartupObject />
|
||||||
|
<PackageProjectUrl>https://github.com/SpringHgui/FastTunnel</PackageProjectUrl>
|
||||||
|
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||||
|
<Copyright>FastTunnel</Copyright>
|
||||||
|
<Description>expose a local server behind a NAT or firewall to the internet like ngrok and frp</Description>
|
||||||
|
<Authors>SpringHgui</Authors>
|
||||||
|
<Company>FastTunnel</Company>
|
||||||
|
<Product>FastTunnel</Product>
|
||||||
|
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
|
||||||
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
|
<RepositoryUrl>https://github.com/SpringHgui/FastTunnel</RepositoryUrl>
|
||||||
|
<RepositoryType>git</RepositoryType>
|
||||||
|
<PackageTags>FastTunnel.Core</PackageTags>
|
||||||
|
<PackageReleaseNotes>FastTunnel.Core</PackageReleaseNotes>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -9,14 +9,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FastTunnel.Core", "FastTunn
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FastTunnel.Server", "FastTunnel.Server\FastTunnel.Server.csproj", "{DEF2E322-9075-4C3F-9967-7EAF0EE28CEB}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FastTunnel.Server", "FastTunnel.Server\FastTunnel.Server.csproj", "{DEF2E322-9075-4C3F-9967-7EAF0EE28CEB}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SuiDao.Client", "SuiDao.Client\SuiDao.Client.csproj", "{23E6C767-3927-4281-9C1D-C0A724D869A9}"
|
|
||||||
EndProject
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SuiDao.Server", "SuiDao.Server\SuiDao.Server.csproj", "{9DA66955-1497-42BA-B345-3C4D2F3E37A9}"
|
|
||||||
EndProject
|
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "suidao.io", "suidao.io", "{024D84DC-BA2E-4CBC-8D9B-0187C0C09AE1}"
|
|
||||||
EndProject
|
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "FastTunnel", "FastTunnel", "{051B4BB3-621D-4386-BA67-BB8896FDB29E}"
|
|
||||||
EndProject
|
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
@ -35,25 +27,10 @@ Global
|
||||||
{DEF2E322-9075-4C3F-9967-7EAF0EE28CEB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{DEF2E322-9075-4C3F-9967-7EAF0EE28CEB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{DEF2E322-9075-4C3F-9967-7EAF0EE28CEB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{DEF2E322-9075-4C3F-9967-7EAF0EE28CEB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{DEF2E322-9075-4C3F-9967-7EAF0EE28CEB}.Release|Any CPU.Build.0 = Release|Any CPU
|
{DEF2E322-9075-4C3F-9967-7EAF0EE28CEB}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{23E6C767-3927-4281-9C1D-C0A724D869A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{23E6C767-3927-4281-9C1D-C0A724D869A9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{23E6C767-3927-4281-9C1D-C0A724D869A9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{23E6C767-3927-4281-9C1D-C0A724D869A9}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{9DA66955-1497-42BA-B345-3C4D2F3E37A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{9DA66955-1497-42BA-B345-3C4D2F3E37A9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{9DA66955-1497-42BA-B345-3C4D2F3E37A9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{9DA66955-1497-42BA-B345-3C4D2F3E37A9}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(NestedProjects) = preSolution
|
|
||||||
{29DA74AE-FFBD-4A24-82B9-B5675593B63A} = {051B4BB3-621D-4386-BA67-BB8896FDB29E}
|
|
||||||
{C8ADFEB1-59DB-4CE3-8D04-5B547107BCCB} = {051B4BB3-621D-4386-BA67-BB8896FDB29E}
|
|
||||||
{DEF2E322-9075-4C3F-9967-7EAF0EE28CEB} = {051B4BB3-621D-4386-BA67-BB8896FDB29E}
|
|
||||||
{23E6C767-3927-4281-9C1D-C0A724D869A9} = {024D84DC-BA2E-4CBC-8D9B-0187C0C09AE1}
|
|
||||||
{9DA66955-1497-42BA-B345-3C4D2F3E37A9} = {024D84DC-BA2E-4CBC-8D9B-0187C0C09AE1}
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {3D9C6B44-6706-4EE8-9043-802BBE474A2E}
|
SolutionGuid = {3D9C6B44-6706-4EE8-9043-802BBE474A2E}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
|
|
|
@ -1,32 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Net;
|
|
||||||
using System.Net.Http;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SuiDao.Client
|
|
||||||
{
|
|
||||||
public static class HttpHelper
|
|
||||||
{
|
|
||||||
public static Task<string> PostAsJson(string uri, string strContent)
|
|
||||||
{
|
|
||||||
using (var handler = new HttpClientHandler() { AutomaticDecompression = DecompressionMethods.None })
|
|
||||||
using (var httpclient = new HttpClient(handler))
|
|
||||||
{
|
|
||||||
httpclient.BaseAddress = new Uri(uri);
|
|
||||||
var content = new StringContent(strContent, Encoding.UTF8, "application/json");
|
|
||||||
|
|
||||||
var response = httpclient.PostAsync(uri, content).Result;
|
|
||||||
if (response.StatusCode == HttpStatusCode.OK)
|
|
||||||
{
|
|
||||||
return response.Content.ReadAsStringAsync();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new Exception(response.ReasonPhrase);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
using FastTunnel.Core.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace SuiDao.Client.Models
|
|
||||||
{
|
|
||||||
public class LogInByKeyMassage : TunnelMassage
|
|
||||||
{
|
|
||||||
public string key { get; set; }
|
|
||||||
|
|
||||||
public long server_id { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace SuiDao.Client.Models
|
|
||||||
{
|
|
||||||
public class SuiDaoServerConfig
|
|
||||||
{
|
|
||||||
public SuiDaoServerInfo[] servers { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class SuiDaoServerInfo
|
|
||||||
{
|
|
||||||
public string ip { get; set; }
|
|
||||||
|
|
||||||
public int bind_port { get; set; }
|
|
||||||
|
|
||||||
public string server_name { get; set; }
|
|
||||||
|
|
||||||
public long server_id { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,271 +0,0 @@
|
||||||
using FastTunnel.Core;
|
|
||||||
using FastTunnel.Core.Config;
|
|
||||||
using FastTunnel.Core.Core;
|
|
||||||
using FastTunnel.Core.Handlers.Client;
|
|
||||||
using FastTunnel.Core.Host;
|
|
||||||
using FastTunnel.Core.Logger;
|
|
||||||
using FastTunnel.Core.Models;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using NLog;
|
|
||||||
using NLog.Extensions.Logging;
|
|
||||||
using SuiDao.Client.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Net.Sockets;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading;
|
|
||||||
|
|
||||||
namespace SuiDao.Client
|
|
||||||
{
|
|
||||||
class Program
|
|
||||||
{
|
|
||||||
const string KeyLogName = ".key";
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// suidao.io 客户端
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="args"></param>
|
|
||||||
static void Main(string[] args)
|
|
||||||
{
|
|
||||||
LogManager.Configuration = NlogConfig.getNewConfig();
|
|
||||||
var logger = LogManager.GetCurrentClassLogger();
|
|
||||||
logger.Info("===== SuiDao Client Start =====");
|
|
||||||
|
|
||||||
var keyFile = Path.Combine(AppContext.BaseDirectory, KeyLogName);
|
|
||||||
if (!File.Exists(keyFile))
|
|
||||||
{
|
|
||||||
NewKey(logger);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<string> keys = new List<string>();
|
|
||||||
using (var reader = new StreamReader(keyFile))
|
|
||||||
{
|
|
||||||
while (!reader.EndOfStream)
|
|
||||||
{
|
|
||||||
var line = reader.ReadLine();
|
|
||||||
if (!string.IsNullOrEmpty(line))
|
|
||||||
{
|
|
||||||
keys.Add(line);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
keys = keys.Distinct().ToList();
|
|
||||||
if (keys.Count > 0)
|
|
||||||
{
|
|
||||||
Console.WriteLine("请选择要启动的客户端:" + Environment.NewLine);
|
|
||||||
|
|
||||||
Console.WriteLine($" 0:其他密钥登录");
|
|
||||||
for (int i = 0; i < keys.Count; i++)
|
|
||||||
{
|
|
||||||
Console.WriteLine($" {i + 1}:{keys[i]}");
|
|
||||||
}
|
|
||||||
|
|
||||||
Console.WriteLine(Environment.NewLine + "输入编号回车键继续:");
|
|
||||||
|
|
||||||
HandleNum(keys, logger);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void NewKey(ILogger logger)
|
|
||||||
{
|
|
||||||
string key;
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
Console.Write("请输入登录密钥:");
|
|
||||||
key = Console.ReadLine();
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(key))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
LogByKey(key, logger, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void HandleNum(List<string> keys, ILogger logger)
|
|
||||||
{
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
var str = Console.ReadLine();
|
|
||||||
if (string.IsNullOrEmpty(str))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
int index;
|
|
||||||
if (!int.TryParse(str, out index))
|
|
||||||
{
|
|
||||||
Console.WriteLine("输入错误 请重新选择");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (index < 0 || index > keys.Count)
|
|
||||||
{
|
|
||||||
Console.WriteLine("输入错误 请重新选择");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (index == 0)
|
|
||||||
{
|
|
||||||
NewKey(logger);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LogByKey(keys[index - 1], logger, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static IServiceProvider servicesProvider;
|
|
||||||
|
|
||||||
private static void LogByKey(string key, ILogger logger, bool log)
|
|
||||||
{
|
|
||||||
Console.WriteLine("登录中...");
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (servicesProvider == null)
|
|
||||||
servicesProvider = new Host().Config(Config).Build();
|
|
||||||
|
|
||||||
Run(servicesProvider, logger, key, log);
|
|
||||||
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
Thread.Sleep(10000 * 60);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
// NLog: catch any exception and log it.
|
|
||||||
logger.Error(ex, "Stopped program because of exception");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
// Ensure to flush and stop internal timers/threads before application-exit (Avoid segmentation fault on Linux)
|
|
||||||
LogManager.Shutdown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void Run(IServiceProvider servicesProvider, ILogger _logger, string key, bool log)
|
|
||||||
{
|
|
||||||
var res_str = HttpHelper.PostAsJson("https://api1.suidao.io/api/Client/GetServerByKey", $"{{ \"key\":\"{key}\"}}").Result;
|
|
||||||
var jobj = JObject.Parse(res_str);
|
|
||||||
if ((bool)jobj["success"] == true)
|
|
||||||
{
|
|
||||||
// 记录登录记录
|
|
||||||
if (log)
|
|
||||||
{
|
|
||||||
AppendTextToFile(Path.Combine(AppContext.BaseDirectory, KeyLogName), Environment.NewLine + key);
|
|
||||||
}
|
|
||||||
|
|
||||||
SuiDaoServerInfo server;
|
|
||||||
var res = jobj["data"].ToObject<SuiDaoServerConfig>();
|
|
||||||
if (res.servers != null && res.servers.Count() > 0)
|
|
||||||
{
|
|
||||||
// 选择其中一个服务器继续
|
|
||||||
if (res.servers.Count() == 1)
|
|
||||||
{
|
|
||||||
server = res.servers.First();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Console.WriteLine("请选择其中一个服务器进行连接(输入序号,回车键确认):");
|
|
||||||
for (int i = 0; i < res.servers.Length; i++)
|
|
||||||
{
|
|
||||||
Console.WriteLine($"{i}:{res.servers[i].server_name}");
|
|
||||||
}
|
|
||||||
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
var input = Console.ReadLine();
|
|
||||||
int index;
|
|
||||||
if (int.TryParse(input, out index) && index <= res.servers.Length - 1 && index >= 0)
|
|
||||||
{
|
|
||||||
// 输入有效,退出循环
|
|
||||||
server = res.servers[index];
|
|
||||||
Console.WriteLine($"您选择的服务器为:{server.server_name}");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Console.WriteLine("输入有误,请重新输入");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Console.WriteLine("您无可用的服务器");
|
|
||||||
NewKey(_logger);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var client = servicesProvider.GetRequiredService<FastTunnelClient>();
|
|
||||||
|
|
||||||
client.Login(() =>
|
|
||||||
{
|
|
||||||
|
|
||||||
Connecter _client = null;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_client = new Connecter(server.ip, server.bind_port);
|
|
||||||
_client.Connect();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.Error(ex.Message);
|
|
||||||
_client.Socket.Close();
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 登录
|
|
||||||
_client.Send(new Message<LogInByKeyMassage> { MessageType = MessageType.C_LogIn, Content = new LogInByKeyMassage { key = key, server_id = server.server_id } });
|
|
||||||
|
|
||||||
return _client;
|
|
||||||
}, new SuiDaoServer { ServerAddr = server.ip, ServerPort = server.bind_port });
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Console.WriteLine(jobj["errorMsg"].ToString());
|
|
||||||
NewKey(_logger);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void Config(ServiceCollection service)
|
|
||||||
{
|
|
||||||
service.AddSingleton<FastTunnelClient>()
|
|
||||||
.AddSingleton<ClientHeartHandler>()
|
|
||||||
.AddSingleton<LogHandler>()
|
|
||||||
.AddSingleton<NewCustomerHandler>()
|
|
||||||
.AddSingleton<NewSSHHandler>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void AppendTextToFile(string filename, string inputStr)
|
|
||||||
{
|
|
||||||
var dir = Path.GetDirectoryName(filename);
|
|
||||||
if (!Directory.Exists(dir))
|
|
||||||
Directory.CreateDirectory(dir);
|
|
||||||
|
|
||||||
using (FileStream fsw = new FileStream(filename, FileMode.Append))
|
|
||||||
{
|
|
||||||
byte[] writeBytes = Encoding.UTF8.GetBytes(inputStr);
|
|
||||||
fsw.Write(writeBytes, 0, writeBytes.Length);
|
|
||||||
fsw.Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<OutputType>Exe</OutputType>
|
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="NLog" Version="4.6.8" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\FastTunnel.Core\FastTunnel.Core.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
|
@ -1,64 +0,0 @@
|
||||||
using FastTunnel.Core.Core;
|
|
||||||
using FastTunnel.Core.Exceptions;
|
|
||||||
using FastTunnel.Core.Handlers;
|
|
||||||
using FastTunnel.Core.Models;
|
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using SuiDao.Client;
|
|
||||||
using SuiDao.Client.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Net.Sockets;
|
|
||||||
|
|
||||||
namespace SuiDao.Server
|
|
||||||
{
|
|
||||||
public class SuiDaoConfigHandler : IConfigHandler
|
|
||||||
{
|
|
||||||
public LogInMassage GetConfig(JObject content)
|
|
||||||
{
|
|
||||||
|
|
||||||
var logMsg = content.ToObject<LogInByKeyMassage>();
|
|
||||||
var res = HttpHelper.PostAsJson("https://api1.suidao.io/api/Client/GetTunnelByKey", $"{{ \"key\":\"{logMsg.key}\",\"server_id\":{logMsg.server_id}}}").Result;
|
|
||||||
|
|
||||||
var jobj = JObject.Parse(res);
|
|
||||||
if ((bool)jobj["success"] == true)
|
|
||||||
{
|
|
||||||
var tunnels = jobj["data"].ToObject<IEnumerable<Tunnel>>();
|
|
||||||
var Webs = new List<WebConfig>();
|
|
||||||
var SSH = new List<SSHConfig>();
|
|
||||||
|
|
||||||
foreach (var tunnel in tunnels)
|
|
||||||
{
|
|
||||||
if (tunnel.app_type == 1) // web
|
|
||||||
{
|
|
||||||
Webs.Add(new WebConfig
|
|
||||||
{
|
|
||||||
LocalIp = tunnel.local_ip,
|
|
||||||
LocalPort = tunnel.local_port,
|
|
||||||
SubDomain = tunnel.sub_domain
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else if (tunnel.app_type == 2)
|
|
||||||
{
|
|
||||||
SSH.Add(new SSHConfig
|
|
||||||
{
|
|
||||||
LocalIp = tunnel.local_ip,
|
|
||||||
LocalPort = tunnel.local_port,
|
|
||||||
RemotePort = tunnel.remote_port,
|
|
||||||
Protocol = Protocol.TCP
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new LogInMassage
|
|
||||||
{
|
|
||||||
SSH = SSH,
|
|
||||||
Webs = Webs,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new APIErrorException(jobj["errorMsg"].ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
using FastTunnel.Core.Config;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SuiDao.Server
|
|
||||||
{
|
|
||||||
public class Appsettings
|
|
||||||
{
|
|
||||||
public ServerConfig ServerSettings { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace SuiDao.Server
|
|
||||||
{
|
|
||||||
public class Tunnel
|
|
||||||
{
|
|
||||||
public int app_type { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 用户别名
|
|
||||||
/// </summary>
|
|
||||||
public string name { get; set; }
|
|
||||||
|
|
||||||
public string sub_domain { get; set; }
|
|
||||||
|
|
||||||
public string local_ip { get; set; }
|
|
||||||
|
|
||||||
public int local_port { get; set; }
|
|
||||||
|
|
||||||
public int remote_port { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,80 +0,0 @@
|
||||||
using FastTunnel.Core.Config;
|
|
||||||
using FastTunnel.Core.Core;
|
|
||||||
using FastTunnel.Core.Handlers;
|
|
||||||
using FastTunnel.Core.Handlers.Server;
|
|
||||||
using FastTunnel.Core.Host;
|
|
||||||
using FastTunnel.Core.Logger;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using NLog;
|
|
||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
using System.Threading;
|
|
||||||
|
|
||||||
namespace SuiDao.Server
|
|
||||||
{
|
|
||||||
public class Program
|
|
||||||
{
|
|
||||||
static Appsettings appsettings;
|
|
||||||
|
|
||||||
static void Main(string[] args)
|
|
||||||
{
|
|
||||||
LogManager.Configuration = NlogConfig.getNewConfig();
|
|
||||||
var logger = LogManager.GetCurrentClassLogger();
|
|
||||||
logger.Debug("===== FastTunnel Server Start =====");
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var servicesProvider = new Host().Config(Config).Build();
|
|
||||||
Run(servicesProvider);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
// NLog: catch any exception and log it.
|
|
||||||
logger.Error(ex);
|
|
||||||
Console.WriteLine(ex);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
// Ensure to flush and stop internal timers/threads before application-exit (Avoid segmentation fault on Linux)
|
|
||||||
LogManager.Shutdown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ServerConfig implementationFactory(IServiceProvider arg)
|
|
||||||
{
|
|
||||||
if (appsettings == null)
|
|
||||||
{
|
|
||||||
var conf = new ConfigurationBuilder()
|
|
||||||
.SetBasePath(Directory.GetCurrentDirectory())
|
|
||||||
.AddJsonFile("appsettings.json", true, true)
|
|
||||||
.Build();
|
|
||||||
|
|
||||||
appsettings = conf.Get<Appsettings>();
|
|
||||||
}
|
|
||||||
|
|
||||||
return appsettings.ServerSettings;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void Config(ServiceCollection service)
|
|
||||||
{
|
|
||||||
service.AddSingleton<FastTunnelServer>()
|
|
||||||
.AddSingleton<ServerConfig>(implementationFactory)
|
|
||||||
.AddSingleton<LoginHandler>()
|
|
||||||
.AddSingleton<SwapMsgHandler>()
|
|
||||||
.AddSingleton<HeartHandler>()
|
|
||||||
.AddSingleton<IConfigHandler, SuiDaoConfigHandler>();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void Run(IServiceProvider servicesProvider)
|
|
||||||
{
|
|
||||||
var server = servicesProvider.GetRequiredService<FastTunnelServer>();
|
|
||||||
server.Run();
|
|
||||||
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
Thread.Sleep(10000 * 60);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
https://go.microsoft.com/fwlink/?LinkID=208121.
|
|
||||||
-->
|
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<PropertyGroup>
|
|
||||||
<PublishProtocol>FileSystem</PublishProtocol>
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>Any CPU</Platform>
|
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
|
||||||
<PublishDir>bin\Release\netcoreapp3.1\publish\</PublishDir>
|
|
||||||
<SelfContained>false</SelfContained>
|
|
||||||
</PropertyGroup>
|
|
||||||
</Project>
|
|
|
@ -1,6 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
https://go.microsoft.com/fwlink/?LinkID=208121.
|
|
||||||
-->
|
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
</Project>
|
|
|
@ -1,23 +0,0 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<OutputType>Exe</OutputType>
|
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Include="..\SuiDao.Client\HttpHelper.cs" Link="HttpHelper.cs" />
|
|
||||||
<Compile Include="..\SuiDao.Client\Models\LogInByKeyMassage.cs" Link="Model\LogInByKeyMassage.cs" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\FastTunnel.Core\FastTunnel.Core.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<None Update="appsettings.json">
|
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
|
@ -1,7 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<PropertyGroup>
|
|
||||||
<_LastSelectedProfileId>D:\GitHub\FastTunnel\SuiDao.Server\Properties\PublishProfiles\FolderProfile.pubxml</_LastSelectedProfileId>
|
|
||||||
<ShowAllFiles>false</ShowAllFiles>
|
|
||||||
</PropertyGroup>
|
|
||||||
</Project>
|
|
|
@ -1,20 +0,0 @@
|
||||||
{
|
|
||||||
"Logging": {
|
|
||||||
"LogLevel": {
|
|
||||||
"Default": "Information",
|
|
||||||
"Microsoft": "Warning",
|
|
||||||
"Microsoft.Hosting.Lifetime": "Information"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"ServerSettings": {
|
|
||||||
"BindAddr": "0.0.0.0",
|
|
||||||
"BindPort": 2271,
|
|
||||||
|
|
||||||
// 自定义域名
|
|
||||||
"Domain": "sd.suidao.io",
|
|
||||||
|
|
||||||
// 服务监听的端口号, 访问自定义域名站点时url为 http://{SubDomain}.{Domain}:{ProxyPort_HTTP}/
|
|
||||||
"ProxyPort_HTTP": 2270,
|
|
||||||
"HasNginxProxy": true
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +1,6 @@
|
||||||
@echo off
|
@echo off
|
||||||
|
|
||||||
for /d %%p in (FastTunnel.Client,FastTunnel.Server,SuiDao.Client,SuiDao.Server) do (
|
for /d %%p in (FastTunnel.Client,FastTunnel.Server) do (
|
||||||
CD ./%%p
|
CD ./%%p
|
||||||
|
|
||||||
for %%I in (win-x64,osx-x64,linux-x64) do (
|
for %%I in (win-x64,osx-x64,linux-x64) do (
|
||||||
|
|
Loading…
Reference in New Issue
Block a user