Replace Xray with SagerNet/v2ray-core

This commit is contained in:
H1JK
2022-06-03 02:28:25 +00:00
parent 1fe1fda285
commit c2393efd10
3 changed files with 30 additions and 17 deletions

View File

@@ -8,7 +8,7 @@ namespace Netch.Servers;
public class V2rayController : Guard, IServerController
{
public V2rayController() : base("xray.exe")
public V2rayController() : base("v2ray-sn.exe")
{
if (!Global.Settings.V2RayConfig.XrayCone)
Instance.StartInfo.Environment["XRAY_CONE_DISABLED"] = "true";
@@ -18,7 +18,7 @@ public class V2rayController : Guard, IServerController
protected override IEnumerable<string> FailedKeywords => new[] { "config file not readable", "failed to" };
public override string Name => "Xray";
public override string Name => "V2Ray (SagerNet)";
public ushort? Socks5LocalPort { get; set; }

28
Other/v2ray-sn/build.ps1 Normal file
View File

@@ -0,0 +1,28 @@
Set-Location (Split-Path $MyInvocation.MyCommand.Path -Parent)
git clone https://github.com/SagerNet/v2ray-core.git -b 'v5.0.12' src
if ( -Not $? ) {
exit $lastExitCode
}
Set-Location src
# Download SSR plugin
Invoke-WebRequest -Uri 'https://gist.githubusercontent.com/H1JK/b3165a99b635dcc06101690e4c43b5fd/raw/691b471f3b395a949d03a3d064d93d319d4997b7/ssr.go' -OutFile '.\proxy\shadowsocks\plugin\self\ssr.go'
# Download Simple-Obfs plugin
Invoke-WebRequest -Uri 'https://gist.githubusercontent.com/H1JK/b3165a99b635dcc06101690e4c43b5fd/raw/691b471f3b395a949d03a3d064d93d319d4997b7/obfs.go' -OutFile '.\proxy\shadowsocks\plugin\self\obfs.go'
# Enable ReadV (Use v2fly/v2ray-core's ReadV code)
Remove-Item '.\common\buf\io.go'
Remove-Item '.\common\buf\readv_reader.go'
Invoke-WebRequest -Uri 'https://raw.githubusercontent.com/v2fly/v2ray-core/master/common/buf/io.go' -OutFile '.\common\buf\io.go'
Invoke-WebRequest -Uri 'https://raw.githubusercontent.com/v2fly/v2ray-core/master/common/buf/readv_reader.go' -OutFile '.\common\buf\readv_reader.go'
$Env:CGO_ENABLED='0'
$Env:GOROOT_FINAL='/usr'
$Env:GOOS='windows'
$Env:GOARCH='amd64'
go mod tidy # necessary
go build -a -trimpath -asmflags '-s -w' -ldflags '-s -w -buildid=' -o '..\..\release\v2ray-sn.exe' '.\main'
exit $lastExitCode

View File

@@ -1,15 +0,0 @@
Set-Location (Split-Path $MyInvocation.MyCommand.Path -Parent)
git clone https://github.com/xtls/xray-core -b 'v1.5.6' src
if ( -Not $? ) {
exit $lastExitCode
}
Set-Location src
$Env:CGO_ENABLED='0'
$Env:GOROOT_FINAL='/usr'
$Env:GOOS='windows'
$Env:GOARCH='amd64'
go build -a -trimpath -asmflags '-s -w' -ldflags '-s -w -buildid=' -o '..\..\release\xray.exe' '.\main'
exit $lastExitCode