Compare commits

..

No commits in common. "5ce0bb6e4a4976861578bcef4e77f6939e19d00e" and "01d35456bde3be7ecfd8b1ea7d0916fe1b764312" have entirely different histories.

6 changed files with 85 additions and 145 deletions

View file

@ -1,32 +0,0 @@
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

View file

@ -28,7 +28,7 @@ jobs:
- name: Build - name: Build
run: cd v2rayN && run: cd v2rayN &&
./build.ps1 .\build.ps1
# - name: Package # - name: Package
# shell: pwsh # shell: pwsh
@ -40,7 +40,7 @@ jobs:
with: with:
name: v2rayN name: v2rayN
path: | path: |
./v2rayN/v2rayN.zip .\v2rayN\v2rayN.zip
# - name: Release # - name: Release
# uses: softprops/action-gh-release@v1 # uses: softprops/action-gh-release@v1

View file

@ -1026,36 +1026,6 @@ namespace ServiceLib.Handler
return result; 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 #endregion Server
#region Batch add servers #region Batch add servers

View file

@ -64,30 +64,49 @@ namespace ServiceLib.Handler
ShowMsg(true, result.Msg); ShowMsg(true, result.Msg);
return; 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);
ShowMsg(true, $"{node.GetSummary()}"); //In tun mode, do a delay check and restart the core
ShowMsg(false, $"{Environment.OSVersion} - {(Environment.Is64BitOperatingSystem ? 64 : 32)}"); //if (_config.tunModeItem.enableTun)
ShowMsg(false, string.Format(ResUI.StartService, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"))); //{
await CoreStop(); // Observable.Range(1, 1)
await Task.Delay(100); // .Delay(TimeSpan.FromSeconds(15))
await CoreStart(node); // .Subscribe(x =>
await CoreStartPreService(node); // {
// {
// if (_process == null || _process.HasExited)
// {
// CoreStart(node);
// ShowMsg(false, "Tun mode restart the core once");
// Logging.SaveLog("Tun mode restart the core once");
// }
// }
// });
//}
}
} }
public async Task<int> LoadCoreConfigSpeedtest(List<ServerTestItem> selecteds) 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 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 configPath = Utils.GetConfigPath(Global.CoreSpeedtestConfigFileName);
var result = await CoreConfigHandler.GenerateClientSpeedtestConfig(_config, configPath, selecteds, coreType); var result = await CoreConfigHandler.GenerateClientSpeedtestConfig(_config, configPath, selecteds, coreType);
ShowMsg(false, result.Msg); ShowMsg(false, result.Msg);
if (result.Success != true) if (result.Success)
{ {
return -1; ShowMsg(false, string.Format(ResUI.StartService, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")));
ShowMsg(false, configPath);
pid = await CoreStartSpeedtest(configPath, coreType);
} }
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() public async Task CoreStop()
@ -152,7 +171,8 @@ namespace ServiceLib.Handler
private async Task CoreStart(ProfileItem node) private async Task CoreStart(ProfileItem node)
{ {
var coreType = _config.RunningCoreType = AppHandler.Instance.GetCoreType(node, node.ConfigType); var coreType = AppHandler.Instance.GetCoreType(node, node.ConfigType);
_config.RunningCoreType = coreType;
var coreInfo = CoreInfoHandler.Instance.GetCoreInfo(coreType); var coreInfo = CoreInfoHandler.Instance.GetCoreInfo(coreType);
var displayLog = node.ConfigType != EConfigType.Custom || node.DisplayLog; var displayLog = node.ConfigType != EConfigType.Custom || node.DisplayLog;
@ -162,28 +182,47 @@ namespace ServiceLib.Handler
return; return;
} }
_process = proc; _process = proc;
}
private async Task CoreStartPreService(ProfileItem node) //start a pre service
{
if (_process != null && !_process.HasExited) if (_process != null && !_process.HasExited)
{ {
var coreType = AppHandler.Instance.GetCoreType(node, node.ConfigType); ProfileItem? itemSocks = null;
var itemSocks = await ConfigHandler.GetPreSocksItem(_config, node, coreType); 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;
}
if (itemSocks != null) if (itemSocks != null)
{ {
var preCoreType = _config.RunningCoreType = itemSocks.CoreType ?? ECoreType.sing_box; var fileName2 = Utils.GetConfigPath(Global.CorePreConfigFileName);
var fileName = Utils.GetConfigPath(Global.CorePreConfigFileName); var result = await CoreConfigHandler.GenerateClientConfig(itemSocks, fileName2);
var result = await CoreConfigHandler.GenerateClientConfig(itemSocks, fileName);
if (result.Success) if (result.Success)
{ {
var coreInfo = CoreInfoHandler.Instance.GetCoreInfo(preCoreType); var coreInfo2 = CoreInfoHandler.Instance.GetCoreInfo(preCoreType);
var proc = await RunProcess(coreInfo, Global.CorePreConfigFileName, true, true); var proc2 = await RunProcess(coreInfo2, Global.CorePreConfigFileName, true, true);
if (proc is null) if (proc2 is not null)
{ {
return; _processPre = proc2;
} }
_processPre = proc;
} }
} }
} }
@ -352,24 +391,24 @@ namespace ServiceLib.Handler
{ {
return; return;
} }
var timeout = new CancellationTokenSource(TimeSpan.FromSeconds(1));
try try
{ {
proc?.Kill(); await proc.WaitForExitAsync(timeout.Token);
} }
catch (Exception) catch (OperationCanceledException)
{ {
// ignored proc.Kill();
} }
await Task.Delay(100); if (!proc.HasExited)
if (proc?.HasExited == false)
{ {
try try
{ {
proc?.Kill(); await proc.WaitForExitAsync(timeout.Token);
} }
catch (Exception) catch (Exception)
{ {
// ignored proc.Kill();
} }
} }
} }

View file

@ -1,17 +0,0 @@
#!/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

View file

@ -2,57 +2,37 @@ param (
[Parameter()] [Parameter()]
[ValidateNotNullOrEmpty()] [ValidateNotNullOrEmpty()]
[string] [string]
$OutputPath = './bin/v2rayN' $OutputPath = '.\bin\v2rayN'
) )
Write-Host 'Building' Write-Host 'Building'
dotnet publish ` dotnet publish `
./v2rayN/v2rayN.csproj ` .\v2rayN\v2rayN.csproj `
-c Release ` -c Release `
-r win-x64 ` -r win-x64 `
--self-contained false ` --self-contained false `
-p:PublishReadyToRun=false ` -p:PublishReadyToRun=false `
-p:PublishSingleFile=true ` -p:PublishSingleFile=true `
-o "$OutputPath/win-x64" -o "$OutputPath\win-x64"
dotnet publish ` dotnet publish `
./v2rayN/v2rayN.csproj ` .\v2rayN.Desktop\v2rayN.Desktop.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 ` -c Release `
-r linux-x64 ` -r linux-x64 `
--self-contained true ` --self-contained true `
-p:PublishReadyToRun=false ` -p:PublishReadyToRun=false `
-p:PublishSingleFile=true ` -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 $? ) { if ( -Not $? ) {
exit $lastExitCode exit $lastExitCode
} }
if ( Test-Path -Path ./bin/v2rayN ) { if ( Test-Path -Path .\bin\v2rayN ) {
rm -Force "$OutputPath/win-x64/*.pdb" rm -Force "$OutputPath\win-x64\*.pdb"
rm -Force "$OutputPath/win-arm64/*.pdb" rm -Force "$OutputPath\linux-x64\*.pdb"
rm -Force "$OutputPath/linux-x64/*.pdb"
rm -Force "$OutputPath/linux-arm64/*.pdb"
} }
Write-Host 'Build done' Write-Host 'Build done'