0%

Clash机场用户无痛转sing-box

Clash最近全系删库或archive,用是还能用,但以后不更新会有安全问题。作为没什么技术的机场用户,目前最好的方式就是转到sing-box啦~这里给出一些简单的配置方法。

注:不支持SSR节点

1. 下载客户端

sing-box releases处下载windows-amd64.zip,解压后把sing-box.exe放到你喜欢的位置,如C:\Program Files\sing-box设置成管理员运行

2. 编写配置

sing-box.exe所在目录新建config.json,写入对应的sing-box配置,详情自己参考文档

如果你有机场的订阅链接(Clash或除了SSR以外的节点订阅),可以通过访问 https://sing-box.ciuzaak.com/config/订阅链接 获得转换后的配置。

请注意,https://sing-box.ciuzaak.com 是我自己搭的,为防止订阅泄露建议自己搭建,参考sing-box-subscribe,部署到vercel,方便快捷。

3. 启动与管理

启动命令是sing-box run,可以用-D指定配置所在目录。启动成功可以看见进程:

然后用 https://yacd.ciuzaak.com 管理和切换节点,同样的,建议自己部署,参照Yacd-meta

其他

为了方便写了一些powershell脚本,把它们放在同一个目录下然后设系统路径,就可以在terminal快速调用啦。里面的订阅链接和文件目录自己改一下。

2023.11.17更新:刷新所有脚本

  • update-sing-box.ps1: 更新客户端
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# PowerShell Script to Download the latest release file 'xxx.zip' from a GitHub repository

# Set your GitHub repository details
$UserOrOrg = "SagerNet" # Replace with the GitHub username or organization
$Repository = "sing-box" # Replace with the GitHub repository name

# GitHub API URL for the latest release
$ApiUrl = "https://api.github.com/repos/$UserOrOrg/$Repository/releases/latest"

# Use Invoke-RestMethod to call the GitHub API
$LatestRelease = Invoke-RestMethod -Uri $ApiUrl
Write-Host "Latest release is $($LatestRelease.tag_name)"

# Ask user whether to continue
$userResponse = Read-Host "Do you want to download and extract this version? (y/n)"
if ($userResponse -ne 'y') {
Write-Host "Operation cancelled by user."
exit
}

# Find the download URL for the specific file
$FileName = "sing-box-$($LatestRelease.tag_name -replace 'v', '')-windows-amd64.zip"
$FileUrl = ($LatestRelease.assets | Where-Object { $_.name -eq $FileName }).browser_download_url

# Check if the file URL was found
if ($FileUrl -eq $null) {
Write-Host "File $FileName not found in the latest release."
exit
}

# Download the file
$OutputPath = ".\$FileName" # Specify the path where the file will be saved
Invoke-WebRequest -Uri $FileUrl -OutFile $OutputPath
Write-Host "Downloaded $FileName to $OutputPath"

# Extract the file
$DestinationFolder = "你放sing-box的地方"
$ExtractPath = ".\$($FileName -replace '.zip', '')"
Expand-Archive -LiteralPath $OutputPath -DestinationPath ".\"

kill-sing-box
Start-Sleep -Milliseconds 1000
# Copy .exe files to the specified destination folder
Copy-Item -Path "$ExtractPath\sing-box.exe" -Destination $DestinationFolder
run-sing-box

# Cleanup: Delete the downloaded .zip and extracted files
Remove-Item -Path $OutputPath
Remove-Item -Path $ExtractPath -Recurse
  • update-subscribe.ps1: 拉取、更新配置文件
1
2
3
4
5
6
7
8
9
$parseUri = "https://sing-box.ciuzaak.com/config" # 可以自己搭,fork https://github.com/Toperlock/sing-box-subscribe 然后用vercel部署
$clashUri = "节点订阅"
$fullUri = "$parseUri/$clashUri"
$destinationDirectory = "你放sing-box的地方"

Invoke-RestMethod -Uri $fullUri -OutFile "$destinationDirectory\config.json"
Write-Host "Downloaded config.json to $destinationDirectory"

run-sing-box
  • run-sing-box.ps1: 启动sing-box
1
2
3
4
5
6
7
kill-sing-box

$destinationDirectory = "你放sing-box的地方"

# 使用 Start-Process 在后台运行 single-box 命令
Start-Process -FilePath "$destinationDirectory\sing-box.exe" -ArgumentList "run", "-D", $destinationDirectory -WindowStyle Hidden
Write-Host "Started sing-box"
  • kill-sing-box.ps1: 结束sing-box
1
2
3
4
5
6
7
8
# 检查 sing-box.exe 进程是否存在
$process = Get-Process sing-box -ErrorAction SilentlyContinue

# 如果进程存在,结束它
if ($process) {
Stop-Process -Name sing-box -Force
Write-Host "Terminated sing-box"
}
  • update-geo-db.ps1: 更新geoip和geosite数据库
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# Define the URLs for the files to download
$geoipUrl = "https://testingcf.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@release/geoip.db"
$geositeUrl = "https://testingcf.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@release/geosite.db"

# Define the destination directory
$destinationDirectory = "你放sing-box的地方"

# Download geoip.db
Invoke-WebRequest -Uri $geoipUrl -OutFile "geoip.db"
# Download geosite.db
Invoke-WebRequest -Uri $geositeUrl -OutFile "geosite.db"

kill-sing-box
Start-Sleep -Milliseconds 1000
Move-Item -Path "geoip.db" -Destination "$destinationDirectory" -Force
Move-Item -Path "geosite.db" -Destination "$destinationDirectory" -Force
run-sing-box