feat: add stable remote support via frp (replaces bore)

- frp server on VPS 101.32.254.221:7000 (auto-start, systemd)
- remote.ps1 (Windows) + remote.sh (Mac/Linux) client scripts
- Auto-reconnect, no rate limits, token-authenticated
- Random port 20000-20099, clear instructions for WeChat sharing
This commit is contained in:
dongsheng123132
2026-03-18 19:15:54 +08:00
parent 165d860383
commit 1ce4cd60ff
2 changed files with 248 additions and 0 deletions

146
website/remote.ps1 Normal file
View File

@@ -0,0 +1,146 @@
# ============================================================
# U-Claw 远程协助 v2Windows— 稳定版
# 用法: irm https://u-claw.org/remote.ps1 | iex
# 通过 frp 连接到 U-Claw 中转服务器,永不断线
# ============================================================
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
try { chcp 65001 | Out-Null } catch {}
Set-ExecutionPolicy Bypass -Scope Process -Force -ErrorAction SilentlyContinue
Clear-Host
Write-Host ""
Write-Host " ==========================================" -ForegroundColor Cyan
Write-Host " U-Claw 远程协助 v2稳定连接" -ForegroundColor Cyan
Write-Host " ==========================================" -ForegroundColor Cyan
Write-Host ""
# ---- Step 1: SSH ----
Write-Host " [1/3] 检查 SSH ..." -ForegroundColor White
$sshd = Get-Service sshd -ErrorAction SilentlyContinue
if (-not $sshd) {
Write-Host " 安装 OpenSSH Server需要几分钟..." -ForegroundColor Yellow
$ErrorActionPreference = "Continue"
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0 2>&1 | Out-Null
$ErrorActionPreference = "Stop"
}
Start-Service sshd -ErrorAction SilentlyContinue
Set-Service -Name sshd -StartupType Automatic -ErrorAction SilentlyContinue
New-NetFirewallRule -Name "OpenSSH-Server" -DisplayName "OpenSSH Server" -Direction Inbound -Protocol TCP -LocalPort 22 -Action Allow -ErrorAction SilentlyContinue 2>&1 | Out-Null
$sshd = Get-Service sshd -ErrorAction SilentlyContinue
if ($sshd -and $sshd.Status -eq 'Running') {
Write-Host " [OK] SSH 已启动" -ForegroundColor Green
} else {
Write-Host " [!] SSH 启动失败,请以管理员身份运行" -ForegroundColor Red
Read-Host " 按回车退出"
exit 1
}
# ---- Step 2: 下载 frpc ----
Write-Host ""
Write-Host " [2/3] 准备远程通道 ..." -ForegroundColor White
$FRP_DIR = "$env:TEMP\uclaw-frp"
$FRPC = "$FRP_DIR\frpc.exe"
if (-not (Test-Path $FRPC)) {
New-Item -ItemType Directory -Force -Path $FRP_DIR | Out-Null
$frpUrl = "https://github.com/fatedier/frp/releases/download/v0.61.1/frp_0.61.1_windows_amd64.zip"
$frpZip = "$FRP_DIR\frp.zip"
# 尝试多个镜像
$mirrors = @(
"https://ghfast.top/$frpUrl",
"https://gh-proxy.com/$frpUrl",
$frpUrl
)
$downloaded = $false
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$ProgressPreference = 'SilentlyContinue'
foreach ($url in $mirrors) {
Write-Host " 下载: $url" -ForegroundColor DarkGray
try {
Invoke-WebRequest -Uri $url -OutFile $frpZip -UseBasicParsing -TimeoutSec 60
if ((Get-Item $frpZip).Length -gt 1MB) { $downloaded = $true; break }
} catch {
Write-Host " 失败,换下一个..." -ForegroundColor DarkGray
}
}
if (-not $downloaded) {
try { & curl.exe -sL $mirrors[0] -o $frpZip; if ((Get-Item $frpZip).Length -gt 1MB) { $downloaded = $true } } catch {}
}
if (-not $downloaded) {
Write-Host " [!] 下载失败" -ForegroundColor Red
Read-Host " 按回车退出"
exit 1
}
Expand-Archive $frpZip $FRP_DIR -Force
$frpcFound = Get-ChildItem -Recurse $FRP_DIR -Filter "frpc.exe" | Select-Object -First 1
if ($frpcFound) { Copy-Item $frpcFound.FullName $FRPC -Force }
Remove-Item $frpZip -Force -ErrorAction SilentlyContinue
}
if (-not (Test-Path $FRPC)) {
Write-Host " [!] frpc 下载失败" -ForegroundColor Red
Read-Host " 按回车退出"
exit 1
}
Write-Host " [OK] 远程通道工具就绪" -ForegroundColor Green
# ---- Step 3: 连接 ----
Write-Host ""
Write-Host " [3/3] 建立连接 ..." -ForegroundColor White
# 随机端口 20000-20099
$PORT = Get-Random -Minimum 20000 -Maximum 20100
$USERNAME = $env:USERNAME
$COMPUTER = $env:COMPUTERNAME
# 写 frpc 配置
$frpcConfig = @"
serverAddr = "101.32.254.221"
serverPort = 7000
auth.method = "token"
auth.token = "uclaw-remote-2026"
[[proxies]]
name = "ssh-$USERNAME-$PORT"
type = "tcp"
localIP = "127.0.0.1"
localPort = 22
remotePort = $PORT
"@
$configPath = "$FRP_DIR\frpc.toml"
[IO.File]::WriteAllText($configPath, $frpcConfig, (New-Object System.Text.UTF8Encoding $false))
Write-Host ""
Write-Host " ==========================================" -ForegroundColor Green
Write-Host " 远程协助已就绪!" -ForegroundColor Green
Write-Host " ==========================================" -ForegroundColor Green
Write-Host ""
Write-Host " +------------------------------------------+" -ForegroundColor Yellow
Write-Host " | 把下面这段发给技术支持(微信): |" -ForegroundColor Yellow
Write-Host " | |" -ForegroundColor Yellow
Write-Host " | 端口: $PORT" -ForegroundColor Cyan -NoNewline
Write-Host "$(' ' * (33 - $PORT.ToString().Length))|" -ForegroundColor Yellow
Write-Host " | 用户: $USERNAME" -ForegroundColor Cyan -NoNewline
Write-Host "$(' ' * (33 - $USERNAME.Length))|" -ForegroundColor Yellow
Write-Host " | 电脑: $COMPUTER" -ForegroundColor Cyan -NoNewline
Write-Host "$(' ' * (33 - $COMPUTER.Length))|" -ForegroundColor Yellow
Write-Host " | |" -ForegroundColor Yellow
Write-Host " +------------------------------------------+" -ForegroundColor Yellow
Write-Host ""
Write-Host " * 连接稳定,断线自动重连" -ForegroundColor DarkGray
Write-Host " * 关闭此窗口即断开远程" -ForegroundColor DarkGray
Write-Host " * 你的登录密码需要告知技术支持" -ForegroundColor DarkGray
Write-Host ""
# 启动 frpc阻塞自动重连
& $FRPC -c $configPath

102
website/remote.sh Normal file
View File

@@ -0,0 +1,102 @@
#!/bin/bash
# ============================================================
# U-Claw 远程协助 v2Mac/Linux— 稳定版
# 用法: curl -fsSL https://u-claw.org/remote.sh | bash
# ============================================================
set -e
GREEN='\033[0;32m'; CYAN='\033[0;36m'; RED='\033[0;31m'; YELLOW='\033[1;33m'; DIM='\033[2m'; NC='\033[0m'
clear
echo ""
echo -e "${CYAN} ===========================================${NC}"
echo -e "${CYAN} U-Claw 远程协助 v2稳定连接${NC}"
echo -e "${CYAN} ===========================================${NC}"
echo ""
# ---- Step 1: SSH ----
echo -e " [1/3] 检查 SSH ..."
if [[ "$(uname)" == "Darwin" ]]; then
sudo systemsetup -setremotelogin on 2>/dev/null || true
else
sudo systemctl start sshd 2>/dev/null || sudo systemctl start ssh 2>/dev/null || {
sudo apt-get install -y openssh-server 2>/dev/null || sudo yum install -y openssh-server 2>/dev/null
sudo systemctl start sshd 2>/dev/null || sudo systemctl start ssh
}
fi
echo -e "${GREEN} [OK] SSH 已启动${NC}"
# ---- Step 2: frpc ----
echo ""
echo -e " [2/3] 准备远程通道 ..."
FRP_DIR="/tmp/uclaw-frp"
mkdir -p "$FRP_DIR"
FRPC="$FRP_DIR/frpc"
if [ ! -f "$FRPC" ]; then
ARCH=$(uname -m)
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
if [[ "$OS" == "darwin" ]]; then
if [[ "$ARCH" == "arm64" ]]; then
FRP_URL="https://github.com/fatedier/frp/releases/download/v0.61.1/frp_0.61.1_darwin_arm64.tar.gz"
else
FRP_URL="https://github.com/fatedier/frp/releases/download/v0.61.1/frp_0.61.1_darwin_amd64.tar.gz"
fi
else
FRP_URL="https://github.com/fatedier/frp/releases/download/v0.61.1/frp_0.61.1_linux_amd64.tar.gz"
fi
echo -e "${DIM} 下载: $FRP_URL${NC}"
curl -sL "https://ghfast.top/$FRP_URL" -o "$FRP_DIR/frp.tar.gz" 2>/dev/null || \
curl -sL "$FRP_URL" -o "$FRP_DIR/frp.tar.gz"
tar xzf "$FRP_DIR/frp.tar.gz" -C "$FRP_DIR" --strip-components=1
rm -f "$FRP_DIR/frp.tar.gz"
fi
chmod +x "$FRPC"
echo -e "${GREEN} [OK] 远程通道工具就绪${NC}"
# ---- Step 3: 连接 ----
echo ""
echo -e " [3/3] 建立连接 ..."
PORT=$((20000 + RANDOM % 100))
USERNAME=$(whoami)
HOSTNAME_VAL=$(hostname)
cat > "$FRP_DIR/frpc.toml" << EOF
serverAddr = "101.32.254.221"
serverPort = 7000
auth.method = "token"
auth.token = "uclaw-remote-2026"
[[proxies]]
name = "ssh-${USERNAME}-${PORT}"
type = "tcp"
localIP = "127.0.0.1"
localPort = 22
remotePort = ${PORT}
EOF
echo ""
echo -e "${GREEN} ===========================================${NC}"
echo -e "${GREEN} 远程协助已就绪!${NC}"
echo -e "${GREEN} ===========================================${NC}"
echo ""
echo -e "${YELLOW} +------------------------------------------+"
echo -e " | 把下面这段发给技术支持(微信): |"
echo -e " | |"
echo -e " | ${CYAN}端口: ${PORT}${YELLOW} |"
echo -e " | ${CYAN}用户: ${USERNAME}${YELLOW} |"
echo -e " | ${CYAN}电脑: ${HOSTNAME_VAL}${YELLOW} |"
echo -e " | |"
echo -e " +------------------------------------------+${NC}"
echo ""
echo -e "${DIM} * 连接稳定,断线自动重连${NC}"
echo -e "${DIM} * 按 Ctrl+C 断开远程${NC}"
echo -e "${DIM} * 你的登录密码需要告知技术支持${NC}"
echo ""
# 启动 frpc
"$FRPC" -c "$FRP_DIR/frpc.toml"