支持使用自有域名访问web站点

This commit is contained in:
SpringHgui 2020-09-21 16:49:05 +08:00
parent 60aea3e9f4
commit bf8461a7d2
10 changed files with 71 additions and 46 deletions

View File

@ -57,33 +57,33 @@ namespace FastTunnel.Client
client.Login(() =>
{
Connecter _client;
Connecter _client;
try
{
// 连接到的目标IP
_client = new Connecter(config.Common.ServerAddr, config.Common.ServerPort);
_client.Connect();
}
catch (Exception ex)
{
Thread.Sleep(5000);
throw;
}
try
{
// 连接到的目标IP
_client = new Connecter(config.Common.ServerAddr, config.Common.ServerPort);
_client.Connect();
}
catch (Exception)
{
Thread.Sleep(5000);
throw;
}
// 登录
_client.Send(new Message<LogInMassage>
{
MessageType = MessageType.C_LogIn,
Content = new LogInMassage
{
Webs = config.Webs,
SSH = config.SSH
}
});
// 登录
_client.Send(new Message<LogInMassage>
{
MessageType = MessageType.C_LogIn,
Content = new LogInMassage
{
Webs = config.Webs,
SSH = config.SSH
}
});
return _client;
}, config.Common);
return _client;
}, config.Common);
while (true)
{

View File

@ -23,7 +23,10 @@
"LocalPort": 80,
// , 访url http://{SubDomain}.{Domain}:{ProxyPort_HTTP}/
"SubDomain": "test" // test.test.cc
"SubDomain": "test", // test.test.cc
// Aip
"WWW": [ "www.abc.com","test111.test.cc" ]
}
],

View File

@ -91,7 +91,7 @@ namespace FastTunnel.Core
{
listenSocket.Shutdown(SocketShutdown.Both);
}
catch (Exception ex)
catch (Exception)
{
}
finally

View File

@ -74,7 +74,7 @@ namespace FastTunnel.Core.Core
_logger.LogDebug($"last heart recived {span / 1000}s ago");
// 重新登录
reConnectAsync();
reConnectAsync().Wait();
}
}
catch (Exception ex)
@ -99,8 +99,7 @@ namespace FastTunnel.Core.Core
_logger.LogError(ex.Message);
Thread.Sleep(reTrySpan);
reConnectAsync();
return;
await reConnectAsync();
}
LogSuccess(_client.Socket);
@ -138,7 +137,7 @@ namespace FastTunnel.Core.Core
_logger.LogError(ex.Message);
Thread.Sleep(reTrySpan);
reConnectAsync();
reConnectAsync().Wait();
return;
}

View File

@ -52,7 +52,7 @@ namespace FastTunnel.Core.Handlers.Client
throw;
}
}
catch (Exception ex)
catch (Exception)
{
localConnecter.Close();
throw;

View File

@ -46,20 +46,29 @@ namespace FastTunnel.Core.Handlers
foreach (var item in requet.Webs)
{
var hostName = $"{item.SubDomain}.{server.ServerSettings.WebDomain}".Trim();
if (server.WebList.ContainsKey(hostName))
{
_logger.LogDebug($"renew domain '{hostName}'");
server.WebList.TryRemove(hostName, out WebInfo web);
server.WebList.TryAdd(hostName, new WebInfo { Socket = client, WebConfig = item });
}
else
{
_logger.LogDebug($"new domain '{hostName}'");
server.WebList.TryAdd(hostName, new WebInfo { Socket = client, WebConfig = item });
}
var info = new WebInfo { Socket = client, WebConfig = item };
_logger.LogDebug($"new domain '{hostName}'");
server.WebList.AddOrUpdate(hostName, info, (key, info) => { return info; });
sb.Append($"{Environment.NewLine} http://{hostName}{(server.ServerSettings.WebHasNginxProxy ? string.Empty : ":" + server.ServerSettings.WebProxyPort)} => {item.LocalIp}:{item.LocalPort}");
if (item.WWW != null)
{
foreach (var www in item.WWW)
{
if (!www.EndsWith(server.ServerSettings.WebDomain))
{
server.WebList.AddOrUpdate(www, info, (key, info) => { return info; });
sb.Append($"{Environment.NewLine} http://{www}{(server.ServerSettings.WebHasNginxProxy ? string.Empty : ":" + server.ServerSettings.WebProxyPort)} => {item.LocalIp}:{item.LocalPort}");
}
else
{
// cant use WebDomain
_logger.LogDebug($"USE WebDomain IN WWW {www}");
sb.Append($"{Environment.NewLine} cant use {www}");
}
}
}
}
}

View File

@ -6,10 +6,24 @@ namespace FastTunnel.Core.Models
{
public class WebConfig
{
/// <summary>
/// 子域名
/// </summary>
public string SubDomain { get; set; }
/// <summary>
/// 本地IP
/// </summary>
public string LocalIp { get; set; }
/// <summary>
///
/// </summary>
public int LocalPort { get; set; }
/// <summary>
/// 个人域名
/// </summary>
public string[] WWW { get; set; }
}
}

View File

@ -78,7 +78,7 @@ namespace FastTunnel.Core
chanel.Send.Send(result, num, SocketFlags.None);
}
catch (SocketException sex)
catch (SocketException)
{
// Interrupted function call. 10004
// An existing connection was forcibly closed by the remote host. 10054

View File

@ -23,7 +23,7 @@ FastTunnel是一款高性能跨平台内网穿透工具使用它可以实现
- [x] 远程内网计算机 Windows/Linux/Mac
- [x] 用自定义域名访问内网web服务常用于微信开发
- [x] 端口转发/端口映射,访问内网任意端口提供的服务 mysql、redis、ftp等等
- [ ] Support any other domain names overlay current binding
- [x] Support any other domain names overlay current binding
- [ ] p2p穿透

View File

@ -23,7 +23,7 @@ FastTunnel是一款高性能跨平台内网穿透工具使用它可以实现
- [x] 远程内网计算机 Windows/Linux/Mac
- [x] 用自定义域名访问内网web服务常用于微信开发
- [x] 端口转发/端口映射,访问内网任意端口提供的服务 mysql、redis、ftp等等
- [ ] 支持任意其他多个域名覆盖绑定当前域名
- [x] 支持任意其他多个域名覆盖绑定当前域名
- [ ] p2p穿透