mirror of
https://github.com/FastTunnel/FastTunnel.git
synced 2025-02-08 02:39:29 +08:00
增加全局项目配置&增加对未登录的代理提示
This commit is contained in:
parent
5c0f276b89
commit
86a0a990e8
7
Directory.Build.props
Normal file
7
Directory.Build.props
Normal file
|
@ -0,0 +1,7 @@
|
|||
<Project>
|
||||
<PropertyGroup>
|
||||
<Version>2.0.1</Version>
|
||||
<Nullable>enable</Nullable>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
</Project>
|
|
@ -1,8 +1,6 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<Version>1.0.0</Version>
|
||||
<PackageProjectUrl>https://github.com/FastTunnel/FastTunnel/tree/v2/FastTunnel.Api</PackageProjectUrl>
|
||||
<RepositoryUrl>https://github.com/FastTunnel/FastTunnel/tree/v2/FastTunnel.Api</RepositoryUrl>
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -21,12 +20,6 @@
|
|||
<None Update="log4net.config">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="uninstall.bat">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="install.bat">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ProjectExtensions>
|
||||
|
|
|
@ -85,7 +85,7 @@ namespace FastTunnel.Core.Client
|
|||
|
||||
_logger.LogInformation($"正在连接服务端 {Server.ServerAddr}:{Server.ServerPort}");
|
||||
await socket.ConnectAsync(
|
||||
new Uri($"ws://{Server.ServerAddr}:{Server.ServerPort}"), cancellationToken);
|
||||
new Uri($"{Server.Protocol}://{Server.ServerAddr}:{Server.ServerPort}"), cancellationToken);
|
||||
|
||||
_logger.LogDebug("连接服务端成功");
|
||||
|
||||
|
@ -151,13 +151,6 @@ namespace FastTunnel.Core.Client
|
|||
public void Stop(CancellationToken cancellationToken)
|
||||
{
|
||||
_logger.LogInformation("===== FastTunnel Client Stoping =====");
|
||||
if (socket == null)
|
||||
return;
|
||||
|
||||
if (socket.State == WebSocketState.Connecting)
|
||||
return;
|
||||
|
||||
socket.CloseAsync(WebSocketCloseStatus.Empty, string.Empty, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@ namespace FastTunnel.Core.Config
|
|||
|
||||
public class SuiDaoServer
|
||||
{
|
||||
public string Protocol { get; set; } = "ws";
|
||||
|
||||
public string ServerAddr { get; set; }
|
||||
|
||||
public int ServerPort { get; set; }
|
||||
|
|
|
@ -14,6 +14,11 @@ using FastTunnel.Core.Filters;
|
|||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using FastTunnel.Core.Models;
|
||||
using FastTunnel.Core.Handlers.Server;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace FastTunnel.Core
|
||||
{
|
||||
|
@ -71,5 +76,24 @@ namespace FastTunnel.Core
|
|||
app.Use(clientHandler.Handle);
|
||||
app.Use(swapHandler.Handle);
|
||||
}
|
||||
|
||||
public static void MapFastTunnelServer(this IEndpointRouteBuilder endpoints)
|
||||
{
|
||||
endpoints.MapReverseProxy();
|
||||
endpoints.MapFallback(context =>
|
||||
{
|
||||
var options = context.RequestServices.GetRequiredService<IOptionsMonitor<DefaultServerConfig>>();
|
||||
var host = context.Request.Host.Host;
|
||||
if (!host.EndsWith(options.CurrentValue.WebDomain) || host.Equals(options.CurrentValue.WebDomain))
|
||||
{
|
||||
context.Response.StatusCode = 404;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
context.Response.StatusCode = 200;
|
||||
context.Response.WriteAsync(TunnelResource.Page_NotFound, CancellationToken.None);
|
||||
return Task.CompletedTask;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,10 +1,6 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Library</OutputType>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<ApplicationIcon />
|
||||
<StartupObject />
|
||||
<PackageProjectUrl>https://github.com/SpringHgui/FastTunnel</PackageProjectUrl>
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
<Copyright>FastTunnel</Copyright>
|
||||
|
@ -18,7 +14,6 @@
|
|||
<RepositoryType>git</RepositoryType>
|
||||
<PackageTags>FastTunnel.Core</PackageTags>
|
||||
<PackageReleaseNotes>FastTunnel.Core</PackageReleaseNotes>
|
||||
<Version>2.0.1</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -52,7 +47,7 @@
|
|||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Update="TunnelResource.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<Generator>PublicResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>TunnelResource.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
|
53
FastTunnel.Core/TunnelResource.Designer.cs
generated
53
FastTunnel.Core/TunnelResource.Designer.cs
generated
|
@ -22,7 +22,7 @@ namespace FastTunnel.Core {
|
|||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class TunnelResource {
|
||||
public class TunnelResource {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
|
@ -36,7 +36,7 @@ namespace FastTunnel.Core {
|
|||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
public static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FastTunnel.Core.TunnelResource", typeof(TunnelResource).Assembly);
|
||||
|
@ -51,7 +51,7 @@ namespace FastTunnel.Core {
|
|||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
public static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ namespace FastTunnel.Core {
|
|||
/// <summary>
|
||||
/// Looks up a localized string similar to 服务端禁用了Forward.
|
||||
/// </summary>
|
||||
internal static string ForwardDisabled {
|
||||
public static string ForwardDisabled {
|
||||
get {
|
||||
return ResourceManager.GetString("ForwardDisabled", resourceCulture);
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ namespace FastTunnel.Core {
|
|||
/// <summary>
|
||||
/// Looks up a localized string similar to 您尚未创建任何隧道,请登录https://suidao.io 创建后重试。.
|
||||
/// </summary>
|
||||
internal static string NoTunnel {
|
||||
public static string NoTunnel {
|
||||
get {
|
||||
return ResourceManager.GetString("NoTunnel", resourceCulture);
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ namespace FastTunnel.Core {
|
|||
/// color: #fff;
|
||||
/// background-color [rest of string was truncated]";.
|
||||
/// </summary>
|
||||
internal static string Page_HostRequired {
|
||||
public static string Page_HostRequired {
|
||||
get {
|
||||
return ResourceManager.GetString("Page_HostRequired", resourceCulture);
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ namespace FastTunnel.Core {
|
|||
/// color: #fff;
|
||||
/// background-color: [rest of string was truncated]";.
|
||||
/// </summary>
|
||||
internal static string Page_NoSite {
|
||||
public static string Page_NoSite {
|
||||
get {
|
||||
return ResourceManager.GetString("Page_NoSite", resourceCulture);
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ namespace FastTunnel.Core {
|
|||
/// color: #fff;
|
||||
/// background-color [rest of string was truncated]";.
|
||||
/// </summary>
|
||||
internal static string Page_NotAccessIps {
|
||||
public static string Page_NotAccessIps {
|
||||
get {
|
||||
return ResourceManager.GetString("Page_NotAccessIps", resourceCulture);
|
||||
}
|
||||
|
@ -187,9 +187,38 @@ namespace FastTunnel.Core {
|
|||
/// color: #fff;
|
||||
/// background-color [rest of string was truncated]";.
|
||||
/// </summary>
|
||||
internal static string Page_Offline {
|
||||
public static string Page_NotFound {
|
||||
get {
|
||||
return ResourceManager.GetString("Page_NoTunnel", resourceCulture);
|
||||
return ResourceManager.GetString("Page_NotFund", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to <!DOCTYPE html>
|
||||
///<html lang="en">
|
||||
///
|
||||
///<head>
|
||||
/// <meta charset="utf-8" />
|
||||
/// <meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
/// <title>FastTunnel</title>
|
||||
/// <link href="https://cdn.bootcss.com/twitter-bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
/// <style>
|
||||
/// .err-info {
|
||||
/// margin-top: 120px;
|
||||
/// }
|
||||
///
|
||||
/// /* Provide sufficient contrast against white background */
|
||||
/// a {
|
||||
/// color: #0366d6;
|
||||
/// }
|
||||
///
|
||||
/// .btn-primary {
|
||||
/// color: #fff;
|
||||
/// background-color [rest of string was truncated]";.
|
||||
/// </summary>
|
||||
public static string Page_Offline {
|
||||
get {
|
||||
return ResourceManager.GetString("Page_Offline", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -213,7 +242,7 @@ namespace FastTunnel.Core {
|
|||
///<body>
|
||||
/// <head [rest of string was truncated]";.
|
||||
/// </summary>
|
||||
internal static string Test {
|
||||
public static string Test {
|
||||
get {
|
||||
return ResourceManager.GetString("Test", resourceCulture);
|
||||
}
|
||||
|
@ -222,7 +251,7 @@ namespace FastTunnel.Core {
|
|||
/// <summary>
|
||||
/// Looks up a localized string similar to \n=====隧道已建立成功,现在可以通过以下方式访问您的内网服务了=====\n{0}\n.
|
||||
/// </summary>
|
||||
internal static string TunnelLlist {
|
||||
public static string TunnelLlist {
|
||||
get {
|
||||
return ResourceManager.GetString("TunnelLlist", resourceCulture);
|
||||
}
|
||||
|
|
|
@ -471,7 +471,7 @@
|
|||
|
||||
</html></value>
|
||||
</data>
|
||||
<data name="Page_NoTunnel" xml:space="preserve">
|
||||
<data name="Page_NotFund" xml:space="preserve">
|
||||
<value><!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
|
@ -585,6 +585,122 @@
|
|||
</footer>
|
||||
</body>
|
||||
|
||||
</html></value>
|
||||
</data>
|
||||
<data name="Page_Offline" xml:space="preserve">
|
||||
<value><!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>FastTunnel</title>
|
||||
<link href="https://cdn.bootcss.com/twitter-bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<style>
|
||||
.err-info {
|
||||
margin-top: 120px;
|
||||
}
|
||||
|
||||
/* Provide sufficient contrast against white background */
|
||||
a {
|
||||
color: #0366d6;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
color: #fff;
|
||||
background-color: #1b6ec2;
|
||||
border-color: #1861ac;
|
||||
}
|
||||
|
||||
.nav-pills .nav-link.active,
|
||||
.nav-pills .show>.nav-link {
|
||||
color: #fff;
|
||||
background-color: #1b6ec2;
|
||||
border-color: #1861ac;
|
||||
}
|
||||
|
||||
/* Sticky footer styles
|
||||
-------------------------------------------------- */
|
||||
html {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
html {
|
||||
font-size: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
.border-top {
|
||||
border-top: 1px solid #e5e5e5;
|
||||
}
|
||||
|
||||
.border-bottom {
|
||||
border-bottom: 1px solid #e5e5e5;
|
||||
}
|
||||
|
||||
.box-shadow {
|
||||
box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
|
||||
}
|
||||
|
||||
button.accept-policy {
|
||||
font-size: 1rem;
|
||||
line-height: inherit;
|
||||
}
|
||||
|
||||
/* Sticky footer styles
|
||||
-------------------------------------------------- */
|
||||
html {
|
||||
position: relative;
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
/* Margin bottom by footer height */
|
||||
margin-bottom: 60px;
|
||||
}
|
||||
|
||||
.footer {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
white-space: nowrap;
|
||||
line-height: 60px;
|
||||
/* Vertically center the text there */
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container err-info">
|
||||
<main role="main" class="pb-3">
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">客户端已离线</h1>
|
||||
<p>登录遇到问题? 去github提交<a target="_blank" href="https://github.com/SpringHgui/FastTunnel/issues">issue</a>给软件作者.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<blockquote style="padding-top: 4em;">
|
||||
<p class="lead">您看到本页面表示当前隧道尚未登录,如果您是当前隧道地址的拥有者,请检查以下原因:</p>
|
||||
</blockquote>
|
||||
<ol>
|
||||
<li class="lead">是否创建了当前子域名的隧道</li>
|
||||
<li class="lead">是否在后台设置中禁用了当前隧道</li>
|
||||
<li class="lead">是否启动了客户端并登录成功</li>
|
||||
</ol>
|
||||
<blockquote style="padding-top: 4em;">
|
||||
<p class="lead">提醒:当前软件处于开发阶段,客户端版本可能会更新频繁,如遇到客户端异常,请登录<a target="_blank" href="https://suidao.io">suidao.io</a>下载最新的客户端重试。</p>
|
||||
</blockquote>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<footer class="border-top footer text-muted">
|
||||
<div class="container">
|
||||
<a href="https://github.com/SpringHgui/FastTunnel" target="_blank">© Power By FastTunnel</a>
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
|
||||
</html></value>
|
||||
<comment>客户端未登录</comment>
|
||||
</data>
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<UserSecretsId>c508b25f-0a51-4bab-b64c-8a7e993f24f6</UserSecretsId>
|
||||
<RunAnalyzersDuringBuild>true</RunAnalyzersDuringBuild>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="logs\**" />
|
||||
<Content Remove="logs\**" />
|
||||
|
@ -29,12 +22,6 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="uninstall.bat">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="install.bat">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="uninstall.bat">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
|
@ -42,8 +29,4 @@
|
|||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ProjectExtensions><VisualStudio><UserProperties config_4appsettings_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>
|
||||
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
using FastTunnel.Core;
|
||||
using FastTunnel.Core.Config;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FastTunnel.Server
|
||||
{
|
||||
|
@ -26,9 +31,9 @@ namespace FastTunnel.Server
|
|||
c.SwaggerDoc("v2", new OpenApiInfo { Title = "FastTunel.Api", Version = "v2" });
|
||||
});
|
||||
|
||||
// -------------------FastTunnel START------------------
|
||||
// -------------------FastTunnel STEP1 OF 3------------------
|
||||
services.AddFastTunnelServer(Configuration.GetSection("ServerSettings"));
|
||||
// -------------------FastTunnel END--------------------
|
||||
// -------------------FastTunnel STEP1 END--------------------
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
|
@ -41,16 +46,18 @@ namespace FastTunnel.Server
|
|||
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v2/swagger.json", "FastTunel.WebApi v2"));
|
||||
}
|
||||
|
||||
// -------------------FastTunnel START------------------
|
||||
// -------------------FastTunnel STEP2 OF 3------------------
|
||||
app.UseFastTunnelServer();
|
||||
// -------------------FastTunnel END--------------------
|
||||
// -------------------FastTunnel STEP2 END--------------------
|
||||
|
||||
app.UseRouting();
|
||||
|
||||
app.UseEndpoints(endpoints =>
|
||||
{
|
||||
endpoints.MapReverseProxy();
|
||||
endpoints.MapControllers();
|
||||
// -------------------FastTunnel STEP3 OF 3------------------
|
||||
endpoints.MapFastTunnelServer();
|
||||
// -------------------FastTunnel STEP3 END--------------------
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user