diff --git a/FastTunnel.Core/Core/SuiDaoServer.cs b/FastTunnel.Core/Core/SuiDaoServer.cs
index eb0e31b..84bc595 100644
--- a/FastTunnel.Core/Core/SuiDaoServer.cs
+++ b/FastTunnel.Core/Core/SuiDaoServer.cs
@@ -14,6 +14,9 @@ using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using FastTunnel.Core.Handlers;
using FastTunnel.Core.Handlers.Server;
+using Microsoft.AspNetCore.Http;
+using FastTunnel.Core.Helper;
+using System.IO;
namespace FastTunnel.Core.Core
{
@@ -120,14 +123,15 @@ namespace FastTunnel.Core.Core
{
_logger.LogError($"客户端不存在:'{domain}'");
_logger.LogDebug(words);
- return;
+ HandlerClientNotOnLine(client, domain, buffer); return;
+
}
if (!web.Socket.Connected)
{
_logger.LogError($"客户端已下线:'{domain}'");
WebList.Remove(domain);
- return;
+ HandlerClientNotOnLine(client, domain, buffer); return;
}
var msgid = Guid.NewGuid().ToString();
@@ -149,6 +153,36 @@ namespace FastTunnel.Core.Core
}
}
+ private void HandlerClientNotOnLine(Socket clientsocket, string domain, byte[] buffer)
+ {
+ string statusLine = "HTTP/1.1 200 OK\r\n";
+ string responseHeader = "Content-Type: text/html\r\n";
+ byte[] responseBody;
+
+ var file = Path.Combine(AppContext.BaseDirectory, "Htmls", "TunnelNotFound.html");
+ if (File.Exists(file))
+ {
+ responseBody = FileHelper.GetBytesFromFile(file);
+ }
+ else
+ {
+ responseBody = Encoding.UTF8.GetBytes(@"
+
看到本页面表示当前隧道未登录,如果您是当前隧道地址的拥有者,请检查以下原因:
+
+ - 是否创建了当前子域名的隧道
+ - 是否在后台设置中禁用了当前隧道
+ - 是否启动了客户端并登录成功
+
");
+ }
+
+
+ clientsocket.Send(Encoding.UTF8.GetBytes(statusLine));
+ clientsocket.Send(Encoding.UTF8.GetBytes(responseHeader));
+ clientsocket.Send(Encoding.UTF8.GetBytes("\r\n"));
+ clientsocket.Send(responseBody);
+ clientsocket.Close();
+ }
+
byte[] buffer = new byte[1024 * 1024];
public void ReceiveClient(Socket client, object _)
@@ -174,9 +208,9 @@ namespace FastTunnel.Core.Core
return;
}
}
- catch (Exception)
+ catch (Exception ex)
{
- _logger.LogError($"client 退出登录");
+ _logger.LogError($"接收客户端异常 -> 退出登录 {ex.Message}");
if (client.Connected)
{
client.Close();
diff --git a/FastTunnel.Core/FastTunnel.Core.csproj b/FastTunnel.Core/FastTunnel.Core.csproj
index c6d158d..0bdd7d5 100644
--- a/FastTunnel.Core/FastTunnel.Core.csproj
+++ b/FastTunnel.Core/FastTunnel.Core.csproj
@@ -14,6 +14,7 @@
+
@@ -26,4 +27,10 @@
+
+
+ Always
+
+
+
diff --git a/FastTunnel.Core/Helper/FileHelper.cs b/FastTunnel.Core/Helper/FileHelper.cs
new file mode 100644
index 0000000..89af322
--- /dev/null
+++ b/FastTunnel.Core/Helper/FileHelper.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+
+namespace FastTunnel.Core.Helper
+{
+ public static class FileHelper
+ {
+ public static byte[] GetBytesFromFile(string fileName)
+ {
+ if (!File.Exists(fileName))
+ {
+ return null;
+ }
+
+ FileInfo fi = new FileInfo(fileName);
+ byte[] buff = new byte[fi.Length];
+
+ FileStream fs = fi.OpenRead();
+ fs.Read(buff, 0, Convert.ToInt32(fs.Length));
+ fs.Close();
+
+ return buff;
+ }
+ }
+}
diff --git a/FastTunnel.Core/Htmls/TunnelNotFound.html b/FastTunnel.Core/Htmls/TunnelNotFound.html
new file mode 100644
index 0000000..c493cec
--- /dev/null
+++ b/FastTunnel.Core/Htmls/TunnelNotFound.html
@@ -0,0 +1,126 @@
+
+
+
+
+
+
+ FastTunnel
+
+
+
+
+
+
+
+
+
+
找不到隧道
+
了解有关 FastTunel的信息.
+
+
+
+ 看到本页面表示当前隧道未登录,如果您是当前隧道地址的拥有者,请检查以下原因:
+
+
+ - 是否创建了当前子域名的隧道
+ - 是否在后台设置中禁用了当前隧道
+ - 是否启动了客户端并登录成功
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/FastTunnel.Core/SocketSwap.cs b/FastTunnel.Core/SocketSwap.cs
index 2b516e0..a5252bb 100644
--- a/FastTunnel.Core/SocketSwap.cs
+++ b/FastTunnel.Core/SocketSwap.cs
@@ -72,6 +72,10 @@ namespace FastTunnel.Core
if (!chanel.Send.Connected)
break;
+
+ var str = Encoding.UTF8.GetString(result, 0, num);
+ Console.Write(str);
+
chanel.Send.Send(result, num, SocketFlags.None);
}
catch (Exception ex)
diff --git a/FastTunnel.Server/Properties/PublishProfiles/FolderProfile.pubxml b/FastTunnel.Server/Properties/PublishProfiles/FolderProfile.pubxml
index ccb19b1..47d90a6 100644
--- a/FastTunnel.Server/Properties/PublishProfiles/FolderProfile.pubxml
+++ b/FastTunnel.Server/Properties/PublishProfiles/FolderProfile.pubxml
@@ -9,5 +9,6 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
Any CPU
netcoreapp3.1
bin\Release\netcoreapp3.1\publish\
+ false
\ No newline at end of file
diff --git a/SuiDao.Server/Properties/PublishProfiles/FolderProfile.pubxml b/SuiDao.Server/Properties/PublishProfiles/FolderProfile.pubxml
index ccb19b1..47d90a6 100644
--- a/SuiDao.Server/Properties/PublishProfiles/FolderProfile.pubxml
+++ b/SuiDao.Server/Properties/PublishProfiles/FolderProfile.pubxml
@@ -9,5 +9,6 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
Any CPU
netcoreapp3.1
bin\Release\netcoreapp3.1\publish\
+ false
\ No newline at end of file