mirror of
https://github.com/2dust/v2rayN.git
synced 2025-08-23 19:36:55 +00:00
Compare commits
11 commits
01d35456bd
...
5ce0bb6e4a
Author | SHA1 | Date | |
---|---|---|---|
![]() |
5ce0bb6e4a | ||
![]() |
487b1ab182 | ||
![]() |
5c144a8ba3 | ||
![]() |
ad344356df | ||
![]() |
a55c65374d | ||
![]() |
28447a9d43 | ||
![]() |
0c03550c62 | ||
![]() |
6d9a84803f | ||
![]() |
03b0e4e2bb | ||
![]() |
a00e9a6f5e | ||
![]() |
ba17f8fde9 |
6 changed files with 145 additions and 85 deletions
32
.github/workflows/build-osx.yml
vendored
Normal file
32
.github/workflows/build-osx.yml
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
name: release macos
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "master" ]
|
||||
pull_request:
|
||||
branches: [ "master" ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
configuration: [Release]
|
||||
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Build
|
||||
run: cd v2rayN &&
|
||||
./build-osx.sh
|
||||
|
||||
- name: Upload build artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: v2rayN
|
||||
path: |
|
||||
./v2rayN/v2rayN-osx.zip
|
||||
|
||||
|
4
.github/workflows/build.yml
vendored
4
.github/workflows/build.yml
vendored
|
@ -28,7 +28,7 @@ jobs:
|
|||
|
||||
- name: Build
|
||||
run: cd v2rayN &&
|
||||
.\build.ps1
|
||||
./build.ps1
|
||||
|
||||
# - name: Package
|
||||
# shell: pwsh
|
||||
|
@ -40,7 +40,7 @@ jobs:
|
|||
with:
|
||||
name: v2rayN
|
||||
path: |
|
||||
.\v2rayN\v2rayN.zip
|
||||
./v2rayN/v2rayN.zip
|
||||
|
||||
# - name: Release
|
||||
# uses: softprops/action-gh-release@v1
|
||||
|
|
|
@ -1026,6 +1026,36 @@ namespace ServiceLib.Handler
|
|||
return result;
|
||||
}
|
||||
|
||||
public static async Task<ProfileItem?> GetPreSocksItem(Config config, ProfileItem node, ECoreType coreType)
|
||||
{
|
||||
ProfileItem? itemSocks = null;
|
||||
var preCoreType = ECoreType.sing_box;
|
||||
if (node.ConfigType != EConfigType.Custom && coreType != ECoreType.sing_box && config.TunModeItem.EnableTun)
|
||||
{
|
||||
itemSocks = new ProfileItem()
|
||||
{
|
||||
CoreType = preCoreType,
|
||||
ConfigType = EConfigType.SOCKS,
|
||||
Address = Global.Loopback,
|
||||
Sni = node.Address, //Tun2SocksAddress
|
||||
Port = AppHandler.Instance.GetLocalPort(EInboundProtocol.socks)
|
||||
};
|
||||
}
|
||||
else if ((node.ConfigType == EConfigType.Custom && node.PreSocksPort > 0))
|
||||
{
|
||||
preCoreType = config.TunModeItem.EnableTun ? ECoreType.sing_box : ECoreType.Xray;
|
||||
itemSocks = new ProfileItem()
|
||||
{
|
||||
CoreType = preCoreType,
|
||||
ConfigType = EConfigType.SOCKS,
|
||||
Address = Global.Loopback,
|
||||
Port = node.PreSocksPort.Value,
|
||||
};
|
||||
}
|
||||
|
||||
return itemSocks;
|
||||
}
|
||||
|
||||
#endregion Server
|
||||
|
||||
#region Batch add servers
|
||||
|
|
|
@ -64,49 +64,30 @@ namespace ServiceLib.Handler
|
|||
ShowMsg(true, result.Msg);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMsg(true, $"{node.GetSummary()}");
|
||||
ShowMsg(false, $"{Environment.OSVersion} - {(Environment.Is64BitOperatingSystem ? 64 : 32)}");
|
||||
ShowMsg(false, string.Format(ResUI.StartService, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")));
|
||||
await CoreStop();
|
||||
await Task.Delay(100);
|
||||
await CoreStart(node);
|
||||
|
||||
//In tun mode, do a delay check and restart the core
|
||||
//if (_config.tunModeItem.enableTun)
|
||||
//{
|
||||
// Observable.Range(1, 1)
|
||||
// .Delay(TimeSpan.FromSeconds(15))
|
||||
// .Subscribe(x =>
|
||||
// {
|
||||
// {
|
||||
// if (_process == null || _process.HasExited)
|
||||
// {
|
||||
// CoreStart(node);
|
||||
// ShowMsg(false, "Tun mode restart the core once");
|
||||
// Logging.SaveLog("Tun mode restart the core once");
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
//}
|
||||
}
|
||||
ShowMsg(true, $"{node.GetSummary()}");
|
||||
ShowMsg(false, $"{Environment.OSVersion} - {(Environment.Is64BitOperatingSystem ? 64 : 32)}");
|
||||
ShowMsg(false, string.Format(ResUI.StartService, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")));
|
||||
await CoreStop();
|
||||
await Task.Delay(100);
|
||||
await CoreStart(node);
|
||||
await CoreStartPreService(node);
|
||||
}
|
||||
|
||||
public async Task<int> LoadCoreConfigSpeedtest(List<ServerTestItem> selecteds)
|
||||
{
|
||||
var pid = -1;
|
||||
var coreType = selecteds.Exists(t => t.ConfigType is EConfigType.Hysteria2 or EConfigType.TUIC or EConfigType.WireGuard) ? ECoreType.sing_box : ECoreType.Xray;
|
||||
var configPath = Utils.GetConfigPath(Global.CoreSpeedtestConfigFileName);
|
||||
var result = await CoreConfigHandler.GenerateClientSpeedtestConfig(_config, configPath, selecteds, coreType);
|
||||
ShowMsg(false, result.Msg);
|
||||
if (result.Success)
|
||||
if (result.Success != true)
|
||||
{
|
||||
ShowMsg(false, string.Format(ResUI.StartService, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")));
|
||||
ShowMsg(false, configPath);
|
||||
pid = await CoreStartSpeedtest(configPath, coreType);
|
||||
return -1;
|
||||
}
|
||||
return pid;
|
||||
|
||||
ShowMsg(false, string.Format(ResUI.StartService, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")));
|
||||
ShowMsg(false, configPath);
|
||||
return await CoreStartSpeedtest(configPath, coreType);
|
||||
}
|
||||
|
||||
public async Task CoreStop()
|
||||
|
@ -171,8 +152,7 @@ namespace ServiceLib.Handler
|
|||
|
||||
private async Task CoreStart(ProfileItem node)
|
||||
{
|
||||
var coreType = AppHandler.Instance.GetCoreType(node, node.ConfigType);
|
||||
_config.RunningCoreType = coreType;
|
||||
var coreType = _config.RunningCoreType = AppHandler.Instance.GetCoreType(node, node.ConfigType);
|
||||
var coreInfo = CoreInfoHandler.Instance.GetCoreInfo(coreType);
|
||||
|
||||
var displayLog = node.ConfigType != EConfigType.Custom || node.DisplayLog;
|
||||
|
@ -182,47 +162,28 @@ namespace ServiceLib.Handler
|
|||
return;
|
||||
}
|
||||
_process = proc;
|
||||
}
|
||||
|
||||
//start a pre service
|
||||
private async Task CoreStartPreService(ProfileItem node)
|
||||
{
|
||||
if (_process != null && !_process.HasExited)
|
||||
{
|
||||
ProfileItem? itemSocks = null;
|
||||
var preCoreType = ECoreType.sing_box;
|
||||
if (node.ConfigType != EConfigType.Custom && coreType != ECoreType.sing_box && _config.TunModeItem.EnableTun)
|
||||
{
|
||||
itemSocks = new ProfileItem()
|
||||
{
|
||||
CoreType = preCoreType,
|
||||
ConfigType = EConfigType.SOCKS,
|
||||
Address = Global.Loopback,
|
||||
Sni = node.Address, //Tun2SocksAddress
|
||||
Port = AppHandler.Instance.GetLocalPort(EInboundProtocol.socks)
|
||||
};
|
||||
}
|
||||
else if ((node.ConfigType == EConfigType.Custom && node.PreSocksPort > 0))
|
||||
{
|
||||
preCoreType = _config.TunModeItem.EnableTun ? ECoreType.sing_box : ECoreType.Xray;
|
||||
itemSocks = new ProfileItem()
|
||||
{
|
||||
CoreType = preCoreType,
|
||||
ConfigType = EConfigType.SOCKS,
|
||||
Address = Global.Loopback,
|
||||
Port = node.PreSocksPort.Value,
|
||||
};
|
||||
_config.RunningCoreType = preCoreType;
|
||||
}
|
||||
var coreType = AppHandler.Instance.GetCoreType(node, node.ConfigType);
|
||||
var itemSocks = await ConfigHandler.GetPreSocksItem(_config, node, coreType);
|
||||
if (itemSocks != null)
|
||||
{
|
||||
var fileName2 = Utils.GetConfigPath(Global.CorePreConfigFileName);
|
||||
var result = await CoreConfigHandler.GenerateClientConfig(itemSocks, fileName2);
|
||||
var preCoreType = _config.RunningCoreType = itemSocks.CoreType ?? ECoreType.sing_box;
|
||||
var fileName = Utils.GetConfigPath(Global.CorePreConfigFileName);
|
||||
var result = await CoreConfigHandler.GenerateClientConfig(itemSocks, fileName);
|
||||
if (result.Success)
|
||||
{
|
||||
var coreInfo2 = CoreInfoHandler.Instance.GetCoreInfo(preCoreType);
|
||||
var proc2 = await RunProcess(coreInfo2, Global.CorePreConfigFileName, true, true);
|
||||
if (proc2 is not null)
|
||||
var coreInfo = CoreInfoHandler.Instance.GetCoreInfo(preCoreType);
|
||||
var proc = await RunProcess(coreInfo, Global.CorePreConfigFileName, true, true);
|
||||
if (proc is null)
|
||||
{
|
||||
_processPre = proc2;
|
||||
return;
|
||||
}
|
||||
_processPre = proc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -378,7 +339,7 @@ namespace ServiceLib.Handler
|
|||
}
|
||||
await File.WriteAllTextAsync(shFilePath, sb.ToString());
|
||||
await Utils.SetLinuxChmod(shFilePath);
|
||||
|
||||
|
||||
proc.StartInfo.FileName = shFilePath;
|
||||
proc.StartInfo.Arguments = "";
|
||||
proc.StartInfo.WorkingDirectory = "";
|
||||
|
@ -391,24 +352,24 @@ namespace ServiceLib.Handler
|
|||
{
|
||||
return;
|
||||
}
|
||||
var timeout = new CancellationTokenSource(TimeSpan.FromSeconds(1));
|
||||
try
|
||||
{
|
||||
await proc.WaitForExitAsync(timeout.Token);
|
||||
proc?.Kill();
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
catch (Exception)
|
||||
{
|
||||
proc.Kill();
|
||||
// ignored
|
||||
}
|
||||
if (!proc.HasExited)
|
||||
await Task.Delay(100);
|
||||
if (proc?.HasExited == false)
|
||||
{
|
||||
try
|
||||
{
|
||||
await proc.WaitForExitAsync(timeout.Token);
|
||||
proc?.Kill();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
proc.Kill();
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
17
v2rayN/build-osx.sh
Executable file
17
v2rayN/build-osx.sh
Executable file
|
@ -0,0 +1,17 @@
|
|||
#!/bin/sh
|
||||
|
||||
echo 'Building'
|
||||
|
||||
OutputPath='./bin/v2rayN'
|
||||
|
||||
dotnet publish ./v2rayN.Desktop/v2rayN.Desktop.csproj -c Release -r osx-x64 --self-contained true -p:PublishReadyToRun=false -p:PublishSingleFile=true -o "${OutputPath}/osx-x64"
|
||||
dotnet publish ./v2rayN.Desktop/v2rayN.Desktop.csproj -c Release -r osx-arm64 --self-contained true -p:PublishReadyToRun=false -p:PublishSingleFile=true -o "${OutputPath}/osx-arm64"
|
||||
|
||||
rm -rf "$OutputPath/osx-x64/*.pdb"
|
||||
rm -rf "$OutputPath/osx-arm64/*.pdb"
|
||||
|
||||
echo 'Build done'
|
||||
|
||||
ls $OutputPath
|
||||
7z a v2rayN-osx.zip $OutputPath
|
||||
exit 0
|
|
@ -2,37 +2,57 @@ param (
|
|||
[Parameter()]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
$OutputPath = '.\bin\v2rayN'
|
||||
$OutputPath = './bin/v2rayN'
|
||||
)
|
||||
|
||||
Write-Host 'Building'
|
||||
|
||||
dotnet publish `
|
||||
.\v2rayN\v2rayN.csproj `
|
||||
./v2rayN/v2rayN.csproj `
|
||||
-c Release `
|
||||
-r win-x64 `
|
||||
--self-contained false `
|
||||
-p:PublishReadyToRun=false `
|
||||
-p:PublishSingleFile=true `
|
||||
-o "$OutputPath\win-x64"
|
||||
-o "$OutputPath/win-x64"
|
||||
|
||||
dotnet publish `
|
||||
.\v2rayN.Desktop\v2rayN.Desktop.csproj `
|
||||
./v2rayN/v2rayN.csproj `
|
||||
-c Release `
|
||||
-r win-arm64 `
|
||||
--self-contained false `
|
||||
-p:PublishReadyToRun=false `
|
||||
-p:PublishSingleFile=true `
|
||||
-o "$OutputPath/win-arm64"
|
||||
|
||||
dotnet publish `
|
||||
./v2rayN.Desktop/v2rayN.Desktop.csproj `
|
||||
-c Release `
|
||||
-r linux-x64 `
|
||||
--self-contained true `
|
||||
-p:PublishReadyToRun=false `
|
||||
-p:PublishSingleFile=true `
|
||||
-o "$OutputPath\linux-x64"
|
||||
|
||||
-o "$OutputPath/linux-x64"
|
||||
|
||||
dotnet publish `
|
||||
./v2rayN.Desktop/v2rayN.Desktop.csproj `
|
||||
-c Release `
|
||||
-r linux-arm64 `
|
||||
--self-contained true `
|
||||
-p:PublishReadyToRun=false `
|
||||
-p:PublishSingleFile=true `
|
||||
-o "$OutputPath/linux-arm64"
|
||||
|
||||
|
||||
if ( -Not $? ) {
|
||||
exit $lastExitCode
|
||||
}
|
||||
|
||||
if ( Test-Path -Path .\bin\v2rayN ) {
|
||||
rm -Force "$OutputPath\win-x64\*.pdb"
|
||||
rm -Force "$OutputPath\linux-x64\*.pdb"
|
||||
if ( Test-Path -Path ./bin/v2rayN ) {
|
||||
rm -Force "$OutputPath/win-x64/*.pdb"
|
||||
rm -Force "$OutputPath/win-arm64/*.pdb"
|
||||
rm -Force "$OutputPath/linux-x64/*.pdb"
|
||||
rm -Force "$OutputPath/linux-arm64/*.pdb"
|
||||
}
|
||||
|
||||
Write-Host 'Build done'
|
||||
|
|
Loading…
Reference in a new issue