[Redirector] Add Tester

This commit is contained in:
Connection Refused
2021-10-14 18:39:28 +08:00
parent 07dafa7bc5
commit b4c368c057
8 changed files with 248 additions and 6 deletions

View File

@@ -1,16 +1,31 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31205.134
# Visual Studio Version 17
VisualStudioVersion = 17.0.31808.319
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Netch", "Netch\Netch.csproj", "{A193DF89-ADCF-4DB4-B75C-729C8BA8A9F3}"
ProjectSection(ProjectDependencies) = postProject
{9142C528-9E42-448D-96B6-7E62E47B54F3} = {9142C528-9E42-448D-96B6-7E62E47B54F3}
{1676DEF3-FBE4-47D2-93A6-8F85EA2F5B74} = {1676DEF3-FBE4-47D2-93A6-8F85EA2F5B74}
{7374F7F4-1732-4DED-A603-8335F6704F10} = {7374F7F4-1732-4DED-A603-8335F6704F10}
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tests", "Tests\Tests.csproj", "{09222C6B-2FFB-4DA7-BC75-CB0A80086711}"
ProjectSection(ProjectDependencies) = postProject
{A193DF89-ADCF-4DB4-B75C-729C8BA8A9F3} = {A193DF89-ADCF-4DB4-B75C-729C8BA8A9F3}
{1676DEF3-FBE4-47D2-93A6-8F85EA2F5B74} = {1676DEF3-FBE4-47D2-93A6-8F85EA2F5B74}
{7374F7F4-1732-4DED-A603-8335F6704F10} = {7374F7F4-1732-4DED-A603-8335F6704F10}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Redirector", "Redirector\Redirector.vcxproj", "{1676DEF3-FBE4-47D2-93A6-8F85EA2F5B74}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RouteHelper", "RouteHelper\RouteHelper.vcxproj", "{7374F7F4-1732-4DED-A603-8335F6704F10}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RedirectorTester", "RedirectorTester\RedirectorTester.csproj", "{9142C528-9E42-448D-96B6-7E62E47B54F3}"
ProjectSection(ProjectDependencies) = postProject
{1676DEF3-FBE4-47D2-93A6-8F85EA2F5B74} = {1676DEF3-FBE4-47D2-93A6-8F85EA2F5B74}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
@@ -32,6 +47,9 @@ Global
{7374F7F4-1732-4DED-A603-8335F6704F10}.Debug|x64.Build.0 = Debug|x64
{7374F7F4-1732-4DED-A603-8335F6704F10}.Release|x64.ActiveCfg = Release|x64
{7374F7F4-1732-4DED-A603-8335F6704F10}.Release|x64.Build.0 = Release|x64
{9142C528-9E42-448D-96B6-7E62E47B54F3}.Debug|x64.ActiveCfg = Debug|x64
{9142C528-9E42-448D-96B6-7E62E47B54F3}.Debug|x64.Build.0 = Debug|x64
{9142C528-9E42-448D-96B6-7E62E47B54F3}.Release|x64.ActiveCfg = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@@ -45,16 +45,16 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(ProjectDir)bin\</OutDir>
<IntDir>$(ProjectDir)obj\</IntDir>
<OutDir>$(ProjectDir)bin\$(Configuration)\</OutDir>
<IntDir>$(ProjectDir)obj\$(Configuration)\</IntDir>
<TargetExt>.bin</TargetExt>
<IncludePath>$(ProjectDir)include\;$(IncludePath)</IncludePath>
<LibraryPath>$(ProjectDir)lib\;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(ProjectDir)bin\</OutDir>
<IntDir>$(ProjectDir)obj\</IntDir>
<OutDir>$(ProjectDir)bin\$(Configuration)\</OutDir>
<IntDir>$(ProjectDir)obj\$(Configuration)\</IntDir>
<TargetExt>.bin</TargetExt>
<IncludePath>$(ProjectDir)include\;$(IncludePath)</IncludePath>
<LibraryPath>$(ProjectDir)lib\;$(LibraryPath)</LibraryPath>

3
RedirectorTester/.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
/bin
/obj
/*.csproj.user

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
</configuration>

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />
<!-- Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
</compatibility>
</assembly>

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("RedirectorTester")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RedirectorTester")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("9142c528-9e42-448d-96b6-7e62e47b54f3")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,87 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace RedirectorTester
{
public class RedirectorTester
{
public enum NameList : int
{
AIO_FILTERLOOPBACK,
AIO_FILTERINTRANET,
AIO_FILTERPARENT,
AIO_FILTERICMP,
AIO_FILTERTCP,
AIO_FILTERUDP,
AIO_FILTERDNS,
AIO_ICMPING,
AIO_DNSHOST,
AIO_DNSPORT,
AIO_TGTHOST,
AIO_TGTPORT,
AIO_TGTUSER,
AIO_TGTPASS,
AIO_CLRNAME,
AIO_ADDNAME,
AIO_BYPNAME
}
[DllImport("Redirector.bin", CallingConvention = CallingConvention.Cdecl)]
public static extern bool aio_register([MarshalAs(UnmanagedType.LPWStr)] string value);
[DllImport("Redirector.bin", CallingConvention = CallingConvention.Cdecl)]
public static extern bool aio_unregister([MarshalAs(UnmanagedType.LPWStr)] string value);
[DllImport("Redirector.bin", CallingConvention = CallingConvention.Cdecl)]
public static extern bool aio_dial(NameList name, [MarshalAs(UnmanagedType.LPWStr)] string value);
[DllImport("Redirector.bin", CallingConvention = CallingConvention.Cdecl)]
public static extern bool aio_init();
[DllImport("Redirector.bin", CallingConvention = CallingConvention.Cdecl)]
public static extern void aio_free();
[DllImport("Redirector.bin", CallingConvention = CallingConvention.Cdecl)]
public static extern ulong aio_getUP();
[DllImport("Redirector.bin", CallingConvention = CallingConvention.Cdecl)]
public static extern ulong aio_getDL();
public static void Main(string[] args)
{
aio_dial(NameList.AIO_FILTERLOOPBACK, "false");
aio_dial(NameList.AIO_FILTERINTRANET, "false");
aio_dial(NameList.AIO_FILTERPARENT, "false");
aio_dial(NameList.AIO_FILTERICMP, "true");
aio_dial(NameList.AIO_FILTERTCP, "true");
aio_dial(NameList.AIO_FILTERUDP, "true");
aio_dial(NameList.AIO_FILTERDNS, "false");
aio_dial(NameList.AIO_ICMPING, "10");
aio_dial(NameList.AIO_DNSHOST, "1.1.1.1");
aio_dial(NameList.AIO_DNSPORT, "53");
aio_dial(NameList.AIO_TGTHOST, "127.0.0.1");
aio_dial(NameList.AIO_TGTPORT, "1080");
aio_dial(NameList.AIO_TGTUSER, "");
aio_dial(NameList.AIO_TGTPASS, "");
aio_dial(NameList.AIO_CLRNAME, "");
aio_dial(NameList.AIO_ADDNAME, "Telegram");
aio_dial(NameList.AIO_ADDNAME, "NatTypeTester");
aio_init();
Console.ReadLine();
aio_free();
}
}
}

View File

@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{9142C528-9E42-448D-96B6-7E62E47B54F3}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>RedirectorTester</RootNamespace>
<AssemblyName>RedirectorTester</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<StartupObject>RedirectorTester.RedirectorTester</StartupObject>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>App.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="RedirectorTester.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="App.manifest" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>COPY /Y $(SolutionDir)Redirector\bin\$(Configuration)\Redirector.bin $(TargetDir) &gt; NUL 2&gt;&amp;1
COPY /Y $(SolutionDir)Redirector\bin\$(Configuration)\Redirector.pdb $(TargetDir) &gt; NUL 2&gt;&amp;1</PostBuildEvent>
</PropertyGroup>
</Project>