增加dnscryptproxy目录

This commit is contained in:
陈国伟 2021-08-20 09:39:48 +08:00
parent b3986ed081
commit c0ca95335c
4 changed files with 42 additions and 19 deletions

18
@libs/LICENSE Normal file
View File

@ -0,0 +1,18 @@
/*
* ISC License
*
* Copyright (c) 2018-2021
* Frank Denis <j at pureftpd dot org>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

View File

@ -1,5 +1,6 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Threading;
@ -12,7 +13,8 @@ namespace FastGithub.DomainResolve
/// </summary>
sealed class DnscryptProxy
{
private const string name = "dnscrypt-proxy";
private const string PATH = "dnscryptproxy";
private const string Name = "dnscrypt-proxy";
/// <summary>
/// 相关进程
@ -40,11 +42,11 @@ namespace FastGithub.DomainResolve
/// <returns></returns>
public async Task StartAsync(CancellationToken cancellationToken)
{
var tomlPath = $"{name}.toml";
var tomlPath = Path.Combine(PATH, $"{Name}.toml");
await TomlUtil.SetListensAsync(tomlPath, this.EndPoint, cancellationToken);
await TomlUtil.SetEdnsClientSubnetAsync(tomlPath, cancellationToken);
foreach (var process in Process.GetProcessesByName(name))
foreach (var process in Process.GetProcessesByName(Name))
{
process.Kill();
process.WaitForExit();
@ -55,7 +57,7 @@ namespace FastGithub.DomainResolve
StartDnscryptProxy("-service uninstall")?.WaitForExit();
StartDnscryptProxy("-service install")?.WaitForExit();
StartDnscryptProxy("-service start")?.WaitForExit();
this.process = Process.GetProcessesByName(name).FirstOrDefault(item => item.SessionId == 0);
this.process = Process.GetProcessesByName(Name).FirstOrDefault(item => item.SessionId == 0);
}
else
{
@ -86,11 +88,13 @@ namespace FastGithub.DomainResolve
/// <param name="arguments"></param>
private static Process? StartDnscryptProxy(string arguments)
{
var fileName = OperatingSystem.IsWindows() ? $"{Name}.exe" : Name;
return Process.Start(new ProcessStartInfo
{
FileName = OperatingSystem.IsWindows() ? $"{name}.exe" : name,
FileName = Path.Combine(PATH, fileName),
Arguments = arguments,
UseShellExecute = true,
WorkingDirectory = PATH,
UseShellExecute = false,
CreateNoWindow = true,
WindowStyle = ProcessWindowStyle.Hidden
});
@ -102,7 +106,7 @@ namespace FastGithub.DomainResolve
/// <returns></returns>
public override string ToString()
{
return name;
return Name;
}
}
}

View File

@ -8,25 +8,28 @@
</ItemGroup>
<ItemGroup>
<None Include="../@libs/dnscrypt-proxy.toml" Link="dnscrypt-proxy.toml">
<None Include="../@libs/dnscrypt-proxy.toml" Link="dnscryptproxy/dnscrypt-proxy.toml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="../@libs/LICENSE" Link="dnscryptproxy/LICENSE">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup Condition="'$(RuntimeIdentifier)' == 'win-x64'">
<None Include="../@libs/windows-x64/dnscrypt-proxy.exe" Link="dnscrypt-proxy.exe">
<None Include="../@libs/windows-x64/dnscrypt-proxy.exe" Link="dnscryptproxy/dnscrypt-proxy.exe">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup Condition="'$(RuntimeIdentifier)' == 'linux-x64'">
<None Include="../@libs/linux-x64/dnscrypt-proxy" Link="dnscrypt-proxy">
<None Include="../@libs/linux-x64/dnscrypt-proxy" Link="dnscryptproxy/dnscrypt-proxy">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup Condition="'$(RuntimeIdentifier)' == 'osx-x64'">
<None Include="../@libs/osx-x64/dnscrypt-proxy" Link="dnscrypt-proxy">
<None Include="../@libs/osx-x64/dnscrypt-proxy" Link="dnscryptproxy/dnscrypt-proxy">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

14
pack.sh
View File

@ -2,17 +2,15 @@
cd ./FastGithub/bin/publish
# linux-x64
chmod 777 ./linux-x64/dnscrypt-proxy
chmod 777 ./linux-x64/FastGithub
zip -r linux-x64.zip linux-x64
chmod 777 ./FastGithub_linux-x64/FastGithub
chmod 777 ./FastGithub_linux-x64/dnscryptproxy/dnscrypt-proxy
zip -r FastGithub_linux-x64.zip FastGithub_linux-x64
# osx-x64
chmod 777 ./osx-x64/dnscrypt-proxy
chmod 777 ./osx-x64/FastGithub
zip -r osx-x64.zip osx-x64
zip -r FastGithub_osx-x64.zip FastGithub_osx-x64
# win10-x64
zip -r win10-x64.zip win10-x64 -x "./win10-x64/aspnetcorev2_inprocess.dll"
zip -r FastGithub_win10-x64.zip FastGithub_win10-x64 -x "./win10-x64/aspnetcorev2_inprocess.dll"
# win7-x64
zip -r win7-x64.zip win7-x64
zip -r FastGithub_win7-x64.zip FastGithub_win7-x64