mirror of
https://github.com/snltty/linker.git
synced 2025-10-22 08:39:27 +08:00
sync
This commit is contained in:
30
.github/workflows/dotnet.yml
vendored
30
.github/workflows/dotnet.yml
vendored
@@ -33,11 +33,11 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.ACTIONS_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.ACTIONS_TOKEN }}
|
||||||
with:
|
with:
|
||||||
tag_name: v1.4.9
|
tag_name: v1.5.0
|
||||||
release_name: v1.4.9.${{ steps.date.outputs.today }}
|
release_name: v1.5.0.${{ steps.date.outputs.today }}
|
||||||
draft: false
|
draft: false
|
||||||
prerelease: false
|
prerelease: false
|
||||||
body: "1. 新增多分组管理,方便分组切换\r\n2. 增加分组密码,提高分组隔离安全性\r\n3. 优化配置同步,可自由选择同步哪些信息\r\n4. 自动分配虚拟网卡IP\r\n5. 线程池优化\r\n6. 一些UI优化"
|
body: "1. 新增多分组管理,方便分组切换\r\n2. 增加分组密码,提高分组隔离安全性\r\n3. 优化配置同步,可自由选择同步哪些信息\r\n4. 自动分配虚拟网卡IP\r\n5. 线程池优化\r\n6. 一些UI优化\r\n7. 测试中,不要更新,不要更新,不要更新,请使用v1.4.9"
|
||||||
- name: upload-win-x86-oss
|
- name: upload-win-x86-oss
|
||||||
id: upload-win-x86-oss
|
id: upload-win-x86-oss
|
||||||
uses: tvrcgo/oss-action@v0.1.1
|
uses: tvrcgo/oss-action@v0.1.1
|
||||||
@@ -47,7 +47,7 @@ jobs:
|
|||||||
key-secret: ${{ secrets.ALIYUN_OSS_SECRET }}
|
key-secret: ${{ secrets.ALIYUN_OSS_SECRET }}
|
||||||
bucket: ide-qbcode
|
bucket: ide-qbcode
|
||||||
asset-path: ./public/publish-zip/linker-win-x86.zip
|
asset-path: ./public/publish-zip/linker-win-x86.zip
|
||||||
target-path: /downloads/linker/v1.4.9/linker-win-x86.zip
|
target-path: /downloads/linker/v1.5.0/linker-win-x86.zip
|
||||||
- name: upload-win-x86
|
- name: upload-win-x86
|
||||||
id: upload-win-x86
|
id: upload-win-x86
|
||||||
uses: actions/upload-release-asset@master
|
uses: actions/upload-release-asset@master
|
||||||
@@ -67,7 +67,7 @@ jobs:
|
|||||||
key-secret: ${{ secrets.ALIYUN_OSS_SECRET }}
|
key-secret: ${{ secrets.ALIYUN_OSS_SECRET }}
|
||||||
bucket: ide-qbcode
|
bucket: ide-qbcode
|
||||||
asset-path: ./public/publish-zip/linker-win-x64.zip
|
asset-path: ./public/publish-zip/linker-win-x64.zip
|
||||||
target-path: /downloads/linker/v1.4.9/linker-win-x64.zip
|
target-path: /downloads/linker/v1.5.0/linker-win-x64.zip
|
||||||
- name: upload-win-x64
|
- name: upload-win-x64
|
||||||
id: upload-win-x64
|
id: upload-win-x64
|
||||||
uses: actions/upload-release-asset@master
|
uses: actions/upload-release-asset@master
|
||||||
@@ -87,7 +87,7 @@ jobs:
|
|||||||
key-secret: ${{ secrets.ALIYUN_OSS_SECRET }}
|
key-secret: ${{ secrets.ALIYUN_OSS_SECRET }}
|
||||||
bucket: ide-qbcode
|
bucket: ide-qbcode
|
||||||
asset-path: ./public/publish-zip/linker-win-arm64.zip
|
asset-path: ./public/publish-zip/linker-win-arm64.zip
|
||||||
target-path: /downloads/linker/v1.4.9/linker-win-arm64.zip
|
target-path: /downloads/linker/v1.5.0/linker-win-arm64.zip
|
||||||
- name: upload-win-arm64
|
- name: upload-win-arm64
|
||||||
id: upload-win-arm64
|
id: upload-win-arm64
|
||||||
uses: actions/upload-release-asset@master
|
uses: actions/upload-release-asset@master
|
||||||
@@ -107,7 +107,7 @@ jobs:
|
|||||||
key-secret: ${{ secrets.ALIYUN_OSS_SECRET }}
|
key-secret: ${{ secrets.ALIYUN_OSS_SECRET }}
|
||||||
bucket: ide-qbcode
|
bucket: ide-qbcode
|
||||||
asset-path: ./public/publish-zip/linker-linux-x64.zip
|
asset-path: ./public/publish-zip/linker-linux-x64.zip
|
||||||
target-path: /downloads/linker/v1.4.9/linker-linux-x64.zip
|
target-path: /downloads/linker/v1.5.0/linker-linux-x64.zip
|
||||||
- name: upload-linux-x64
|
- name: upload-linux-x64
|
||||||
id: upload-linux-x64
|
id: upload-linux-x64
|
||||||
uses: actions/upload-release-asset@master
|
uses: actions/upload-release-asset@master
|
||||||
@@ -127,7 +127,7 @@ jobs:
|
|||||||
key-secret: ${{ secrets.ALIYUN_OSS_SECRET }}
|
key-secret: ${{ secrets.ALIYUN_OSS_SECRET }}
|
||||||
bucket: ide-qbcode
|
bucket: ide-qbcode
|
||||||
asset-path: ./public/publish-zip/linker-linux-arm.zip
|
asset-path: ./public/publish-zip/linker-linux-arm.zip
|
||||||
target-path: /downloads/linker/v1.4.9/linker-linux-arm.zip
|
target-path: /downloads/linker/v1.5.0/linker-linux-arm.zip
|
||||||
- name: upload-linux-arm
|
- name: upload-linux-arm
|
||||||
id: upload-linux-arm
|
id: upload-linux-arm
|
||||||
uses: actions/upload-release-asset@master
|
uses: actions/upload-release-asset@master
|
||||||
@@ -147,7 +147,7 @@ jobs:
|
|||||||
key-secret: ${{ secrets.ALIYUN_OSS_SECRET }}
|
key-secret: ${{ secrets.ALIYUN_OSS_SECRET }}
|
||||||
bucket: ide-qbcode
|
bucket: ide-qbcode
|
||||||
asset-path: ./public/publish-zip/linker-linux-arm64.zip
|
asset-path: ./public/publish-zip/linker-linux-arm64.zip
|
||||||
target-path: /downloads/linker/v1.4.9/linker-linux-arm64.zip
|
target-path: /downloads/linker/v1.5.0/linker-linux-arm64.zip
|
||||||
- name: upload-linux-arm64
|
- name: upload-linux-arm64
|
||||||
id: upload-linux-arm64
|
id: upload-linux-arm64
|
||||||
uses: actions/upload-release-asset@master
|
uses: actions/upload-release-asset@master
|
||||||
@@ -167,7 +167,7 @@ jobs:
|
|||||||
key-secret: ${{ secrets.ALIYUN_OSS_SECRET }}
|
key-secret: ${{ secrets.ALIYUN_OSS_SECRET }}
|
||||||
bucket: ide-qbcode
|
bucket: ide-qbcode
|
||||||
asset-path: ./public/publish-zip/linker-linux-musl-x64.zip
|
asset-path: ./public/publish-zip/linker-linux-musl-x64.zip
|
||||||
target-path: /downloads/linker/v1.4.9/linker-linux-musl-x64.zip
|
target-path: /downloads/linker/v1.5.0/linker-linux-musl-x64.zip
|
||||||
- name: upload-linux-musl-x64
|
- name: upload-linux-musl-x64
|
||||||
id: upload-linux-musl-x64
|
id: upload-linux-musl-x64
|
||||||
uses: actions/upload-release-asset@master
|
uses: actions/upload-release-asset@master
|
||||||
@@ -187,7 +187,7 @@ jobs:
|
|||||||
key-secret: ${{ secrets.ALIYUN_OSS_SECRET }}
|
key-secret: ${{ secrets.ALIYUN_OSS_SECRET }}
|
||||||
bucket: ide-qbcode
|
bucket: ide-qbcode
|
||||||
asset-path: ./public/publish-zip/linker-linux-musl-arm.zip
|
asset-path: ./public/publish-zip/linker-linux-musl-arm.zip
|
||||||
target-path: /downloads/linker/v1.4.9/linker-linux-musl-arm.zip
|
target-path: /downloads/linker/v1.5.0/linker-linux-musl-arm.zip
|
||||||
- name: upload-linux-musl-arm
|
- name: upload-linux-musl-arm
|
||||||
id: upload-linux-musl-arm
|
id: upload-linux-musl-arm
|
||||||
uses: actions/upload-release-asset@master
|
uses: actions/upload-release-asset@master
|
||||||
@@ -207,7 +207,7 @@ jobs:
|
|||||||
key-secret: ${{ secrets.ALIYUN_OSS_SECRET }}
|
key-secret: ${{ secrets.ALIYUN_OSS_SECRET }}
|
||||||
bucket: ide-qbcode
|
bucket: ide-qbcode
|
||||||
asset-path: ./public/publish-zip/linker-linux-musl-arm64.zip
|
asset-path: ./public/publish-zip/linker-linux-musl-arm64.zip
|
||||||
target-path: /downloads/linker/v1.4.9/linker-linux-musl-arm64.zip
|
target-path: /downloads/linker/v1.5.0/linker-linux-musl-arm64.zip
|
||||||
- name: upload-linux-musl-arm64
|
- name: upload-linux-musl-arm64
|
||||||
id: upload-linux-musl-arm64
|
id: upload-linux-musl-arm64
|
||||||
uses: actions/upload-release-asset@master
|
uses: actions/upload-release-asset@master
|
||||||
@@ -227,7 +227,7 @@ jobs:
|
|||||||
key-secret: ${{ secrets.ALIYUN_OSS_SECRET }}
|
key-secret: ${{ secrets.ALIYUN_OSS_SECRET }}
|
||||||
bucket: ide-qbcode
|
bucket: ide-qbcode
|
||||||
asset-path: ./public/publish-zip/linker-osx-x64.zip
|
asset-path: ./public/publish-zip/linker-osx-x64.zip
|
||||||
target-path: /downloads/linker/v1.4.9/linker-osx-x64.zip
|
target-path: /downloads/linker/v1.5.0/linker-osx-x64.zip
|
||||||
- name: upload-osx-x64
|
- name: upload-osx-x64
|
||||||
id: upload-osx-x64
|
id: upload-osx-x64
|
||||||
uses: actions/upload-release-asset@master
|
uses: actions/upload-release-asset@master
|
||||||
@@ -247,7 +247,7 @@ jobs:
|
|||||||
key-secret: ${{ secrets.ALIYUN_OSS_SECRET }}
|
key-secret: ${{ secrets.ALIYUN_OSS_SECRET }}
|
||||||
bucket: ide-qbcode
|
bucket: ide-qbcode
|
||||||
asset-path: ./public/publish-zip/linker-osx-arm64.zip
|
asset-path: ./public/publish-zip/linker-osx-arm64.zip
|
||||||
target-path: /downloads/linker/v1.4.9/linker-osx-arm64.zip
|
target-path: /downloads/linker/v1.5.0/linker-osx-arm64.zip
|
||||||
- name: upload-osx-arm64
|
- name: upload-osx-arm64
|
||||||
id: upload-osx-arm64
|
id: upload-osx-arm64
|
||||||
uses: actions/upload-release-asset@master
|
uses: actions/upload-release-asset@master
|
||||||
@@ -277,7 +277,7 @@ jobs:
|
|||||||
key-secret: ${{ secrets.ALIYUN_OSS_SECRET }}
|
key-secret: ${{ secrets.ALIYUN_OSS_SECRET }}
|
||||||
bucket: ide-qbcode
|
bucket: ide-qbcode
|
||||||
asset-path: ./public/publish-zip/linker-windows-route.zip
|
asset-path: ./public/publish-zip/linker-windows-route.zip
|
||||||
target-path: /downloads/linker/v1.4.9/linker-windows-route.zip
|
target-path: /downloads/linker/v1.5.0/linker-windows-route.zip
|
||||||
- name: upload-windows-route
|
- name: upload-windows-route
|
||||||
id: upload-windows-route
|
id: upload-windows-route
|
||||||
uses: actions/upload-release-asset@master
|
uses: actions/upload-release-asset@master
|
||||||
|
6
.github/workflows/nuget.yml
vendored
6
.github/workflows/nuget.yml
vendored
@@ -38,6 +38,6 @@ jobs:
|
|||||||
|
|
||||||
- name: Push
|
- name: Push
|
||||||
run: |
|
run: |
|
||||||
nuget push ./linker.tunnel/bin/release/linker.tunnel.1.4.9.nupkg -Source https://api.nuget.org/v3/index.json -SkipDuplicate -ApiKey ${{ secrets.NUGET_KEY }} -NoSymbol
|
nuget push ./linker.tunnel/bin/release/linker.tunnel.1.5.0.nupkg -Source https://api.nuget.org/v3/index.json -SkipDuplicate -ApiKey ${{ secrets.NUGET_KEY }} -NoSymbol
|
||||||
nuget push ./linker.libs/bin/release/linker.libs.1.4.9.nupkg -Source https://api.nuget.org/v3/index.json -SkipDuplicate -ApiKey ${{ secrets.NUGET_KEY }} -NoSymbol
|
nuget push ./linker.libs/bin/release/linker.libs.1.5.0.nupkg -Source https://api.nuget.org/v3/index.json -SkipDuplicate -ApiKey ${{ secrets.NUGET_KEY }} -NoSymbol
|
||||||
nuget push ./linker.tun/bin/release/linker.tun.1.4.9.nupkg -Source https://api.nuget.org/v3/index.json -SkipDuplicate -ApiKey ${{ secrets.NUGET_KEY }} -NoSymbol
|
nuget push ./linker.tun/bin/release/linker.tun.1.5.0.nupkg -Source https://api.nuget.org/v3/index.json -SkipDuplicate -ApiKey ${{ secrets.NUGET_KEY }} -NoSymbol
|
||||||
|
@@ -27,7 +27,21 @@ namespace linker.libs
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
public static void SetInterval(Func<Task<bool>> action, int delayMs)
|
public static void SetInterval(Func<bool> action, Func<int> delay)
|
||||||
|
{
|
||||||
|
Task.Run(async () =>
|
||||||
|
{
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
if (action() == false)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
await Task.Delay(delay()).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
public static void SetInterval(Func<Task<bool>> action, Func<int> delay)
|
||||||
{
|
{
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
@@ -37,7 +51,7 @@ namespace linker.libs
|
|||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
await Task.Delay(delayMs).ConfigureAwait(false);
|
await Task.Delay(delay()).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -17,7 +17,7 @@ namespace linker.libs.extends
|
|||||||
ref double v = ref value;
|
ref double v = ref value;
|
||||||
fixed (void* p = &v)
|
fixed (void* p = &v)
|
||||||
{
|
{
|
||||||
new Span<byte>(p, 8).CopyTo(memory.Span);
|
new Span<byte>(p, sizeof(double)).CopyTo(memory.Span);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -32,7 +32,7 @@ namespace linker.libs.extends
|
|||||||
ref long v = ref value;
|
ref long v = ref value;
|
||||||
fixed (void* p = &v)
|
fixed (void* p = &v)
|
||||||
{
|
{
|
||||||
new Span<byte>(p, 8).CopyTo(memory.Span);
|
new Span<byte>(p, sizeof(long)).CopyTo(memory.Span);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static unsafe void ToBytes(this long[] value, Memory<byte> memory)
|
public static unsafe void ToBytes(this long[] value, Memory<byte> memory)
|
||||||
@@ -80,7 +80,7 @@ namespace linker.libs.extends
|
|||||||
ref int v = ref value;
|
ref int v = ref value;
|
||||||
fixed (void* p = &v)
|
fixed (void* p = &v)
|
||||||
{
|
{
|
||||||
new Span<byte>(p, 4).CopyTo(memory.Span);
|
new Span<byte>(p, sizeof(int)).CopyTo(memory.Span);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static unsafe void ToBytes(this int[] value, Memory<byte> memory)
|
public static unsafe void ToBytes(this int[] value, Memory<byte> memory)
|
||||||
@@ -99,7 +99,7 @@ namespace linker.libs.extends
|
|||||||
ref uint v = ref value;
|
ref uint v = ref value;
|
||||||
fixed (void* p = &v)
|
fixed (void* p = &v)
|
||||||
{
|
{
|
||||||
new Span<byte>(p, 4).CopyTo(memory.Span);
|
new Span<byte>(p, sizeof(uint)).CopyTo(memory.Span);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static unsafe void ToBytes(this uint[] value, Memory<byte> memory)
|
public static unsafe void ToBytes(this uint[] value, Memory<byte> memory)
|
||||||
|
@@ -14,9 +14,9 @@
|
|||||||
<Copyright>snltty</Copyright>
|
<Copyright>snltty</Copyright>
|
||||||
<PackageProjectUrl>https://github.com/snltty/linker</PackageProjectUrl>
|
<PackageProjectUrl>https://github.com/snltty/linker</PackageProjectUrl>
|
||||||
<RepositoryUrl>https://github.com/snltty/linker</RepositoryUrl>
|
<RepositoryUrl>https://github.com/snltty/linker</RepositoryUrl>
|
||||||
<Version>1.4.9</Version>
|
<Version>1.5.0</Version>
|
||||||
<AssemblyVersion>1.4.9</AssemblyVersion>
|
<AssemblyVersion>1.5.0</AssemblyVersion>
|
||||||
<FileVersion>1.4.9</FileVersion>
|
<FileVersion>1.5.0</FileVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
<DebugType>full</DebugType>
|
<DebugType>full</DebugType>
|
||||||
|
@@ -16,9 +16,9 @@
|
|||||||
<PackageProjectUrl>https://github.com/snltty/linker</PackageProjectUrl>
|
<PackageProjectUrl>https://github.com/snltty/linker</PackageProjectUrl>
|
||||||
<RepositoryUrl>https://github.com/snltty/linker</RepositoryUrl>
|
<RepositoryUrl>https://github.com/snltty/linker</RepositoryUrl>
|
||||||
<PackageReleaseNotes>linker tun</PackageReleaseNotes>
|
<PackageReleaseNotes>linker tun</PackageReleaseNotes>
|
||||||
<Version>1.4.9</Version>
|
<Version>1.5.0</Version>
|
||||||
<AssemblyVersion>1.4.9</AssemblyVersion>
|
<AssemblyVersion>1.5.0</AssemblyVersion>
|
||||||
<FileVersion>1.4.9</FileVersion>
|
<FileVersion>1.5.0</FileVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
|
@@ -28,7 +28,7 @@ namespace linker.tunnel
|
|||||||
/// 加载打洞协议
|
/// 加载打洞协议
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="assembs"></param>
|
/// <param name="assembs"></param>
|
||||||
public void Init(TunnelWanPortTransfer compactTransfer, ITunnelAdapter tunnelAdapter, List<ITunnelTransport> transports)
|
public void LoadTransports(TunnelWanPortTransfer compactTransfer, ITunnelAdapter tunnelAdapter, List<ITunnelTransport> transports)
|
||||||
{
|
{
|
||||||
this.compactTransfer = compactTransfer;
|
this.compactTransfer = compactTransfer;
|
||||||
this.tunnelAdapter = tunnelAdapter;
|
this.tunnelAdapter = tunnelAdapter;
|
||||||
|
@@ -305,7 +305,7 @@ namespace linker.tunnel.connection
|
|||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return this.ToJson();
|
return this.ToJsonFormat();
|
||||||
}
|
}
|
||||||
public bool Equals(ITunnelConnection connection)
|
public bool Equals(ITunnelConnection connection)
|
||||||
{
|
{
|
||||||
|
@@ -16,9 +16,9 @@
|
|||||||
<PackageProjectUrl>https://github.com/snltty/linker</PackageProjectUrl>
|
<PackageProjectUrl>https://github.com/snltty/linker</PackageProjectUrl>
|
||||||
<RepositoryUrl>https://github.com/snltty/linker</RepositoryUrl>
|
<RepositoryUrl>https://github.com/snltty/linker</RepositoryUrl>
|
||||||
<PackageReleaseNotes>linker tunnel</PackageReleaseNotes>
|
<PackageReleaseNotes>linker tunnel</PackageReleaseNotes>
|
||||||
<Version>1.4.9</Version>
|
<Version>1.5.0</Version>
|
||||||
<AssemblyVersion>1.4.9</AssemblyVersion>
|
<AssemblyVersion>1.5.0</AssemblyVersion>
|
||||||
<FileVersion>1.4.9</FileVersion>
|
<FileVersion>1.5.0</FileVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
|
@@ -19,7 +19,7 @@ namespace linker.tunnel.wanport
|
|||||||
/// 加载所有外网端口协议
|
/// 加载所有外网端口协议
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="assembs"></param>
|
/// <param name="assembs"></param>
|
||||||
public void Init(List<ITunnelWanPortProtocol> tunnelWanPorts)
|
public void LoadTransports(List<ITunnelWanPortProtocol> tunnelWanPorts)
|
||||||
{
|
{
|
||||||
this.tunnelWanPorts = tunnelWanPorts;
|
this.tunnelWanPorts = tunnelWanPorts;
|
||||||
LoggerHelper.Instance.Info($"load tunnel wanport compacts:{string.Join(",", tunnelWanPorts.Select(c => c.Name))}");
|
LoggerHelper.Instance.Info($"load tunnel wanport compacts:{string.Join(",", tunnelWanPorts.Select(c => c.Name))}");
|
||||||
|
@@ -26,14 +26,15 @@
|
|||||||
3. 优化配置同步,可自由选择同步哪些信息
|
3. 优化配置同步,可自由选择同步哪些信息
|
||||||
4. 自动分配虚拟网卡IP
|
4. 自动分配虚拟网卡IP
|
||||||
5. 线程池优化
|
5. 线程池优化
|
||||||
6. 一些UI优化</Description>
|
6. 一些UI优化
|
||||||
|
7. 测试中,不要更新,不要更新,不要更新,请使用v1.4.9</Description>
|
||||||
<Copyright>snltty</Copyright>
|
<Copyright>snltty</Copyright>
|
||||||
<PackageProjectUrl>https://github.com/snltty/linker</PackageProjectUrl>
|
<PackageProjectUrl>https://github.com/snltty/linker</PackageProjectUrl>
|
||||||
<RepositoryUrl>https://github.com/snltty/linker</RepositoryUrl>
|
<RepositoryUrl>https://github.com/snltty/linker</RepositoryUrl>
|
||||||
<PackageReleaseNotes>linker</PackageReleaseNotes>
|
<PackageReleaseNotes>linker</PackageReleaseNotes>
|
||||||
<Version>1.4.9</Version>
|
<Version>1.5.0</Version>
|
||||||
<AssemblyVersion>1.4.9</AssemblyVersion>
|
<AssemblyVersion>1.5.0</AssemblyVersion>
|
||||||
<FileVersion>1.4.9</FileVersion>
|
<FileVersion>1.5.0</FileVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|
||||||
|
@@ -54,7 +54,7 @@ namespace linker.plugins.client
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}, 10000);
|
}, () => 10000);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -221,7 +221,7 @@ namespace linker.plugins.client
|
|||||||
public void Set(string newName, ClientGroupInfo[] groups)
|
public void Set(string newName, ClientGroupInfo[] groups)
|
||||||
{
|
{
|
||||||
config.Data.Client.Name = newName;
|
config.Data.Client.Name = newName;
|
||||||
config.Data.Client.Groups = groups.DistinctBy(c => c.Name).ToArray();
|
config.Data.Client.Groups = groups.DistinctBy(c => c.Name).ToArray();
|
||||||
config.Data.Update();
|
config.Data.Update();
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -230,7 +230,7 @@ namespace linker.plugins.client
|
|||||||
/// <param name="groups"></param>
|
/// <param name="groups"></param>
|
||||||
public void Set(ClientGroupInfo[] groups)
|
public void Set(ClientGroupInfo[] groups)
|
||||||
{
|
{
|
||||||
config.Data.Client.Groups = groups.DistinctBy(c=>c.Name).ToArray();
|
config.Data.Client.Groups = groups.DistinctBy(c => c.Name).ToArray();
|
||||||
config.Data.Update();
|
config.Data.Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -291,7 +291,7 @@ namespace linker.plugins.forward.proxy
|
|||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}, 5000);
|
}, 30000);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CloseClientSocketUdp(ITunnelConnection connection)
|
private void CloseClientSocketUdp(ITunnelConnection connection)
|
||||||
|
@@ -31,7 +31,7 @@ namespace linker.plugins.relay
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}, 1000);
|
}, () => lastTicksManager.DiffLessEqual(5000) ? 1000 : 30000);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update()
|
public void Update()
|
||||||
|
@@ -293,7 +293,7 @@ namespace linker.plugins.relay
|
|||||||
await TaskRelay();
|
await TaskRelay();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}, 3000);
|
}, () => lastTicksManager.DiffLessEqual(3000) ? 3000 : 30000);
|
||||||
}
|
}
|
||||||
sealed class TestInfo
|
sealed class TestInfo
|
||||||
{
|
{
|
||||||
|
@@ -162,6 +162,7 @@ namespace linker.plugins.relay.transport
|
|||||||
{
|
{
|
||||||
if (certificate == null)
|
if (certificate == null)
|
||||||
{
|
{
|
||||||
|
LoggerHelper.Instance.Error($"need ssl");
|
||||||
socket.SafeClose();
|
socket.SafeClose();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@@ -31,7 +31,7 @@ namespace linker.plugins.sforward.proxy
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}, 1000);
|
}, () => lastTicksManager.DiffLessEqual(5000) ? 1000 : 30000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -284,7 +284,7 @@ namespace linker.plugins.sforward.proxy
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}, 5000);
|
}, 60000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -101,7 +101,7 @@ namespace linker.plugins.tunnel
|
|||||||
};
|
};
|
||||||
List<ITunnelWanPortProtocol> compacts = types.Select(c => (ITunnelWanPortProtocol)serviceProvider.GetService(c)).Where(c => c != null).Where(c => string.IsNullOrWhiteSpace(c.Name) == false).ToList();
|
List<ITunnelWanPortProtocol> compacts = types.Select(c => (ITunnelWanPortProtocol)serviceProvider.GetService(c)).Where(c => c != null).Where(c => string.IsNullOrWhiteSpace(c.Name) == false).ToList();
|
||||||
TunnelWanPortTransfer compack = serviceProvider.GetService<TunnelWanPortTransfer>();
|
TunnelWanPortTransfer compack = serviceProvider.GetService<TunnelWanPortTransfer>();
|
||||||
compack.Init(compacts);
|
compack.LoadTransports(compacts);
|
||||||
|
|
||||||
|
|
||||||
types = new List<Type> {
|
types = new List<Type> {
|
||||||
@@ -114,7 +114,7 @@ namespace linker.plugins.tunnel
|
|||||||
};
|
};
|
||||||
List<ITunnelTransport> transports = types.Select(c => (ITunnelTransport)serviceProvider.GetService(c)).Where(c => c != null).Where(c => string.IsNullOrWhiteSpace(c.Name) == false).ToList();
|
List<ITunnelTransport> transports = types.Select(c => (ITunnelTransport)serviceProvider.GetService(c)).Where(c => c != null).Where(c => string.IsNullOrWhiteSpace(c.Name) == false).ToList();
|
||||||
TunnelTransfer tunnel = serviceProvider.GetService<TunnelTransfer>();
|
TunnelTransfer tunnel = serviceProvider.GetService<TunnelTransfer>();
|
||||||
tunnel.Init(compack, tunnelAdapter, transports);
|
tunnel.LoadTransports(compack, tunnelAdapter, transports);
|
||||||
|
|
||||||
TunnelConfigTransfer tunnelConfigTransfer = serviceProvider.GetService<TunnelConfigTransfer>();
|
TunnelConfigTransfer tunnelConfigTransfer = serviceProvider.GetService<TunnelConfigTransfer>();
|
||||||
TunnelExcludeIPTransfer excludeIPTransfer = serviceProvider.GetService<TunnelExcludeIPTransfer>();
|
TunnelExcludeIPTransfer excludeIPTransfer = serviceProvider.GetService<TunnelExcludeIPTransfer>();
|
||||||
|
@@ -34,6 +34,10 @@ namespace linker.plugins.tuntap
|
|||||||
serviceCollection.AddSingleton<ExcludeIP>();
|
serviceCollection.AddSingleton<ExcludeIP>();
|
||||||
|
|
||||||
serviceCollection.AddSingleton<TuntapConfigTransfer>();
|
serviceCollection.AddSingleton<TuntapConfigTransfer>();
|
||||||
|
serviceCollection.AddSingleton<TuntapPingTransfer>();
|
||||||
|
serviceCollection.AddSingleton<TuntapDeviceStatusTransfer>();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddServer(ServiceCollection serviceCollection, FileConfig config)
|
public void AddServer(ServiceCollection serviceCollection, FileConfig config)
|
||||||
@@ -51,6 +55,9 @@ namespace linker.plugins.tuntap
|
|||||||
LeaseClientTreansfer leaseTreansfer = serviceProvider.GetService<LeaseClientTreansfer>();
|
LeaseClientTreansfer leaseTreansfer = serviceProvider.GetService<LeaseClientTreansfer>();
|
||||||
|
|
||||||
TuntapConfigTransfer tuntapConfigTransfer = serviceProvider.GetService<TuntapConfigTransfer>();
|
TuntapConfigTransfer tuntapConfigTransfer = serviceProvider.GetService<TuntapConfigTransfer>();
|
||||||
|
TuntapPingTransfer tuntapPingTransfer = serviceProvider.GetService<TuntapPingTransfer>();
|
||||||
|
TuntapDeviceStatusTransfer tuntapDeviceStatusTransfer = serviceProvider.GetService<TuntapDeviceStatusTransfer>();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UseServer(ServiceProvider serviceProvider, FileConfig config)
|
public void UseServer(ServiceProvider serviceProvider, FileConfig config)
|
||||||
|
@@ -24,8 +24,10 @@ namespace linker.plugins.tuntap.client
|
|||||||
private readonly RunningConfig runningConfig;
|
private readonly RunningConfig runningConfig;
|
||||||
private readonly TuntapConfigTransfer tuntapConfigTransfer;
|
private readonly TuntapConfigTransfer tuntapConfigTransfer;
|
||||||
private readonly LeaseClientTreansfer leaseClientTreansfer;
|
private readonly LeaseClientTreansfer leaseClientTreansfer;
|
||||||
|
private readonly TuntapPingTransfer pingTransfer;
|
||||||
|
|
||||||
public TuntapClientApiController(MessengerSender messengerSender, TuntapTransfer tuntapTransfer, ClientSignInState clientSignInState, FileConfig config, TuntapProxy tuntapProxy, RunningConfig runningConfig, TuntapConfigTransfer tuntapConfigTransfer, LeaseClientTreansfer leaseClientTreansfer)
|
|
||||||
|
public TuntapClientApiController(MessengerSender messengerSender, TuntapTransfer tuntapTransfer, ClientSignInState clientSignInState, FileConfig config, TuntapProxy tuntapProxy, RunningConfig runningConfig, TuntapConfigTransfer tuntapConfigTransfer, LeaseClientTreansfer leaseClientTreansfer, TuntapPingTransfer pingTransfer)
|
||||||
{
|
{
|
||||||
this.messengerSender = messengerSender;
|
this.messengerSender = messengerSender;
|
||||||
this.tuntapTransfer = tuntapTransfer;
|
this.tuntapTransfer = tuntapTransfer;
|
||||||
@@ -35,6 +37,7 @@ namespace linker.plugins.tuntap.client
|
|||||||
this.runningConfig = runningConfig;
|
this.runningConfig = runningConfig;
|
||||||
this.tuntapConfigTransfer = tuntapConfigTransfer;
|
this.tuntapConfigTransfer = tuntapConfigTransfer;
|
||||||
this.leaseClientTreansfer = leaseClientTreansfer;
|
this.leaseClientTreansfer = leaseClientTreansfer;
|
||||||
|
this.pingTransfer = pingTransfer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConnectionListInfo Connections(ApiControllerParamsInfo param)
|
public ConnectionListInfo Connections(ApiControllerParamsInfo param)
|
||||||
@@ -96,9 +99,7 @@ namespace linker.plugins.tuntap.client
|
|||||||
{
|
{
|
||||||
if (config.Data.Client.HasAccess(ClientApiAccess.TuntapStatusSelf) == false) return false;
|
if (config.Data.Client.HasAccess(ClientApiAccess.TuntapStatusSelf) == false) return false;
|
||||||
|
|
||||||
tuntapTransfer.Shutdown();
|
await tuntapConfigTransfer.RetstartDevice();
|
||||||
await tuntapConfigTransfer.RefreshIPForce();
|
|
||||||
tuntapTransfer.Setup();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -124,7 +125,7 @@ namespace linker.plugins.tuntap.client
|
|||||||
if (param.Content == config.Data.Client.Id)
|
if (param.Content == config.Data.Client.Id)
|
||||||
{
|
{
|
||||||
if (config.Data.Client.HasAccess(ClientApiAccess.TuntapStatusSelf) == false) return false;
|
if (config.Data.Client.HasAccess(ClientApiAccess.TuntapStatusSelf) == false) return false;
|
||||||
tuntapTransfer.Shutdown();
|
tuntapConfigTransfer.StopDevice();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -191,20 +192,23 @@ namespace linker.plugins.tuntap.client
|
|||||||
return await leaseClientTreansfer.GetNetwork();
|
return await leaseClientTreansfer.GetNetwork();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 订阅ping
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="param"></param>
|
||||||
public void SubscribePing(ApiControllerParamsInfo param)
|
public void SubscribePing(ApiControllerParamsInfo param)
|
||||||
{
|
{
|
||||||
tuntapConfigTransfer.SubscribePing();
|
pingTransfer.SubscribePing();
|
||||||
}
|
|
||||||
|
|
||||||
public sealed class TuntabListInfo
|
|
||||||
{
|
|
||||||
public ConcurrentDictionary<string, TuntapInfo> List { get; set; }
|
|
||||||
public ulong HashCode { get; set; }
|
|
||||||
}
|
|
||||||
public sealed class ConnectionListInfo
|
|
||||||
{
|
|
||||||
public ConcurrentDictionary<string, ITunnelConnection> List { get; set; }
|
|
||||||
public ulong HashCode { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public sealed class TuntabListInfo
|
||||||
|
{
|
||||||
|
public ConcurrentDictionary<string, TuntapInfo> List { get; set; }
|
||||||
|
public ulong HashCode { get; set; }
|
||||||
|
}
|
||||||
|
public sealed class ConnectionListInfo
|
||||||
|
{
|
||||||
|
public ConcurrentDictionary<string, ITunnelConnection> List { get; set; }
|
||||||
|
public ulong HashCode { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -9,8 +9,6 @@ using linker.plugins.client;
|
|||||||
using linker.plugins.messenger;
|
using linker.plugins.messenger;
|
||||||
using linker.plugins.tuntap.config;
|
using linker.plugins.tuntap.config;
|
||||||
using linker.tun;
|
using linker.tun;
|
||||||
using linker.tunnel.connection;
|
|
||||||
using System.Net.NetworkInformation;
|
|
||||||
using linker.plugins.tuntap.lease;
|
using linker.plugins.tuntap.lease;
|
||||||
|
|
||||||
namespace linker.plugins.tuntap.client
|
namespace linker.plugins.tuntap.client
|
||||||
@@ -22,32 +20,25 @@ namespace linker.plugins.tuntap.client
|
|||||||
private readonly FileConfig config;
|
private readonly FileConfig config;
|
||||||
private readonly TuntapProxy tuntapProxy;
|
private readonly TuntapProxy tuntapProxy;
|
||||||
private readonly RunningConfig runningConfig;
|
private readonly RunningConfig runningConfig;
|
||||||
private readonly LinkerTunDeviceAdapter linkerTunDeviceAdapter;
|
|
||||||
private readonly TuntapTransfer tuntapTransfer;
|
private readonly TuntapTransfer tuntapTransfer;
|
||||||
private readonly LeaseClientTreansfer leaseClientTreansfer;
|
private readonly LeaseClientTreansfer leaseClientTreansfer;
|
||||||
|
|
||||||
private string deviceName = "linker";
|
|
||||||
|
|
||||||
public VersionManager Version { get; } = new VersionManager();
|
public VersionManager Version { get; } = new VersionManager();
|
||||||
private readonly ConcurrentDictionary<string, TuntapInfo> tuntapInfos = new ConcurrentDictionary<string, TuntapInfo>();
|
private readonly ConcurrentDictionary<string, TuntapInfo> tuntapInfos = new ConcurrentDictionary<string, TuntapInfo>();
|
||||||
public ConcurrentDictionary<string, TuntapInfo> Infos => tuntapInfos;
|
public ConcurrentDictionary<string, TuntapInfo> Infos => tuntapInfos;
|
||||||
public LinkerTunDeviceRouteItem[] RouteItems { get; private set; } = [];
|
|
||||||
|
|
||||||
|
|
||||||
private readonly SemaphoreSlim slim = new SemaphoreSlim(1);
|
private readonly SemaphoreSlim slim = new SemaphoreSlim(1);
|
||||||
public TuntapConfigTransfer(MessengerSender messengerSender, ClientSignInState clientSignInState, FileConfig config, TuntapProxy tuntapProxy, RunningConfig runningConfig, LinkerTunDeviceAdapter linkerTunDeviceAdapter, TuntapTransfer tuntapTransfer, LeaseClientTreansfer leaseClientTreansfer)
|
public TuntapConfigTransfer(MessengerSender messengerSender, ClientSignInState clientSignInState, FileConfig config, TuntapProxy tuntapProxy, RunningConfig runningConfig, TuntapTransfer tuntapTransfer, LeaseClientTreansfer leaseClientTreansfer)
|
||||||
{
|
{
|
||||||
this.messengerSender = messengerSender;
|
this.messengerSender = messengerSender;
|
||||||
this.clientSignInState = clientSignInState;
|
this.clientSignInState = clientSignInState;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.tuntapProxy = tuntapProxy;
|
this.tuntapProxy = tuntapProxy;
|
||||||
this.runningConfig = runningConfig;
|
this.runningConfig = runningConfig;
|
||||||
this.linkerTunDeviceAdapter = linkerTunDeviceAdapter;
|
|
||||||
this.tuntapTransfer = tuntapTransfer;
|
this.tuntapTransfer = tuntapTransfer;
|
||||||
this.leaseClientTreansfer = leaseClientTreansfer;
|
this.leaseClientTreansfer = leaseClientTreansfer;
|
||||||
|
|
||||||
PingTask();
|
clientSignInState.NetworkEnabledHandle += (times) => RefreshIP();
|
||||||
clientSignInState.NetworkEnabledHandle += NetworkEanble;
|
|
||||||
|
|
||||||
tuntapTransfer.OnSetupBefore += () => { NotifyConfig(); };
|
tuntapTransfer.OnSetupBefore += () => { NotifyConfig(); };
|
||||||
tuntapTransfer.OnSetupAfter += () => { NotifyConfig(); };
|
tuntapTransfer.OnSetupAfter += () => { NotifyConfig(); };
|
||||||
@@ -58,90 +49,76 @@ namespace linker.plugins.tuntap.client
|
|||||||
tuntapTransfer.OnShutdownSuccess += () => { NotifyConfig(); DeleteForward(); DelRoute(); runningConfig.Data.Tuntap.Running = false; runningConfig.Data.Update(); };
|
tuntapTransfer.OnShutdownSuccess += () => { NotifyConfig(); DeleteForward(); DelRoute(); runningConfig.Data.Tuntap.Running = false; runningConfig.Data.Update(); };
|
||||||
|
|
||||||
}
|
}
|
||||||
private void NetworkEanble(int times)
|
|
||||||
{
|
|
||||||
TimerHelper.Async(async () =>
|
|
||||||
{
|
|
||||||
if (runningConfig.Data.Tuntap.Group2IP.TryGetValue(config.Data.Client.Group.Id, out TuntapGroup2IPInfo tuntapGroup2IPInfo))
|
|
||||||
{
|
|
||||||
if (tuntapGroup2IPInfo.IP.Equals(runningConfig.Data.Tuntap.IP) == false || tuntapGroup2IPInfo.PrefixLength != runningConfig.Data.Tuntap.PrefixLength)
|
|
||||||
{
|
|
||||||
runningConfig.Data.Tuntap.IP = tuntapGroup2IPInfo.IP;
|
|
||||||
runningConfig.Data.Tuntap.PrefixLength = tuntapGroup2IPInfo.PrefixLength;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (runningConfig.Data.Tuntap.Running || runningConfig.Data.Tuntap.IP.Equals(IPAddress.Any) == false)
|
|
||||||
{
|
|
||||||
LeaseInfo leaseInfo = await leaseClientTreansfer.LeaseIp(runningConfig.Data.Tuntap.IP, runningConfig.Data.Tuntap.PrefixLength);
|
|
||||||
runningConfig.Data.Tuntap.IP = leaseInfo.IP;
|
|
||||||
runningConfig.Data.Tuntap.PrefixLength = leaseInfo.PrefixLength;
|
|
||||||
runningConfig.Data.Update();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tuntapTransfer.Status == TuntapStatus.Running && times > 0)
|
|
||||||
{
|
|
||||||
tuntapTransfer.Shutdown();
|
|
||||||
tuntapTransfer.Setup();
|
|
||||||
}
|
|
||||||
if (times == 0)
|
|
||||||
{
|
|
||||||
LoggerHelper.Instance.Debug($"tuntap initialize->{runningConfig.Data.Tuntap.Running}");
|
|
||||||
if (runningConfig.Data.Tuntap.Running)
|
|
||||||
{
|
|
||||||
tuntapTransfer.Shutdown();
|
|
||||||
LoggerHelper.Instance.Debug($"tuntap should be run");
|
|
||||||
tuntapTransfer.Setup();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
NotifyConfig();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 刷新IP
|
/// 刷新IP
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void RefreshIP()
|
public void RefreshIP()
|
||||||
{
|
{
|
||||||
if (runningConfig.Data.Tuntap.Running || runningConfig.Data.Tuntap.IP.Equals(IPAddress.Any) == false)
|
TimerHelper.Async(async () =>
|
||||||
{
|
{
|
||||||
TimerHelper.Async(async () =>
|
IPAddress oldIP = runningConfig.Data.Tuntap.IP;
|
||||||
|
byte prefixLength = runningConfig.Data.Tuntap.PrefixLength;
|
||||||
|
|
||||||
|
await LeaseIP();
|
||||||
|
while (tuntapTransfer.Status == TuntapStatus.Operating)
|
||||||
{
|
{
|
||||||
IPAddress oldIP = runningConfig.Data.Tuntap.IP;
|
await Task.Delay(1000);
|
||||||
byte prefixLength = runningConfig.Data.Tuntap.PrefixLength;
|
}
|
||||||
|
|
||||||
LeaseInfo leaseInfo = await leaseClientTreansfer.LeaseIp(runningConfig.Data.Tuntap.IP, runningConfig.Data.Tuntap.PrefixLength);
|
bool run = ((oldIP.Equals(runningConfig.Data.Tuntap.IP) == false || prefixLength != runningConfig.Data.Tuntap.PrefixLength) && runningConfig.Data.Tuntap.Running)
|
||||||
runningConfig.Data.Tuntap.IP = leaseInfo.IP;
|
|| (runningConfig.Data.Tuntap.Running && tuntapTransfer.Status != TuntapStatus.Running);
|
||||||
runningConfig.Data.Tuntap.PrefixLength = leaseInfo.PrefixLength;
|
|
||||||
runningConfig.Data.Update();
|
|
||||||
|
|
||||||
TuntapGroup2IPInfo tuntapGroup2IPInfo = new TuntapGroup2IPInfo { IP = runningConfig.Data.Tuntap.IP, PrefixLength = runningConfig.Data.Tuntap.PrefixLength };
|
if (run)
|
||||||
runningConfig.Data.Tuntap.Group2IP.AddOrUpdate(config.Data.Client.Group.Id, tuntapGroup2IPInfo, (a, b) => tuntapGroup2IPInfo);
|
{
|
||||||
|
tuntapTransfer.Shutdown();
|
||||||
while (tuntapTransfer.Status == TuntapStatus.Operating)
|
tuntapTransfer.Setup(runningConfig.Data.Tuntap.IP, runningConfig.Data.Tuntap.PrefixLength);
|
||||||
{
|
}
|
||||||
await Task.Delay(1000);
|
NotifyConfig();
|
||||||
}
|
});
|
||||||
|
|
||||||
if ((oldIP.Equals(runningConfig.Data.Tuntap.IP) == false || prefixLength != runningConfig.Data.Tuntap.PrefixLength) && tuntapTransfer.Status == TuntapStatus.Running)
|
|
||||||
{
|
|
||||||
tuntapTransfer.Shutdown();
|
|
||||||
tuntapTransfer.Setup();
|
|
||||||
}
|
|
||||||
NotifyConfig();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
public async Task RefreshIPForce()
|
/// <summary>
|
||||||
|
/// 重启网卡
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task RetstartDevice()
|
||||||
{
|
{
|
||||||
LeaseInfo leaseInfo = await leaseClientTreansfer.LeaseIp(runningConfig.Data.Tuntap.IP, runningConfig.Data.Tuntap.PrefixLength);
|
tuntapTransfer.Shutdown();
|
||||||
runningConfig.Data.Tuntap.IP = leaseInfo.IP;
|
await LeaseIP();
|
||||||
runningConfig.Data.Tuntap.PrefixLength = leaseInfo.PrefixLength;
|
tuntapTransfer.Setup(runningConfig.Data.Tuntap.IP, runningConfig.Data.Tuntap.PrefixLength);
|
||||||
runningConfig.Data.Update();
|
}
|
||||||
|
/// <summary>
|
||||||
TuntapGroup2IPInfo tuntapGroup2IPInfo = new TuntapGroup2IPInfo { IP = runningConfig.Data.Tuntap.IP, PrefixLength = runningConfig.Data.Tuntap.PrefixLength };
|
/// 关闭网卡
|
||||||
|
/// </summary>
|
||||||
|
public void StopDevice()
|
||||||
|
{
|
||||||
|
tuntapTransfer.Shutdown();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 租赁IP
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
private async Task LeaseIP()
|
||||||
|
{
|
||||||
|
if (runningConfig.Data.Tuntap.Group2IP.TryGetValue(config.Data.Client.Group.Id, out TuntapGroup2IPInfo tuntapGroup2IPInfo))
|
||||||
|
{
|
||||||
|
if (tuntapGroup2IPInfo.IP.Equals(runningConfig.Data.Tuntap.IP) == false || tuntapGroup2IPInfo.PrefixLength != runningConfig.Data.Tuntap.PrefixLength)
|
||||||
|
{
|
||||||
|
runningConfig.Data.Tuntap.IP = tuntapGroup2IPInfo.IP;
|
||||||
|
runningConfig.Data.Tuntap.PrefixLength = tuntapGroup2IPInfo.PrefixLength;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (runningConfig.Data.Tuntap.Running || runningConfig.Data.Tuntap.IP.Equals(IPAddress.Any) == false)
|
||||||
|
{
|
||||||
|
LeaseInfo leaseInfo = await leaseClientTreansfer.LeaseIp(runningConfig.Data.Tuntap.IP, runningConfig.Data.Tuntap.PrefixLength);
|
||||||
|
runningConfig.Data.Tuntap.IP = leaseInfo.IP;
|
||||||
|
runningConfig.Data.Tuntap.PrefixLength = leaseInfo.PrefixLength;
|
||||||
|
runningConfig.Data.Update();
|
||||||
|
}
|
||||||
|
tuntapGroup2IPInfo = new TuntapGroup2IPInfo { IP = runningConfig.Data.Tuntap.IP, PrefixLength = runningConfig.Data.Tuntap.PrefixLength };
|
||||||
runningConfig.Data.Tuntap.Group2IP.AddOrUpdate(config.Data.Client.Group.Id, tuntapGroup2IPInfo, (a, b) => tuntapGroup2IPInfo);
|
runningConfig.Data.Tuntap.Group2IP.AddOrUpdate(config.Data.Client.Group.Id, tuntapGroup2IPInfo, (a, b) => tuntapGroup2IPInfo);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -177,7 +154,7 @@ namespace linker.plugins.tuntap.client
|
|||||||
if (tuntapTransfer.Status == TuntapStatus.Running && needReboot)
|
if (tuntapTransfer.Status == TuntapStatus.Running && needReboot)
|
||||||
{
|
{
|
||||||
tuntapTransfer.Shutdown();
|
tuntapTransfer.Shutdown();
|
||||||
tuntapTransfer.Setup();
|
tuntapTransfer.Setup(runningConfig.Data.Tuntap.IP, runningConfig.Data.Tuntap.PrefixLength);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -275,6 +252,11 @@ namespace linker.plugins.tuntap.client
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private TuntapInfo GetLocalInfo()
|
private TuntapInfo GetLocalInfo()
|
||||||
{
|
{
|
||||||
|
if (runningConfig.Data.Tuntap.LanIPs.Length == 0)
|
||||||
|
{
|
||||||
|
runningConfig.Data.Tuntap.LanIPs = [clientSignInState.Connection.LocalAddress.Address];
|
||||||
|
runningConfig.Data.Tuntap.Masks = [24];
|
||||||
|
}
|
||||||
TuntapInfo info = new TuntapInfo
|
TuntapInfo info = new TuntapInfo
|
||||||
{
|
{
|
||||||
IP = runningConfig.Data.Tuntap.IP,
|
IP = runningConfig.Data.Tuntap.IP,
|
||||||
@@ -458,51 +440,5 @@ namespace linker.plugins.tuntap.client
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private readonly LastTicksManager lastTicksManager = new LastTicksManager();
|
|
||||||
public void SubscribePing()
|
|
||||||
{
|
|
||||||
lastTicksManager.Update();
|
|
||||||
}
|
|
||||||
private void PingTask()
|
|
||||||
{
|
|
||||||
TimerHelper.SetInterval(async () =>
|
|
||||||
{
|
|
||||||
if (tuntapTransfer.Status == TuntapStatus.Running && lastTicksManager.DiffLessEqual(5000))
|
|
||||||
{
|
|
||||||
await Ping();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}, 3000);
|
|
||||||
TimerHelper.SetInterval(async () =>
|
|
||||||
{
|
|
||||||
if (tuntapTransfer.Status == TuntapStatus.Running && lastTicksManager.DiffGreater(15000))
|
|
||||||
{
|
|
||||||
await Ping();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}, 30000);
|
|
||||||
}
|
|
||||||
private async Task Ping()
|
|
||||||
{
|
|
||||||
if (tuntapTransfer.Status == TuntapStatus.Running && (runningConfig.Data.Tuntap.Switch & TuntapSwitch.ShowDelay) == TuntapSwitch.ShowDelay)
|
|
||||||
{
|
|
||||||
var items = tuntapInfos.Values.Where(c => c.IP != null && c.IP.Equals(IPAddress.Any) == false && (c.Status & TuntapStatus.Running) == TuntapStatus.Running);
|
|
||||||
if ((runningConfig.Data.Tuntap.Switch & TuntapSwitch.AutoConnect) != TuntapSwitch.AutoConnect)
|
|
||||||
{
|
|
||||||
var connections = tuntapProxy.GetConnections();
|
|
||||||
items = items.Where(c => connections.TryGetValue(c.MachineId, out ITunnelConnection connection) && connection.Connected || c.MachineId == config.Data.Client.Id);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var item in items)
|
|
||||||
{
|
|
||||||
using Ping ping = new Ping();
|
|
||||||
PingReply pingReply = await ping.SendPingAsync(item.IP, 500);
|
|
||||||
item.Delay = pingReply.Status == IPStatus.Success ? (int)pingReply.RoundtripTime : -1;
|
|
||||||
|
|
||||||
Version.Add();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
68
linker/plugins/tuntap/client/TuntapDeviceStatusTransfer.cs
Normal file
68
linker/plugins/tuntap/client/TuntapDeviceStatusTransfer.cs
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
using linker.client.config;
|
||||||
|
using linker.libs;
|
||||||
|
using linker.plugins.tuntap.config;
|
||||||
|
using linker.tun;
|
||||||
|
using System.Net.NetworkInformation;
|
||||||
|
|
||||||
|
namespace linker.plugins.tuntap.client
|
||||||
|
{
|
||||||
|
public sealed class TuntapDeviceStatusTransfer
|
||||||
|
{
|
||||||
|
private readonly RunningConfig runningConfig;
|
||||||
|
private readonly TuntapTransfer tuntapTransfer;
|
||||||
|
private readonly TuntapConfigTransfer tuntapConfigTransfer;
|
||||||
|
private readonly LinkerTunDeviceAdapter linkerTunDeviceAdapter;
|
||||||
|
private ulong setupTimes = 0;
|
||||||
|
public TuntapDeviceStatusTransfer(RunningConfig runningConfig, TuntapTransfer tuntapTransfer, TuntapConfigTransfer tuntapConfigTransfer, LinkerTunDeviceAdapter linkerTunDeviceAdapter)
|
||||||
|
{
|
||||||
|
this.runningConfig = runningConfig;
|
||||||
|
this.tuntapTransfer = tuntapTransfer;
|
||||||
|
this.tuntapConfigTransfer = tuntapConfigTransfer;
|
||||||
|
this.linkerTunDeviceAdapter = linkerTunDeviceAdapter;
|
||||||
|
|
||||||
|
tuntapTransfer.OnSetupSuccess += () => { setupTimes++; };
|
||||||
|
}
|
||||||
|
private void CheckTuntapStatusTask()
|
||||||
|
{
|
||||||
|
TimerHelper.SetInterval(async () =>
|
||||||
|
{
|
||||||
|
if (setupTimes > 0 && runningConfig.Data.Tuntap.Running && OperatingSystem.IsWindows())
|
||||||
|
{
|
||||||
|
await InterfaceCheck().ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}, () => 15000);
|
||||||
|
}
|
||||||
|
private async Task InterfaceCheck()
|
||||||
|
{
|
||||||
|
if (await InterfaceAvailable() == false && tuntapTransfer.Status != TuntapStatus.Operating)
|
||||||
|
{
|
||||||
|
LoggerHelper.Instance.Error($"tuntap inerface {tuntapTransfer.DeviceName} is down, restarting");
|
||||||
|
linkerTunDeviceAdapter.Shutdown();
|
||||||
|
await Task.Delay(5000).ConfigureAwait(false);
|
||||||
|
if (await InterfaceAvailable() == false && tuntapTransfer.Status != TuntapStatus.Operating)
|
||||||
|
{
|
||||||
|
await tuntapConfigTransfer.RetstartDevice();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private async Task<bool> InterfaceAvailable()
|
||||||
|
{
|
||||||
|
NetworkInterface networkInterface = NetworkInterface.GetAllNetworkInterfaces().FirstOrDefault(c => c.Name == tuntapTransfer.DeviceName);
|
||||||
|
return networkInterface != null && networkInterface.OperationalStatus == OperationalStatus.Up && await InterfacePing();
|
||||||
|
}
|
||||||
|
private async Task<bool> InterfacePing()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using Ping ping = new Ping();
|
||||||
|
PingReply pingReply = await ping.SendPingAsync(runningConfig.Data.Tuntap.IP, 500);
|
||||||
|
return pingReply.Status == IPStatus.Success;
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
67
linker/plugins/tuntap/client/TuntapPingTransfer.cs
Normal file
67
linker/plugins/tuntap/client/TuntapPingTransfer.cs
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
using linker.client.config;
|
||||||
|
using linker.libs;
|
||||||
|
using linker.plugins.tuntap.config;
|
||||||
|
using linker.tunnel.connection;
|
||||||
|
using System.Net.NetworkInformation;
|
||||||
|
using System.Net;
|
||||||
|
using linker.config;
|
||||||
|
|
||||||
|
namespace linker.plugins.tuntap.client
|
||||||
|
{
|
||||||
|
public sealed class TuntapPingTransfer
|
||||||
|
{
|
||||||
|
private readonly TuntapTransfer tuntapTransfer;
|
||||||
|
private readonly TuntapConfigTransfer tuntapConfigTransfer;
|
||||||
|
private readonly FileConfig config;
|
||||||
|
private readonly TuntapProxy tuntapProxy;
|
||||||
|
private readonly RunningConfig runningConfig;
|
||||||
|
public TuntapPingTransfer(TuntapTransfer tuntapTransfer, TuntapConfigTransfer tuntapConfigTransfer, FileConfig config, TuntapProxy tuntapProxy, RunningConfig runningConfig)
|
||||||
|
{
|
||||||
|
this.tuntapTransfer = tuntapTransfer;
|
||||||
|
this.tuntapConfigTransfer = tuntapConfigTransfer;
|
||||||
|
this.config = config;
|
||||||
|
this.tuntapProxy = tuntapProxy;
|
||||||
|
this.runningConfig = runningConfig;
|
||||||
|
PingTask();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly LastTicksManager lastTicksManager = new LastTicksManager();
|
||||||
|
public void SubscribePing()
|
||||||
|
{
|
||||||
|
lastTicksManager.Update();
|
||||||
|
}
|
||||||
|
private void PingTask()
|
||||||
|
{
|
||||||
|
TimerHelper.SetInterval(async () =>
|
||||||
|
{
|
||||||
|
if (tuntapTransfer.Status == TuntapStatus.Running && lastTicksManager.DiffLessEqual(5000))
|
||||||
|
{
|
||||||
|
await Ping();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}, () => tuntapTransfer.Status == TuntapStatus.Running && lastTicksManager.DiffLessEqual(5000) ? 3000 : 30000);
|
||||||
|
}
|
||||||
|
private async Task Ping()
|
||||||
|
{
|
||||||
|
if (tuntapTransfer.Status == TuntapStatus.Running && (runningConfig.Data.Tuntap.Switch & TuntapSwitch.ShowDelay) == TuntapSwitch.ShowDelay)
|
||||||
|
{
|
||||||
|
var items = tuntapConfigTransfer.Infos.Values.Where(c => c.IP != null && c.IP.Equals(IPAddress.Any) == false && (c.Status & TuntapStatus.Running) == TuntapStatus.Running);
|
||||||
|
if ((runningConfig.Data.Tuntap.Switch & TuntapSwitch.AutoConnect) != TuntapSwitch.AutoConnect)
|
||||||
|
{
|
||||||
|
var connections = tuntapProxy.GetConnections();
|
||||||
|
items = items.Where(c => connections.TryGetValue(c.MachineId, out ITunnelConnection connection) && connection.Connected || c.MachineId == config.Data.Client.Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var item in items)
|
||||||
|
{
|
||||||
|
using Ping ping = new Ping();
|
||||||
|
PingReply pingReply = await ping.SendPingAsync(item.IP, 500);
|
||||||
|
item.Delay = pingReply.Status == IPStatus.Success ? (int)pingReply.RoundtripTime : -1;
|
||||||
|
|
||||||
|
tuntapConfigTransfer.Version.Add();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -1,7 +1,6 @@
|
|||||||
using linker.client.config;
|
using linker.client.config;
|
||||||
using linker.libs;
|
using linker.libs;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.NetworkInformation;
|
|
||||||
using linker.plugins.client;
|
using linker.plugins.client;
|
||||||
using linker.plugins.tuntap.config;
|
using linker.plugins.tuntap.config;
|
||||||
using linker.tun;
|
using linker.tun;
|
||||||
@@ -10,15 +9,17 @@ namespace linker.plugins.tuntap.client
|
|||||||
{
|
{
|
||||||
public sealed class TuntapTransfer
|
public sealed class TuntapTransfer
|
||||||
{
|
{
|
||||||
private readonly RunningConfig runningConfig;
|
|
||||||
private readonly LinkerTunDeviceAdapter linkerTunDeviceAdapter;
|
private readonly LinkerTunDeviceAdapter linkerTunDeviceAdapter;
|
||||||
|
|
||||||
private string deviceName = "linker";
|
|
||||||
|
|
||||||
private OperatingManager operatingManager = new OperatingManager();
|
private OperatingManager operatingManager = new OperatingManager();
|
||||||
public TuntapStatus Status => operatingManager.Operating ? TuntapStatus.Operating : (TuntapStatus)(byte)linkerTunDeviceAdapter.Status;
|
public TuntapStatus Status => operatingManager.Operating ? TuntapStatus.Operating : (TuntapStatus)(byte)linkerTunDeviceAdapter.Status;
|
||||||
public string Error => linkerTunDeviceAdapter.Error;
|
public string Error => linkerTunDeviceAdapter.Error;
|
||||||
public string Error1 => linkerTunDeviceAdapter.Error1;
|
public string Error1 => linkerTunDeviceAdapter.Error1;
|
||||||
|
|
||||||
|
public string DeviceName => "linker";
|
||||||
|
|
||||||
public Action OnSetupBefore { get; set; } = () => { };
|
public Action OnSetupBefore { get; set; } = () => { };
|
||||||
public Action OnSetupAfter { get; set; } = () => { };
|
public Action OnSetupAfter { get; set; } = () => { };
|
||||||
public Action OnSetupSuccess { get; set; } = () => { };
|
public Action OnSetupSuccess { get; set; } = () => { };
|
||||||
@@ -26,25 +27,19 @@ namespace linker.plugins.tuntap.client
|
|||||||
public Action OnShutdownAfter { get; set; } = () => { };
|
public Action OnShutdownAfter { get; set; } = () => { };
|
||||||
public Action OnShutdownSuccess { get; set; } = () => { };
|
public Action OnShutdownSuccess { get; set; } = () => { };
|
||||||
|
|
||||||
private ulong setupTimes = 0;
|
|
||||||
|
|
||||||
public TuntapTransfer(ClientSignInState clientSignInState, LinkerTunDeviceAdapter linkerTunDeviceAdapter, TuntapProxy tuntapProxy, RunningConfig runningConfig)
|
public TuntapTransfer(ClientSignInState clientSignInState, LinkerTunDeviceAdapter linkerTunDeviceAdapter, TuntapProxy tuntapProxy, RunningConfig runningConfig)
|
||||||
{
|
{
|
||||||
this.linkerTunDeviceAdapter = linkerTunDeviceAdapter;
|
this.linkerTunDeviceAdapter = linkerTunDeviceAdapter;
|
||||||
this.runningConfig = runningConfig;
|
|
||||||
|
|
||||||
linkerTunDeviceAdapter.Initialize(deviceName, tuntapProxy);
|
linkerTunDeviceAdapter.Initialize(DeviceName, tuntapProxy);
|
||||||
AppDomain.CurrentDomain.ProcessExit += (s, e) => linkerTunDeviceAdapter.Shutdown();
|
AppDomain.CurrentDomain.ProcessExit += (s, e) => linkerTunDeviceAdapter.Shutdown();
|
||||||
Console.CancelKeyPress += (s, e) => linkerTunDeviceAdapter.Shutdown();
|
Console.CancelKeyPress += (s, e) => linkerTunDeviceAdapter.Shutdown();
|
||||||
|
|
||||||
|
|
||||||
CheckTuntapStatusTask();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 运行网卡
|
/// 运行网卡
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Setup()
|
public void Setup(IPAddress ip,byte prefixLength)
|
||||||
{
|
{
|
||||||
if (operatingManager.StartOperation() == false)
|
if (operatingManager.StartOperation() == false)
|
||||||
{
|
{
|
||||||
@@ -55,14 +50,13 @@ namespace linker.plugins.tuntap.client
|
|||||||
OnSetupBefore();
|
OnSetupBefore();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (runningConfig.Data.Tuntap.IP.Equals(IPAddress.Any))
|
if (ip.Equals(IPAddress.Any))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
linkerTunDeviceAdapter.Setup(runningConfig.Data.Tuntap.IP, runningConfig.Data.Tuntap.PrefixLength, 1400);
|
linkerTunDeviceAdapter.Setup(ip, prefixLength, 1400);
|
||||||
if (string.IsNullOrWhiteSpace(linkerTunDeviceAdapter.Error))
|
if (string.IsNullOrWhiteSpace(linkerTunDeviceAdapter.Error))
|
||||||
{
|
{
|
||||||
setupTimes++;
|
|
||||||
linkerTunDeviceAdapter.SetNat();
|
linkerTunDeviceAdapter.SetNat();
|
||||||
OnSetupSuccess();
|
OnSetupSuccess();
|
||||||
}
|
}
|
||||||
@@ -135,51 +129,5 @@ namespace linker.plugins.tuntap.client
|
|||||||
linkerTunDeviceAdapter.DelRoute(ips);
|
linkerTunDeviceAdapter.DelRoute(ips);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void CheckTuntapStatusTask()
|
|
||||||
{
|
|
||||||
TimerHelper.SetInterval(async () =>
|
|
||||||
{
|
|
||||||
if (setupTimes > 0 && runningConfig.Data.Tuntap.Running && OperatingSystem.IsWindows())
|
|
||||||
{
|
|
||||||
await InterfaceCheck().ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}, 15000);
|
|
||||||
}
|
|
||||||
private async Task InterfaceCheck()
|
|
||||||
{
|
|
||||||
if (await InterfaceAvailable() == false && operatingManager.Operating == false)
|
|
||||||
{
|
|
||||||
LoggerHelper.Instance.Error($"tuntap inerface {deviceName} is down, restarting");
|
|
||||||
linkerTunDeviceAdapter.Shutdown();
|
|
||||||
await Task.Delay(5000).ConfigureAwait(false);
|
|
||||||
if (await InterfaceAvailable() == false && operatingManager.Operating == false)
|
|
||||||
{
|
|
||||||
Setup();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private async Task<bool> InterfaceAvailable()
|
|
||||||
{
|
|
||||||
NetworkInterface networkInterface = NetworkInterface.GetAllNetworkInterfaces().FirstOrDefault(c => c.Name == deviceName);
|
|
||||||
return networkInterface != null && networkInterface.OperationalStatus == OperationalStatus.Up && await InterfacePing();
|
|
||||||
}
|
|
||||||
private async Task<bool> InterfacePing()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using Ping ping = new Ping();
|
|
||||||
PingReply pingReply = await ping.SendPingAsync(runningConfig.Data.Tuntap.IP, 500);
|
|
||||||
return pingReply.Status == IPStatus.Success;
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -84,7 +84,7 @@ namespace linker.plugins.tuntap.lease
|
|||||||
});
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}, 30000);
|
}, () => 60000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,6 @@ using linker.plugins.tuntap.client;
|
|||||||
using linker.plugins.tuntap.config;
|
using linker.plugins.tuntap.config;
|
||||||
using linker.plugins.tuntap.lease;
|
using linker.plugins.tuntap.lease;
|
||||||
using MemoryPack;
|
using MemoryPack;
|
||||||
using System.Net;
|
|
||||||
|
|
||||||
namespace linker.plugins.tuntap.messenger
|
namespace linker.plugins.tuntap.messenger
|
||||||
{
|
{
|
||||||
@@ -31,12 +30,7 @@ namespace linker.plugins.tuntap.messenger
|
|||||||
[MessengerId((ushort)TuntapMessengerIds.Run)]
|
[MessengerId((ushort)TuntapMessengerIds.Run)]
|
||||||
public void Run(IConnection connection)
|
public void Run(IConnection connection)
|
||||||
{
|
{
|
||||||
TimerHelper.Async(async () =>
|
_ = tuntapConfigTransfer.RetstartDevice();
|
||||||
{
|
|
||||||
tuntapTransfer.Shutdown();
|
|
||||||
await tuntapConfigTransfer.RefreshIPForce();
|
|
||||||
tuntapTransfer.Setup();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -46,7 +40,7 @@ namespace linker.plugins.tuntap.messenger
|
|||||||
[MessengerId((ushort)TuntapMessengerIds.Stop)]
|
[MessengerId((ushort)TuntapMessengerIds.Stop)]
|
||||||
public void Stop(IConnection connection)
|
public void Stop(IConnection connection)
|
||||||
{
|
{
|
||||||
tuntapTransfer.Shutdown();
|
tuntapConfigTransfer.StopDevice();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@@ -80,17 +80,18 @@ namespace linker.plugins.updater
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private readonly LastTicksManager lastTicksManager = new LastTicksManager();
|
||||||
public void Subscribe(string machineId)
|
public void Subscribe(string machineId)
|
||||||
{
|
{
|
||||||
if (subscribes.TryGetValue(machineId, out LastTicksManager lastTicksManager) == false)
|
if (subscribes.TryGetValue(machineId, out LastTicksManager _lastTicksManager) == false)
|
||||||
{
|
{
|
||||||
lastTicksManager = new LastTicksManager();
|
_lastTicksManager = new LastTicksManager();
|
||||||
subscribes.TryAdd(machineId, lastTicksManager);
|
subscribes.TryAdd(machineId, _lastTicksManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
//距离上次订阅超过一分钟,需要立即更新一次
|
//距离上次订阅超过一分钟,需要立即更新一次
|
||||||
bool needUpdate = lastTicksManager.DiffGreater(60 * 1000);
|
bool needUpdate = _lastTicksManager.DiffGreater(60 * 1000);
|
||||||
|
_lastTicksManager.Update();
|
||||||
lastTicksManager.Update();
|
lastTicksManager.Update();
|
||||||
|
|
||||||
if (needUpdate)
|
if (needUpdate)
|
||||||
@@ -119,7 +120,7 @@ namespace linker.plugins.updater
|
|||||||
Update(updateInfo);
|
Update(updateInfo);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}, 1000);
|
}, () => lastTicksManager.DiffLessEqual(5000) ? 1000 : 15000);
|
||||||
|
|
||||||
}
|
}
|
||||||
private void LoadTask()
|
private void LoadTask()
|
||||||
@@ -128,7 +129,7 @@ namespace linker.plugins.updater
|
|||||||
{
|
{
|
||||||
await updaterHelper.GetUpdateInfo(updateInfo);
|
await updaterHelper.GetUpdateInfo(updateInfo);
|
||||||
return true;
|
return true;
|
||||||
}, 15000);
|
}, () => 30000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,8 +1,9 @@
|
|||||||
v1.4.9
|
v1.5.0
|
||||||
2024-10-18 17:15:48
|
2024-10-20 18:50:45
|
||||||
1. 新增多分组管理,方便分组切换
|
1. 新增多分组管理,方便分组切换
|
||||||
2. 增加分组密码,提高分组隔离安全性
|
2. 增加分组密码,提高分组隔离安全性
|
||||||
3. 优化配置同步,可自由选择同步哪些信息
|
3. 优化配置同步,可自由选择同步哪些信息
|
||||||
4. 自动分配虚拟网卡IP
|
4. 自动分配虚拟网卡IP
|
||||||
5. 线程池优化
|
5. 线程池优化
|
||||||
6. 一些UI优化
|
6. 一些UI优化
|
||||||
|
7. 测试中,不要更新,不要更新,不要更新,请使用v1.4.9
|
Reference in New Issue
Block a user