mirror of
https://github.com/2dust/v2rayN.git
synced 2025-08-24 03:46: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
|
- 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
|
||||||
|
|
|
@ -1026,6 +1026,36 @@ 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
|
||||||
|
|
|
@ -64,49 +64,30 @@ namespace ServiceLib.Handler
|
||||||
ShowMsg(true, result.Msg);
|
ShowMsg(true, result.Msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
ShowMsg(true, $"{node.GetSummary()}");
|
ShowMsg(true, $"{node.GetSummary()}");
|
||||||
ShowMsg(false, $"{Environment.OSVersion} - {(Environment.Is64BitOperatingSystem ? 64 : 32)}");
|
ShowMsg(false, $"{Environment.OSVersion} - {(Environment.Is64BitOperatingSystem ? 64 : 32)}");
|
||||||
ShowMsg(false, string.Format(ResUI.StartService, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")));
|
ShowMsg(false, string.Format(ResUI.StartService, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")));
|
||||||
await CoreStop();
|
await CoreStop();
|
||||||
await Task.Delay(100);
|
await Task.Delay(100);
|
||||||
await CoreStart(node);
|
await CoreStart(node);
|
||||||
|
await CoreStartPreService(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");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
if (result.Success != true)
|
||||||
{
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
ShowMsg(false, string.Format(ResUI.StartService, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")));
|
ShowMsg(false, string.Format(ResUI.StartService, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")));
|
||||||
ShowMsg(false, configPath);
|
ShowMsg(false, configPath);
|
||||||
pid = await CoreStartSpeedtest(configPath, coreType);
|
return await CoreStartSpeedtest(configPath, coreType);
|
||||||
}
|
|
||||||
return pid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task CoreStop()
|
public async Task CoreStop()
|
||||||
|
@ -171,8 +152,7 @@ namespace ServiceLib.Handler
|
||||||
|
|
||||||
private async Task CoreStart(ProfileItem node)
|
private async Task CoreStart(ProfileItem node)
|
||||||
{
|
{
|
||||||
var coreType = AppHandler.Instance.GetCoreType(node, node.ConfigType);
|
var coreType = _config.RunningCoreType = 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;
|
||||||
|
@ -182,47 +162,28 @@ namespace ServiceLib.Handler
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_process = proc;
|
_process = proc;
|
||||||
|
}
|
||||||
|
|
||||||
//start a pre service
|
private async Task CoreStartPreService(ProfileItem node)
|
||||||
|
{
|
||||||
if (_process != null && !_process.HasExited)
|
if (_process != null && !_process.HasExited)
|
||||||
{
|
{
|
||||||
ProfileItem? itemSocks = null;
|
var coreType = AppHandler.Instance.GetCoreType(node, node.ConfigType);
|
||||||
var preCoreType = ECoreType.sing_box;
|
var itemSocks = await ConfigHandler.GetPreSocksItem(_config, node, coreType);
|
||||||
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 fileName2 = Utils.GetConfigPath(Global.CorePreConfigFileName);
|
var preCoreType = _config.RunningCoreType = itemSocks.CoreType ?? ECoreType.sing_box;
|
||||||
var result = await CoreConfigHandler.GenerateClientConfig(itemSocks, fileName2);
|
var fileName = Utils.GetConfigPath(Global.CorePreConfigFileName);
|
||||||
|
var result = await CoreConfigHandler.GenerateClientConfig(itemSocks, fileName);
|
||||||
if (result.Success)
|
if (result.Success)
|
||||||
{
|
{
|
||||||
var coreInfo2 = CoreInfoHandler.Instance.GetCoreInfo(preCoreType);
|
var coreInfo = CoreInfoHandler.Instance.GetCoreInfo(preCoreType);
|
||||||
var proc2 = await RunProcess(coreInfo2, Global.CorePreConfigFileName, true, true);
|
var proc = await RunProcess(coreInfo, Global.CorePreConfigFileName, true, true);
|
||||||
if (proc2 is not null)
|
if (proc is null)
|
||||||
{
|
{
|
||||||
_processPre = proc2;
|
return;
|
||||||
}
|
}
|
||||||
|
_processPre = proc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -391,24 +352,24 @@ namespace ServiceLib.Handler
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var timeout = new CancellationTokenSource(TimeSpan.FromSeconds(1));
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await proc.WaitForExitAsync(timeout.Token);
|
proc?.Kill();
|
||||||
}
|
|
||||||
catch (OperationCanceledException)
|
|
||||||
{
|
|
||||||
proc.Kill();
|
|
||||||
}
|
|
||||||
if (!proc.HasExited)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await proc.WaitForExitAsync(timeout.Token);
|
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
proc.Kill();
|
// ignored
|
||||||
|
}
|
||||||
|
await Task.Delay(100);
|
||||||
|
if (proc?.HasExited == false)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
proc?.Kill();
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
// 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()]
|
[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.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 `
|
-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\linux-x64\*.pdb"
|
rm -Force "$OutputPath/win-arm64/*.pdb"
|
||||||
|
rm -Force "$OutputPath/linux-x64/*.pdb"
|
||||||
|
rm -Force "$OutputPath/linux-arm64/*.pdb"
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Host 'Build done'
|
Write-Host 'Build done'
|
||||||
|
|
Loading…
Reference in a new issue