Compare commits
2 Commits
73f1a15018
...
e5050fd937
| Author | SHA1 | Date | |
|---|---|---|---|
| e5050fd937 | |||
| 0b38c0ab17 |
Binary file not shown.
9
AxibugTransfer.Config/AxibugTransfer.Config.csproj
Normal file
9
AxibugTransfer.Config/AxibugTransfer.Config.csproj
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
55
AxibugTransfer.Config/Config.cs
Normal file
55
AxibugTransfer.Config/Config.cs
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace AxibugTransfer.Config
|
||||||
|
{
|
||||||
|
public struct CfgInfo
|
||||||
|
{
|
||||||
|
public int localPort;
|
||||||
|
public string targetIP;
|
||||||
|
public int targetPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Config
|
||||||
|
{
|
||||||
|
public static bool LoadConfig(out List<CfgInfo> cfgList)
|
||||||
|
{
|
||||||
|
cfgList = new List<CfgInfo>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
StreamReader sr = new StreamReader(System.Environment.CurrentDirectory + "\\config.cfg", Encoding.Default);
|
||||||
|
String line;
|
||||||
|
while (!string.IsNullOrEmpty((line = sr.ReadLine())))
|
||||||
|
{
|
||||||
|
if (!line.Contains(":"))
|
||||||
|
continue;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
CfgInfo cfg = new CfgInfo()
|
||||||
|
{
|
||||||
|
localPort = Convert.ToInt32(line.Split(':')[0].Trim()),
|
||||||
|
targetIP = line.Split(':')[1].Trim(),
|
||||||
|
targetPort = Convert.ToInt32(line.Split(':')[2].Trim())
|
||||||
|
};
|
||||||
|
cfgList.Add(cfg);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sr.Close();
|
||||||
|
|
||||||
|
if (cfgList.Count > 0)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("配置文件异常:"+ex.ToString());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,5 +0,0 @@
|
|||||||
using AxibugTransfer.Tcp;
|
|
||||||
|
|
||||||
new TcpTransfer(80, "Your IP", 8080, true).Start();
|
|
||||||
|
|
||||||
Console.ReadLine();
|
|
||||||
@ -3,9 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||||||
# Visual Studio Version 17
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.0.31903.59
|
VisualStudioVersion = 17.0.31903.59
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AxibugTransfer.Tcp", "AxibugTransfer.Tcp\AxibugTransfer.Tcp.csproj", "{B5A89E34-0283-44CB-8683-8E41888CA949}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AxibugTransfer.Tcp", "AxibugTransfer.Tcp\AxibugTransfer.Tcp.csproj", "{B5A89E34-0283-44CB-8683-8E41888CA949}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AxibugTransfer.Test", "AxibugTransfer.Test\AxibugTransfer.Test.csproj", "{A27FCE74-123D-477C-BB5B-2879D0B39D22}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AxibugTransfer.Config", "AxibugTransfer.Config\AxibugTransfer.Config.csproj", "{A4C29DED-B1B3-4312-8743-A2BF20188618}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AxibugTransfer", "AxibugTransfer\AxibugTransfer.csproj", "{69341276-017A-43F1-BC73-6123013C689F}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@ -17,10 +19,14 @@ Global
|
|||||||
{B5A89E34-0283-44CB-8683-8E41888CA949}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{B5A89E34-0283-44CB-8683-8E41888CA949}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{B5A89E34-0283-44CB-8683-8E41888CA949}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{B5A89E34-0283-44CB-8683-8E41888CA949}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{B5A89E34-0283-44CB-8683-8E41888CA949}.Release|Any CPU.Build.0 = Release|Any CPU
|
{B5A89E34-0283-44CB-8683-8E41888CA949}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{A27FCE74-123D-477C-BB5B-2879D0B39D22}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{A4C29DED-B1B3-4312-8743-A2BF20188618}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{A27FCE74-123D-477C-BB5B-2879D0B39D22}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{A4C29DED-B1B3-4312-8743-A2BF20188618}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{A27FCE74-123D-477C-BB5B-2879D0B39D22}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{A4C29DED-B1B3-4312-8743-A2BF20188618}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{A27FCE74-123D-477C-BB5B-2879D0B39D22}.Release|Any CPU.Build.0 = Release|Any CPU
|
{A4C29DED-B1B3-4312-8743-A2BF20188618}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{69341276-017A-43F1-BC73-6123013C689F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{69341276-017A-43F1-BC73-6123013C689F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{69341276-017A-43F1-BC73-6123013C689F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{69341276-017A-43F1-BC73-6123013C689F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\AxibugTransfer.Config\AxibugTransfer.Config.csproj" />
|
||||||
<ProjectReference Include="..\AxibugTransfer.Tcp\AxibugTransfer.Tcp.csproj" />
|
<ProjectReference Include="..\AxibugTransfer.Tcp\AxibugTransfer.Tcp.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
14
AxibugTransfer/Program.cs
Normal file
14
AxibugTransfer/Program.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using AxibugTransfer.Tcp;
|
||||||
|
using AxibugTransfer.Config;
|
||||||
|
|
||||||
|
if (!Config.LoadConfig(out List<CfgInfo> cfgList))
|
||||||
|
{
|
||||||
|
Console.WriteLine("请检查配置文件!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (CfgInfo cfg in cfgList)
|
||||||
|
new TcpTransfer(cfg.localPort, cfg.targetIP, cfg.targetPort, true).Start();
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
Console.ReadLine();
|
||||||
1
AxibugTransfer/bin/Debug/net6.0/config.cfg
Normal file
1
AxibugTransfer/bin/Debug/net6.0/config.cfg
Normal file
@ -0,0 +1 @@
|
|||||||
|
80:127.0.0.1:8080
|
||||||
28
README.md
28
README.md
@ -1,3 +1,29 @@
|
|||||||
# AxibugTransfer
|
# AxibugTransfer
|
||||||
|
|
||||||
一个自封装的端口转发类库
|
一个自制的开源端口转发工具 By 皓月
|
||||||
|
dotNet 版本: .Net 6
|
||||||
|
平台: Windows/Linux/Other..
|
||||||
|
|
||||||
|
项目"AxibugTransfer"为控制台版本项目
|
||||||
|
项目"AxibugTransfer.Tcp"为TCP端口转发库
|
||||||
|
|
||||||
|
##控制台版本使用方法
|
||||||
|
|
||||||
|
下载Release版本,或者自编译AxibugTransfer项目.
|
||||||
|
编辑可执行程序目录的config.cfg配置文件
|
||||||
|
|
||||||
|
格式(可多行)
|
||||||
|
本地监听端口:目标IP:目标端口
|
||||||
|
|
||||||
|
如:
|
||||||
|
80:1.2.3.4:8080
|
||||||
|
81:1.2.3.4:8081
|
||||||
|
|
||||||
|
标识
|
||||||
|
将本地80端口TCP/HTTP请求转发到1.2.3.4的8080端口上
|
||||||
|
将本地81端口 转发到1.2.3.4的8081端口上
|
||||||
|
|
||||||
|
TODO:
|
||||||
|
完善的统计功能
|
||||||
|
使用 IOCP/epoll 提升性能
|
||||||
|
也许做一个GUI版本
|
||||||
Loading…
Reference in New Issue
Block a user