使用ICS的NAT

This commit is contained in:
snltty
2025-03-01 00:13:17 +08:00
parent 06e7c26cf9
commit d19e3470ce
49 changed files with 220 additions and 16 deletions

View File

@@ -59,7 +59,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "linker.messenger.tuntap", "
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "linker.messenger.serializer.aot", "src\linker.messenger.serializer.aot\linker.messenger.serializer.aot.csproj", "{0538DDF8-346F-48DE-84DF-AEF3EEBE03EA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "linker.app", "linker.app\linker.app.csproj", "{60FFFE21-C8F2-4B3A-BB49-7FA2AE31C2B0}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "linker.app", "src\linker.app\linker.app.csproj", "{60FFFE21-C8F2-4B3A-BB49-7FA2AE31C2B0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution

View File

Before

Width:  |  Height:  |  Size: 228 B

After

Width:  |  Height:  |  Size: 228 B

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 68 KiB

After

Width:  |  Height:  |  Size: 68 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@@ -60,5 +60,7 @@ sidebar_position: 1
1. win7 或 win8 可能需要安装一些环境,才能运行
2. <a href="https://aka.ms/vs/16/release/vc_redist.x64.exe" target="_blank">Microsoft Visual C++ 2015-2019 Redistributable </a>
3. <a href="https://www.microsoft.com/download/details.aspx?id=47442" target="_blank">KB3063858 </a>
4. <a href="https://www.microsoft.com/zh-cn/download/details.aspx?id=46148" target="_blank">KB3033929 </a>
:::

View File

@@ -7,4 +7,5 @@ sidebar_position: 2
1.`System(系统)``Software(软件包)``Update Package(更新列表)`先更新一下
2. 下载对应架构的ipk文件`System(系统)``Software(软件包)``Upload Package(上传软件包)`上传ipk文件安装
3. 如果ui无法安装或者安装失败可以尝试使用命令安装`opkg install --force-overwrite linker-xxx.ipk` 强制安装
4. 需要 `zlib`,`bash`,`iptables`,`kmod-tun`,`ip-full`,`kmod-ipt-nat`,`libstdcpp`,`libopenssl`,`libopenssl-legacy`
:::

View File

@@ -4,15 +4,9 @@ sidebar_position: 4
# 1.1.2、RRAS
:::danger[说明]
1. 操作不当可能会导致网络无法访问,请谨慎操作,最好先创建还原点
2. 有局限性,创建虚拟网卡后,需要重新`“配置并启用路由和远程访问”`
:::
:::tip[说明]
1. 在windows server中你可以选择使用RRAS(Routing and Remote Access Service) 来启用NAT从而实现点对网
:::
1. 操作不当可能会导致网络无法访问,请谨慎操作
2. 有局限性,创建虚拟网卡后,需要重新`“配置并启用路由和远程访问”`
![](./img/rras1.png)
![](./img/rras2.png)
@@ -27,7 +21,4 @@ sidebar_position: 4
![](./img/rras11.png)
![](./img/rras12.png)
![](./img/rras13.png)
:::danger[说明]
所有步骤已经结束了,没有其它操作
:::

View File

@@ -0,0 +1,12 @@
---
sidebar_position: 5
---
# 1.1.3、ICS
:::tip[说明]
1. 操作不当可能会导致网络无法访问,请谨慎操作
![](./img/ics1.png)
:::

View File

@@ -1,5 +1,5 @@
---
sidebar_position: 5
sidebar_position: 6
---
# 1.2、网对网

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

115
src/linker.ics/Program.cs Normal file
View File

@@ -0,0 +1,115 @@
using NETCONLib;
using System;
using System.Text;
namespace linker.ics
{
internal class Program
{
static void Main(string[] args)
{
string pulicName = args[0];
string privateName = args[1];
string type = args[2];
StringBuilder sb = new StringBuilder();
GetConnections(pulicName, privateName, out INetSharingConfiguration publicCon, out INetSharingConfiguration privateCon);
if (publicCon == null)
{
sb.Append($"{pulicName} public device not found!");
return;
}
else if (privateCon == null)
{
sb.Append($"{privateName} private device not found!");
return;
}
else if (type == "enable")
{
try
{
publicCon.EnableSharing(tagSHARINGCONNECTIONTYPE.ICSSHARINGTYPE_PUBLIC);
}
catch (Exception ex)
{
sb.Append($"{ex.Message},may need to be reboot system");
}
try
{
privateCon.EnableSharing(tagSHARINGCONNECTIONTYPE.ICSSHARINGTYPE_PRIVATE);
}
catch (Exception ex)
{
sb.Append($"{ex.Message},may need to be reboot system");
}
}
else if (type == "disable")
{
try
{
publicCon.DisableSharing();
}
catch (Exception ex)
{
sb.Append($"{ex.Message},may need to be reboot system");
}
try
{
privateCon.DisableSharing();
}
catch (Exception ex)
{
sb.Append($"{ex.Message},may need to be reboot system");
}
}
else
{
sb.Append($"{type} command invalid");
}
string result = sb.ToString();
if (string.IsNullOrEmpty(result))
{
Console.WriteLine($"{type} success");
}
else
{
Console.WriteLine(result);
}
}
static void GetConnections(string publicName, string privateName, out INetSharingConfiguration publicCon, out INetSharingConfiguration privateCon)
{
publicCon = null;
privateCon = null;
try
{
INetSharingManager netSharingManager = new NetSharingManager();
foreach (INetConnection connection in netSharingManager.EnumEveryConnection)
{
INetConnectionProps props = netSharingManager.NetConnectionProps[connection];
INetSharingConfiguration sharingConfig = netSharingManager.INetSharingConfigurationForINetConnection[connection];
try
{
if (props.Name == publicName)
{
publicCon = sharingConfig;
}
if (props.Name == privateName)
{
privateCon = sharingConfig;
}
}
catch (Exception)
{
}
}
}
catch (Exception)
{
}
}
}
}

View File

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

View File

@@ -0,0 +1,47 @@
<?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>{BBE91688-7734-4BEF-B957-54F8C17F47CE}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>linker.ics</RootNamespace>
<AssemblyName>linker.ics</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -37,7 +37,7 @@ namespace linker.messenger.tuntap
{
TimerHelper.SetInterval(async () =>
{
if (tuntapTransfer.Status == TuntapStatus.Running && lastTicksManager.DiffLessEqual(5000))
if (tuntapTransfer.Status == TuntapStatus.Running)
{
await Ping();
}

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<project ver="10" name="linker.tray.win" libEmbed="true" icon="..\linker\favicon.ico" ui="win" output="linker.tray.win.exe" CompanyName="snltty" FileDescription="linker.tray.win" LegalCopyright="Copyright (C) snltty 2024" ProductName="linker.tray.win" InternalName="linker.install.win" FileVersion="0.0.0.212" ProductVersion="0.0.0.212" publishDir="/dist/" dstrip="false" local="false" ignored="false">
<project ver="10" name="linker.tray.win" libEmbed="true" icon="..\linker\favicon.ico" ui="win" output="linker.tray.win.exe" CompanyName="snltty" FileDescription="linker.tray.win" LegalCopyright="Copyright (C) snltty 2024" ProductName="linker.tray.win" InternalName="linker.install.win" FileVersion="0.0.0.213" ProductVersion="0.0.0.213" publishDir="/dist/" dstrip="false" local="false" ignored="false">
<file name="main.aardio" path="main.aardio" comment="main.aardio"/>
<folder name="资源文件" path="res" embed="true" local="false" ignored="false">
<file name="favicon.ico" path="res\favicon.ico" comment="res\favicon.ico"/>

View File

@@ -1,5 +1,5 @@
v1.6.9
2025-02-27 15:04:12
2025-03-01 00:13:17
1. 修复litedb抢锁超时导致客户端登录失败问题
2. 同步信标服务器
3. 其它一些修复优化