diff --git a/.editorconfig b/.editorconfig index 567e59f..61cc4da 100644 --- a/.editorconfig +++ b/.editorconfig @@ -261,4 +261,99 @@ dotnet_diagnostic.CA2016.severity = suggestion [{**/Shared/runtime/**.{cs,vb},src/Shared/test/Shared.Tests/runtime/**.{cs,vb},**/microsoft.extensions.hostfactoryresolver.sources/**.{cs,vb}}] # IDE0161: Convert to file-scoped namespace -dotnet_diagnostic.IDE0161.severity = silent \ No newline at end of file +dotnet_diagnostic.IDE0161.severity = silent +[*.cs] +#### 命名样式 #### + +# 命名规则 + +dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion +dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface +dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i + +dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.types_should_be_pascal_case.symbols = types +dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case + +dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members +dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case + +# 符号规范 + +dotnet_naming_symbols.interface.applicable_kinds = interface +dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.interface.required_modifiers = + +dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum +dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.types.required_modifiers = + +dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method +dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.non_field_members.required_modifiers = + +# 命名样式 + +dotnet_naming_style.begins_with_i.required_prefix = I +dotnet_naming_style.begins_with_i.required_suffix = +dotnet_naming_style.begins_with_i.word_separator = +dotnet_naming_style.begins_with_i.capitalization = pascal_case + +dotnet_naming_style.pascal_case.required_prefix = +dotnet_naming_style.pascal_case.required_suffix = +dotnet_naming_style.pascal_case.word_separator = +dotnet_naming_style.pascal_case.capitalization = pascal_case + +dotnet_naming_style.pascal_case.required_prefix = +dotnet_naming_style.pascal_case.required_suffix = +dotnet_naming_style.pascal_case.word_separator = +dotnet_naming_style.pascal_case.capitalization = pascal_case + +[*.vb] +#### 命名样式 #### + +# 命名规则 + +dotnet_naming_rule.interface_should_be_以_i_开始.severity = suggestion +dotnet_naming_rule.interface_should_be_以_i_开始.symbols = interface +dotnet_naming_rule.interface_should_be_以_i_开始.style = 以_i_开始 + +dotnet_naming_rule.类型_should_be_帕斯卡拼写法.severity = suggestion +dotnet_naming_rule.类型_should_be_帕斯卡拼写法.symbols = 类型 +dotnet_naming_rule.类型_should_be_帕斯卡拼写法.style = 帕斯卡拼写法 + +dotnet_naming_rule.非字段成员_should_be_帕斯卡拼写法.severity = suggestion +dotnet_naming_rule.非字段成员_should_be_帕斯卡拼写法.symbols = 非字段成员 +dotnet_naming_rule.非字段成员_should_be_帕斯卡拼写法.style = 帕斯卡拼写法 + +# 符号规范 + +dotnet_naming_symbols.interface.applicable_kinds = interface +dotnet_naming_symbols.interface.applicable_accessibilities = public, friend, private, protected, protected_friend, private_protected +dotnet_naming_symbols.interface.required_modifiers = + +dotnet_naming_symbols.类型.applicable_kinds = class, struct, interface, enum +dotnet_naming_symbols.类型.applicable_accessibilities = public, friend, private, protected, protected_friend, private_protected +dotnet_naming_symbols.类型.required_modifiers = + +dotnet_naming_symbols.非字段成员.applicable_kinds = property, event, method +dotnet_naming_symbols.非字段成员.applicable_accessibilities = public, friend, private, protected, protected_friend, private_protected +dotnet_naming_symbols.非字段成员.required_modifiers = + +# 命名样式 + +dotnet_naming_style.以_i_开始.required_prefix = I +dotnet_naming_style.以_i_开始.required_suffix = +dotnet_naming_style.以_i_开始.word_separator = +dotnet_naming_style.以_i_开始.capitalization = pascal_case + +dotnet_naming_style.帕斯卡拼写法.required_prefix = +dotnet_naming_style.帕斯卡拼写法.required_suffix = +dotnet_naming_style.帕斯卡拼写法.word_separator = +dotnet_naming_style.帕斯卡拼写法.capitalization = pascal_case + +dotnet_naming_style.帕斯卡拼写法.required_prefix = +dotnet_naming_style.帕斯卡拼写法.required_suffix = +dotnet_naming_style.帕斯卡拼写法.word_separator = +dotnet_naming_style.帕斯卡拼写法.capitalization = pascal_case diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000..d9826be --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,20 @@ + + + 3.0.0-Beta.1.22511 + net6.0 + https://github.com/SpringHgui/FastTunnel + Apache2.0 + FastTunnel + expose a local server behind a NAT or firewall to the internet like ngrok and frp + Gui.H + FastTunnel + FastTunnel + true + true + https://github.com/SpringHgui/FastTunnel + git + 鍐呯綉绌块;Proxy;TCP;HTTP;NAT;Tunnel + true + 10.0 + + diff --git a/FastTunnel.Api/FastTunnel.Api.csproj b/FastTunnel.Api/FastTunnel.Api.csproj index 8332ed2..9b44515 100644 --- a/FastTunnel.Api/FastTunnel.Api.csproj +++ b/FastTunnel.Api/FastTunnel.Api.csproj @@ -1,20 +1,17 @@ - - net6.0 - 1.1.0 - https://github.com/FastTunnel/FastTunnel/tree/v2/FastTunnel.Api - https://github.com/FastTunnel/FastTunnel/tree/v2/FastTunnel.Api - - - - - - - - + + net5.0;net6.0 + + + + + + + + - - - + + + diff --git a/FastTunnel.Client/FastTunnel.Client.csproj b/FastTunnel.Client/FastTunnel.Client.csproj index 6919d74..9d20edd 100644 --- a/FastTunnel.Client/FastTunnel.Client.csproj +++ b/FastTunnel.Client/FastTunnel.Client.csproj @@ -1,6 +1,5 @@ - net6.0 Exe diff --git a/FastTunnel.Core/FastTunnel.Core.csproj b/FastTunnel.Core/FastTunnel.Core.csproj index ec590b9..83ffd4e 100644 --- a/FastTunnel.Core/FastTunnel.Core.csproj +++ b/FastTunnel.Core/FastTunnel.Core.csproj @@ -1,27 +1,19 @@ - - net6.0 - 2.1.0 - https://github.com/SpringHgui/FastTunnel - MIT - FastTunnel - expose a local server behind a NAT or firewall to the internet like ngrok and frp - Gui.H - FastTunnel - FastTunnel - false - true - https://github.com/SpringHgui/FastTunnel - git - FastTunnel.Core - true - FastTunnel.Core + README.md + net5.0;net6.0 - + + + + + + + + @@ -43,4 +35,11 @@ + + + True + \ + + + diff --git a/FastTunnel.Core/Forwarder/MiddleWare/DuplexPipeStream.cs b/FastTunnel.Core/Forwarder/MiddleWare/DuplexPipeStream.cs index 8acb3d2..705531a 100644 --- a/FastTunnel.Core/Forwarder/MiddleWare/DuplexPipeStream.cs +++ b/FastTunnel.Core/Forwarder/MiddleWare/DuplexPipeStream.cs @@ -116,7 +116,9 @@ internal class DuplexPipeStream : Stream return _output.FlushAsync(cancellationToken).GetAsTask(); } +#if NET6_0_OR_GREATER [AsyncMethodBuilder(typeof(PoolingAsyncValueTaskMethodBuilder<>))] +#endif private async ValueTask ReadAsyncInternal(Memory destination, CancellationToken cancellationToken) { while (true) diff --git a/FastTunnel.Hosting/FastTunnel.Hosting.csproj b/FastTunnel.Hosting/FastTunnel.Hosting.csproj index fb436fe..24c580f 100644 --- a/FastTunnel.Hosting/FastTunnel.Hosting.csproj +++ b/FastTunnel.Hosting/FastTunnel.Hosting.csproj @@ -1,18 +1,29 @@ - - net6.0 enable enable + README.md + net5.0;net6.0 - + + + + + - + + + + True + \ + + + diff --git a/FastTunnel.Hosting/README.md b/FastTunnel.Hosting/README.md new file mode 100644 index 0000000..e9295b3 --- /dev/null +++ b/FastTunnel.Hosting/README.md @@ -0,0 +1,166 @@ +
+ + + +## FastTunnel +[![License](https://img.shields.io/badge/license-Apache%202-green.svg)](https://www.apache.org/licenses/LICENSE-2.0) +[![Build status](https://github.com/anjoy8/blog.core/workflows/.NET%20Core/badge.svg)](https://github.com/SpringHgui/FastTunnel/actions) +[![Nuget](https://img.shields.io/nuget/v/FastTunnel.Core)](https://www.nuget.org/packages/FastTunnel.Core/) +[![Nuget](https://img.shields.io/nuget/dt/FastTunnel.Core)](https://www.nuget.org/packages/FastTunnel.Core/) + +[README](README.md) | [涓枃鏂囨。](README_zh.md) + + ***This project supports any commercial and secondary development activities, but seriously despises plagiarizing and copying the code, implementation scheme or architecture of this project and repackaging them into their own open source works.*** + +
+ + +## What is FastTunnel锛 +- FastTunnel is a high-performance cross-platform intranet penetration tool. With it, you can expose intranet services to the public network for yourself or anyone to access. +- Unlike other penetration tools, the FastTunnel project is committed to creating an easy-to-extensible and easy-to-maintain intranet penetration framework. +- You can build your own penetration application by referencing the nuget package of `FastTunnel.Core`, and target the business extension functions you need. + + +*** + +Official website : https://suidao.io + +The penetration platform developed based on this framework, if you need intranet penetration, you can register and use it directly, eliminating the cost of building and maintaining yourself. +But do not use this service for important items. + +OpenSource锛 + +GitHub : [FastTunnel](https://github.com/SpringHgui/FastTunnel) +Gitee: [FastTunnel](https://gitee.com/Hgui/FastTunnel) + +**If helpful, click on 猸怱tar to support this project, please submit an issue if you have needs and bugs, and welcome coder to PR** + +## Get GVP + +![img1](images/gvp.png) +*** + +## What can FastTunel do锛 +- [x] Remote intranet computer Windows/Linux/Mac +- [x] Use a custom domain name to access intranet web services (usually used for WeChat development) +- [x] Port forwarding/port mapping, access services provided by any port on the intranet mysql, redis, ftp, etc. +- [ ] p2p penetration +- [x] Support binding multiple domain names to access intranet services +- [x] Support domain name whitelist restriction +- [x] Support client identity verification + +## Quickstart +1. Download the corresponding program on the [releases](https://github.com/SpringHgui/FastTunnel/releases) page +2. Modify the client and server configuration files according to your needs`appsettings.json` +3. Run FastTunnel.Server +4. Run FastTunnel.Cient + +## Install FastTunel.Sever using Docker Engine +Configuration files and log files are mounted through volume. If this image has been run before, docker may not update to the latest image. Please delete the existing image manually, and then execute the following command + +``` +docker run --detach \ + --publish 1270:1270 --publish 1271:1271 \ + --name FastTunnel \ + --restart always \ + --volume /var/FastTunnel/config:/app/config \ + --volume /var/FastTunnel/Logs:/app/Logs \ + springhgui/fasttunnel:latest +``` +## Run on Linux/Mac os锛 +#### Windows +Double click directly `FastTunnel.Client.exe` to run +#### Linux +`chmod +x FastTunnel.Client` +`./FastTunnel.Client` +#### Mac +click directly `FastTunnel.Client` to run + +## Configuration example +### 1. Use a custom domain name to access intranet web services +- For example, you have a server with a public IP address of `110.110.110.110`, and you have a domain name with a top-level domain name of `abc.com`, you want to visit a website on the intranet by visiting `test.abc.com` +- You need to add a DNS resolution for the domain name address, the type is `A`, the name is `*`, and the ipv4 address is `110.110.110.110`, so that all domain names of `*.abc.com` will point to `110.110.110.110`鈥檚 server, because the default http port of `FastTunnel` is 1270, so you need to visit`http://test.abc.com:1270` + +- #### If you don't want to bring the port number every time you visit, you can use `nginx` forwarding. +``` +http { + # add resolver + resolver 8.8.8.8; + + # set *.abc.com to 1270 port + server { + server_name *.abc.com; + location / { + proxy_pass http://$host:1270; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + + # 鍙 + error_log /var/log/nginx/error_ft.log error; + } +} +``` + +- If the domain name configured on the server is `ft.suidao.io`, then access the local site through the subdomain name `test.ft.suidao.io:1270`, the IIS configuration is as follows: +![img1](images/iis-web.png) + +### 2. Remote intranet computer Windows/Linux/Mac + +The client configuration is as follows, there are two hosts in the intranet, and the ip is as follows: +appsettings.json +``` + "ClientSettings": { + "Common": { + "ServerAddr": "xxx.xxx.xxx.xxx", + "ServerPort": 1271 + }, + "SSH": [ + { + "LocalIp": "192.168.0.100", // linux pc + "LocalPort": 22, // ssh default port + "RemotePort": 12701 + }, + { + "LocalIp": "192.168.0.101", // windows pc + "LocalPort": 3389, // windows default port for Remote + "RemotePort": 12702 + } + ] + } +``` +#### remote intranet linux host by ssh (ip:192.168.0.100) + +Assuming that the user name of the intranet host is root, the server ip is x.x.x.x, and the two hosts that access the intranet are as follows +``` +ssh -oPort=12701 root@x.x.x.x +``` + +#### remote desktop Windows host by mstsc (ip:192.168.0.101) +#### Controlled terminal setting +- Open cmd and enter the command `sysdm.cpl` in the pop-up dialog box and select Allow remote connection to this computer + +![img1](images/setallow.png) +#### Control terminal settings +- Open cmd and enter the command `mstsc`, open the remote dialog box, enter `x.x.x.x:12701` in the computer input box of the dialog box, and then specify the user name and password to remote the windows host of the intranet +![img1](images/remote.png) + +## Development/PR +- install `vs2019` last version +- install `.net5` or higher `https://dotnet.microsoft.com/download/dotnet/5.0` +- add `test.test.cc 127.0.0.1` in system host file +- run fasttunnel.server +- run fasttunnel.client + +## contributors + + + + +## Join QQ Group + +
+ +## License +Apache License 2.0 diff --git a/FastTunnel.Server/FastTunnel.Server.csproj b/FastTunnel.Server/FastTunnel.Server.csproj index e888399..d5604be 100644 --- a/FastTunnel.Server/FastTunnel.Server.csproj +++ b/FastTunnel.Server/FastTunnel.Server.csproj @@ -6,7 +6,6 @@ - net6.0 false diff --git a/FastTunnel.sln b/FastTunnel.sln index 3033bc0..4dcbf63 100644 --- a/FastTunnel.sln +++ b/FastTunnel.sln @@ -16,9 +16,11 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{54494A47-33E6-488B-B7D4-DBE8FD34916A}" ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig + Directory.Build.props = Directory.Build.props + .github\workflows\dotnetcore.yml = .github\workflows\dotnetcore.yml EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FastTunnel.Hosting", "FastTunnel.Hosting\FastTunnel.Hosting.csproj", "{D7F07110-E85C-4F0E-B479-AEC9760CD2A7}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FastTunnel.Hosting", "FastTunnel.Hosting\FastTunnel.Hosting.csproj", "{D7F07110-E85C-4F0E-B479-AEC9760CD2A7}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution