diff --git a/openclaw/install.sh b/openclaw/install.sh index 5b5d856..86f3145 100644 --- a/openclaw/install.sh +++ b/openclaw/install.sh @@ -161,10 +161,11 @@ configure_openclaw() { cat > "${CONFIG_FILE}" < "${CONFIG_FILE}" </dev/null 2>&1; then + GATEWAY_TOKEN=$(openssl rand -hex 16) + else + GATEWAY_TOKEN=$(date +%s%N | sha256sum | head -c 32) + fi + echo -e "${CYAN}请选择 API 类型:${PLAIN}" echo "1. Anthropic 官方 API" echo "2. OpenAI 兼容 API (中转站/其他模型)" @@ -149,7 +157,11 @@ configure_openclaw() { "gateway": { "mode": "local", "bind": "loopback", - "port": 18789 + "port": 18789, + "auth": { + "mode": "token", + "token": "${GATEWAY_TOKEN}" + } }, "env": { "ANTHROPIC_API_KEY": "${api_key}" @@ -186,7 +198,11 @@ EOF "gateway": { "mode": "local", "bind": "loopback", - "port": 18789 + "port": 18789, + "auth": { + "mode": "token", + "token": "${GATEWAY_TOKEN}" + } }, "env": { "ANTHROPIC_API_KEY": "${api_key}" @@ -222,7 +238,11 @@ EOF "gateway": { "mode": "local", "bind": "loopback", - "port": 18789 + "port": 18789, + "auth": { + "mode": "token", + "token": "${GATEWAY_TOKEN}" + } }, "agents": { "defaults": { @@ -283,7 +303,11 @@ EOF "gateway": { "mode": "local", "bind": "loopback", - "port": 18789 + "port": 18789, + "auth": { + "mode": "token", + "token": "${GATEWAY_TOKEN}" + } }, "agents": { "defaults": { @@ -335,7 +359,9 @@ EOF fi fi log_info "配置文件已生成: ${CONFIG_FILE}" - log_info "配置文件绝对路径: ${CONFIG_FILE}" + echo -e "${GREEN}配置文件绝对路径: ${CONFIG_FILE}${PLAIN}" + echo -e "${GREEN}Gateway Token: ${GATEWAY_TOKEN}${PLAIN}" + echo -e "${YELLOW}请妥善保存此 Token,用于远程连接 Gateway。${PLAIN}" } setup_launchd() { diff --git a/openclaw/installer/installer.exe b/openclaw/installer/installer.exe index dd89ba0..ee3fd93 100644 Binary files a/openclaw/installer/installer.exe and b/openclaw/installer/installer.exe differ diff --git a/openclaw/installer/internal/sys/sys.go b/openclaw/installer/internal/sys/sys.go index 11bda6b..92ff580 100644 --- a/openclaw/installer/internal/sys/sys.go +++ b/openclaw/installer/internal/sys/sys.go @@ -945,10 +945,11 @@ func GenerateAndWriteConfig(opts ConfigOptions) error { config := OpenclawConfig{ Gateway: GatewayConfig{ - Mode: "token", + Mode: "local", Bind: "loopback", Port: 18789, Auth: &AuthConfig{ + Mode: "token", Token: token, }, },