chore(frp): 新增 frpc 隧道安装/启动脚本与配置,忽略本地 frpc.exe 二进制
This commit is contained in:
parent
fa112891a9
commit
a5a6ea4a93
3
.gitignore
vendored
3
.gitignore
vendored
@ -44,3 +44,6 @@ script/debug-*.cjs
|
|||||||
.ssl/
|
.ssl/
|
||||||
nginx_config/
|
nginx_config/
|
||||||
nginx-upstream-local.conf
|
nginx-upstream-local.conf
|
||||||
|
|
||||||
|
# frpc binary (installed on demand by script/frp/frp-install.ps1)
|
||||||
|
script/frp/*.exe
|
||||||
|
|||||||
17
frpc.toml
Normal file
17
frpc.toml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# frpc 客户端配置(frp v0.70.1,复用本机 printServer 的 frpc.exe;生产 frps 为 v0.61.1)
|
||||||
|
# 用途:将本地 WMS 开发服务(http://127.0.0.1:6060)通过生产环境 frps
|
||||||
|
# 暴露为 http://test.wms.o.gztbyc.com(frps subDomainHost=o.gztbyc.com)。
|
||||||
|
# 启动:npm run frpc:start(首次自动从 D:\printServer 复制 frpc.exe 到 script/frp/)
|
||||||
|
|
||||||
|
serverAddr = "112.124.21.102"
|
||||||
|
serverPort = 6005
|
||||||
|
auth.token = "frpPrintToken2024"
|
||||||
|
|
||||||
|
# 测试域名:test_wms.o.gztbyc.com
|
||||||
|
# (subdomain + 生产 frps 的 subDomainHost 泛域名拼接,经 vhostHTTPPort 18080 对外)
|
||||||
|
[[proxies]]
|
||||||
|
name = "wms-test"
|
||||||
|
type = "http"
|
||||||
|
localIP = "127.0.0.1"
|
||||||
|
localPort = 6060
|
||||||
|
subdomain = "test_wms"
|
||||||
@ -43,6 +43,8 @@
|
|||||||
"start": "egg-scripts start ",
|
"start": "egg-scripts start ",
|
||||||
"stop": "node ./app/lib/stop_current_egg.js",
|
"stop": "node ./app/lib/stop_current_egg.js",
|
||||||
"dev": "egg-bin dev --port=6060",
|
"dev": "egg-bin dev --port=6060",
|
||||||
|
"frpc:install": "powershell -ExecutionPolicy Bypass -File ./script/frp/frp-install.ps1",
|
||||||
|
"frpc:start": "powershell -ExecutionPolicy Bypass -File ./script/frp/frp-start.ps1",
|
||||||
"file-writer:pressure": "node ./temp/generated-tests/file-writer-pressure.generated.test.cjs",
|
"file-writer:pressure": "node ./temp/generated-tests/file-writer-pressure.generated.test.cjs",
|
||||||
"debug:webhook:receiver": "node ./script/debug-webhook-receiver.cjs",
|
"debug:webhook:receiver": "node ./script/debug-webhook-receiver.cjs",
|
||||||
"debug:webhook:receiving": "node ./script/debug-send-receiving-webhooks.cjs",
|
"debug:webhook:receiving": "node ./script/debug-send-receiving-webhooks.cjs",
|
||||||
|
|||||||
42
script/frp/frp-install.ps1
Normal file
42
script/frp/frp-install.ps1
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
# Put frpc.exe into script/frp/ (same dir as this script).
|
||||||
|
# Priority: 1) reuse local D:\printServer\frpc\frpc.exe 2) download from GitHub.
|
||||||
|
# ASCII only, avoids ANSI encoding issues with Chinese paths.
|
||||||
|
$ErrorActionPreference = 'Stop'
|
||||||
|
|
||||||
|
$FrpDir = $PSScriptRoot
|
||||||
|
$Exe = Join-Path $FrpDir 'frpc.exe'
|
||||||
|
|
||||||
|
if (Test-Path $Exe) {
|
||||||
|
Write-Output "frpc.exe already exists: $Exe"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
New-Item -ItemType Directory -Force -Path $FrpDir | Out-Null
|
||||||
|
|
||||||
|
# 1) reuse frpc from local printServer project
|
||||||
|
$LocalFrpc = 'D:\printServer\frpc\frpc.exe'
|
||||||
|
if (Test-Path $LocalFrpc) {
|
||||||
|
Copy-Item -Force $LocalFrpc $Exe
|
||||||
|
Write-Output "frpc.exe copied from $LocalFrpc -> $Exe"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# 2) download (fallback)
|
||||||
|
$Version = '0.61.1'
|
||||||
|
$ZipName = "frp_${Version}_windows_amd64.zip"
|
||||||
|
$Url = "https://github.com/fatedier/frp/releases/download/v$Version/$ZipName"
|
||||||
|
$TmpZip = Join-Path $FrpDir $ZipName
|
||||||
|
$ExtractDir = Join-Path $FrpDir "frp_${Version}_windows_amd64"
|
||||||
|
|
||||||
|
Write-Output "Downloading $Url ..."
|
||||||
|
Invoke-WebRequest -Uri $Url -OutFile $TmpZip -UseBasicParsing
|
||||||
|
|
||||||
|
Write-Output "Extracting ..."
|
||||||
|
Add-Type -AssemblyName System.IO.Compression.FileSystem
|
||||||
|
[System.IO.Compression.ZipFile]::ExtractToDirectory($TmpZip, $FrpDir)
|
||||||
|
|
||||||
|
Move-Item -Force (Join-Path $ExtractDir 'frpc.exe') $Exe
|
||||||
|
Remove-Item -Recurse -Force $ExtractDir
|
||||||
|
Remove-Item -Force $TmpZip
|
||||||
|
|
||||||
|
Write-Output "frpc.exe installed: $Exe"
|
||||||
18
script/frp/frp-start.ps1
Normal file
18
script/frp/frp-start.ps1
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# Start frpc with the project frpc.toml (copy frpc.exe first if missing).
|
||||||
|
# ASCII only, avoids ANSI encoding issues with Chinese paths.
|
||||||
|
$ErrorActionPreference = 'Stop'
|
||||||
|
|
||||||
|
$FrpDir = $PSScriptRoot
|
||||||
|
$Exe = Join-Path $FrpDir 'frpc.exe'
|
||||||
|
|
||||||
|
if (-not (Test-Path $Exe)) {
|
||||||
|
Write-Output 'frpc.exe not found, installing ...'
|
||||||
|
& (Join-Path $PSScriptRoot 'frp-install.ps1')
|
||||||
|
}
|
||||||
|
|
||||||
|
$ProjectRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
|
||||||
|
$Config = Join-Path $ProjectRoot 'frpc.toml'
|
||||||
|
$Config = (Resolve-Path $Config).Path
|
||||||
|
|
||||||
|
Write-Output "Starting frpc with config: $Config"
|
||||||
|
& $Exe -c $Config
|
||||||
Loading…
x
Reference in New Issue
Block a user