Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b7a1a249a4 | |||
| 5cee8daabc | |||
|
|
a9ca714b24 | ||
|
|
d6627a292d | ||
| e0d88e9ad7 |
5
go.mod
5
go.mod
@@ -27,6 +27,7 @@ require (
|
|||||||
github.com/dlclark/regexp2 v1.11.4 // indirect
|
github.com/dlclark/regexp2 v1.11.4 // indirect
|
||||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||||
github.com/gabriel-vasile/mimetype v1.4.12 // indirect
|
github.com/gabriel-vasile/mimetype v1.4.12 // indirect
|
||||||
|
github.com/gen2brain/shm v0.1.0 // indirect
|
||||||
github.com/gin-contrib/sse v1.1.0 // indirect
|
github.com/gin-contrib/sse v1.1.0 // indirect
|
||||||
github.com/go-ole/go-ole v1.2.6 // indirect
|
github.com/go-ole/go-ole v1.2.6 // indirect
|
||||||
github.com/go-openapi/jsonpointer v0.22.4 // indirect
|
github.com/go-openapi/jsonpointer v0.22.4 // indirect
|
||||||
@@ -44,12 +45,16 @@ require (
|
|||||||
github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect
|
github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect
|
||||||
github.com/goccy/go-json v0.10.5 // indirect
|
github.com/goccy/go-json v0.10.5 // indirect
|
||||||
github.com/goccy/go-yaml v1.19.1 // indirect
|
github.com/goccy/go-yaml v1.19.1 // indirect
|
||||||
|
github.com/godbus/dbus/v5 v5.1.0 // indirect
|
||||||
github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e // indirect
|
github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e // indirect
|
||||||
|
github.com/jezek/xgb v1.1.1 // indirect
|
||||||
github.com/json-iterator/go v1.1.12 // indirect
|
github.com/json-iterator/go v1.1.12 // indirect
|
||||||
|
github.com/kbinani/screenshot v0.0.0-20250624051815-089614a94018 // indirect
|
||||||
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
|
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
|
||||||
github.com/kr/text v0.2.0 // indirect
|
github.com/kr/text v0.2.0 // indirect
|
||||||
github.com/leodido/go-urn v1.4.0 // indirect
|
github.com/leodido/go-urn v1.4.0 // indirect
|
||||||
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
|
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
|
||||||
|
github.com/lxn/win v0.0.0-20210218163916-a377121e959e // indirect
|
||||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||||
|
|||||||
11
go.sum
11
go.sum
@@ -22,6 +22,8 @@ github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkp
|
|||||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||||
github.com/gabriel-vasile/mimetype v1.4.12 h1:e9hWvmLYvtp846tLHam2o++qitpguFiYCKbn0w9jyqw=
|
github.com/gabriel-vasile/mimetype v1.4.12 h1:e9hWvmLYvtp846tLHam2o++qitpguFiYCKbn0w9jyqw=
|
||||||
github.com/gabriel-vasile/mimetype v1.4.12/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=
|
github.com/gabriel-vasile/mimetype v1.4.12/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=
|
||||||
|
github.com/gen2brain/shm v0.1.0 h1:MwPeg+zJQXN0RM9o+HqaSFypNoNEcNpeoGp0BTSx2YY=
|
||||||
|
github.com/gen2brain/shm v0.1.0/go.mod h1:UgIcVtvmOu+aCJpqJX7GOtiN7X2ct+TKLg4RTxwPIUA=
|
||||||
github.com/gin-contrib/gzip v0.0.6 h1:NjcunTcGAj5CO1gn4N8jHOSIeRFHIbn51z6K+xaN4d4=
|
github.com/gin-contrib/gzip v0.0.6 h1:NjcunTcGAj5CO1gn4N8jHOSIeRFHIbn51z6K+xaN4d4=
|
||||||
github.com/gin-contrib/gzip v0.0.6/go.mod h1:QOJlmV2xmayAjkNS2Y8NQsMneuRShOU/kjovCXNuzzk=
|
github.com/gin-contrib/gzip v0.0.6/go.mod h1:QOJlmV2xmayAjkNS2Y8NQsMneuRShOU/kjovCXNuzzk=
|
||||||
github.com/gin-contrib/sse v1.1.0 h1:n0w2GMuUpWDVp7qSpvze6fAu9iRxJY4Hmj6AmBOU05w=
|
github.com/gin-contrib/sse v1.1.0 h1:n0w2GMuUpWDVp7qSpvze6fAu9iRxJY4Hmj6AmBOU05w=
|
||||||
@@ -71,6 +73,8 @@ github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
|
|||||||
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
||||||
github.com/goccy/go-yaml v1.19.1 h1:3rG3+v8pkhRqoQ/88NYNMHYVGYztCOCIZ7UQhu7H+NE=
|
github.com/goccy/go-yaml v1.19.1 h1:3rG3+v8pkhRqoQ/88NYNMHYVGYztCOCIZ7UQhu7H+NE=
|
||||||
github.com/goccy/go-yaml v1.19.1/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
|
github.com/goccy/go-yaml v1.19.1/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
|
||||||
|
github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
|
||||||
|
github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||||
github.com/golang-jwt/jwt/v5 v5.3.0 h1:pv4AsKCKKZuqlgs5sUmn4x8UlGa0kEVt/puTpKx9vvo=
|
github.com/golang-jwt/jwt/v5 v5.3.0 h1:pv4AsKCKKZuqlgs5sUmn4x8UlGa0kEVt/puTpKx9vvo=
|
||||||
github.com/golang-jwt/jwt/v5 v5.3.0/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE=
|
github.com/golang-jwt/jwt/v5 v5.3.0/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE=
|
||||||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
@@ -85,8 +89,12 @@ github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aN
|
|||||||
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||||
github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE=
|
github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE=
|
||||||
github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ=
|
github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ=
|
||||||
|
github.com/jezek/xgb v1.1.1 h1:bE/r8ZZtSv7l9gk6nU0mYx51aXrvnyb44892TwSaqS4=
|
||||||
|
github.com/jezek/xgb v1.1.1/go.mod h1:nrhwO0FX/enq75I7Y7G8iN1ubpSGZEiA3v9e9GyRFlk=
|
||||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||||
|
github.com/kbinani/screenshot v0.0.0-20250624051815-089614a94018 h1:NQYgMY188uWrS+E/7xMVpydsI48PMHcc7SfR4OxkDF4=
|
||||||
|
github.com/kbinani/screenshot v0.0.0-20250624051815-089614a94018/go.mod h1:Pmpz2BLf55auQZ67u3rvyI2vAQvNetkK/4zYUmpauZQ=
|
||||||
github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=
|
github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=
|
||||||
github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
|
github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
|
||||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||||
@@ -97,6 +105,8 @@ github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
|
|||||||
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
||||||
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4=
|
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4=
|
||||||
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I=
|
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I=
|
||||||
|
github.com/lxn/win v0.0.0-20210218163916-a377121e959e h1:H+t6A/QJMbhCSEH5rAuRxh+CtW96g0Or0Fxa9IKr4uc=
|
||||||
|
github.com/lxn/win v0.0.0-20210218163916-a377121e959e/go.mod h1:KxxjdtRkfNoYDCUP5ryK7XJJNTnpC8atvtmTheChOtk=
|
||||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
@@ -181,6 +191,7 @@ golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
|
|||||||
golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
|
golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20201018230417-eeed37f84f13/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package tunnel
|
package tunnel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
@@ -286,6 +288,10 @@ func (c *Client) handleStream(stream net.Conn) {
|
|||||||
c.handlePluginAPIRequest(stream, msg)
|
c.handlePluginAPIRequest(stream, msg)
|
||||||
case protocol.MsgTypeSystemStatsRequest:
|
case protocol.MsgTypeSystemStatsRequest:
|
||||||
c.handleSystemStatsRequest(stream, msg)
|
c.handleSystemStatsRequest(stream, msg)
|
||||||
|
case protocol.MsgTypeScreenshotRequest:
|
||||||
|
c.handleScreenshotRequest(stream, msg)
|
||||||
|
case protocol.MsgTypeShellExecuteRequest:
|
||||||
|
c.handleShellExecuteRequest(stream, msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -910,10 +916,24 @@ func (c *Client) performSelfUpdate(downloadURL string) error {
|
|||||||
currentPath, _ = filepath.EvalSymlinks(currentPath)
|
currentPath, _ = filepath.EvalSymlinks(currentPath)
|
||||||
|
|
||||||
// 预检查:验证是否有写权限(在下载前检查,避免浪费带宽)
|
// 预检查:验证是否有写权限(在下载前检查,避免浪费带宽)
|
||||||
|
// Windows 跳过预检查,因为 Windows 更新通过 batch 脚本以提升权限执行
|
||||||
|
// 非 Windows:原始路径 → DataDir → 临时目录,逐级回退
|
||||||
|
fallbackDir := ""
|
||||||
|
if runtime.GOOS != "windows" {
|
||||||
if err := c.checkUpdatePermissions(currentPath); err != nil {
|
if err := c.checkUpdatePermissions(currentPath); err != nil {
|
||||||
c.logErrorf("Update failed: %v", err)
|
// 尝试 DataDir
|
||||||
c.logErrorf("Self-update is not supported in this environment. Please update manually.")
|
fallbackDir = c.DataDir
|
||||||
return err
|
testFile := filepath.Join(fallbackDir, ".gotunnel_update_test")
|
||||||
|
if f, err := os.Create(testFile); err != nil {
|
||||||
|
// DataDir 也不可写,回退到临时目录
|
||||||
|
fallbackDir = os.TempDir()
|
||||||
|
c.logf("DataDir not writable, falling back to temp directory: %s", fallbackDir)
|
||||||
|
} else {
|
||||||
|
f.Close()
|
||||||
|
os.Remove(testFile)
|
||||||
|
c.logf("Original path not writable, falling back to data directory: %s", fallbackDir)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 使用共享的下载和解压逻辑
|
// 使用共享的下载和解压逻辑
|
||||||
@@ -930,21 +950,26 @@ func (c *Client) performSelfUpdate(downloadURL string) error {
|
|||||||
return performWindowsClientUpdate(binaryPath, currentPath, c.ServerAddr, c.Token, c.ID)
|
return performWindowsClientUpdate(binaryPath, currentPath, c.ServerAddr, c.Token, c.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Linux/Mac/Android: 直接替换
|
// 确定目标路径
|
||||||
backupPath := currentPath + ".bak"
|
targetPath := currentPath
|
||||||
|
if fallbackDir != "" {
|
||||||
|
targetPath = filepath.Join(fallbackDir, filepath.Base(currentPath))
|
||||||
|
c.logf("Will install to fallback path: %s", targetPath)
|
||||||
|
}
|
||||||
|
|
||||||
// 停止所有插件
|
// 停止所有插件
|
||||||
c.stopAllPlugins()
|
c.stopAllPlugins()
|
||||||
|
|
||||||
// 备份当前文件
|
if fallbackDir == "" {
|
||||||
|
// 原地替换:备份 → 复制 → 清理
|
||||||
|
backupPath := currentPath + ".bak"
|
||||||
|
|
||||||
c.logf("Backing up current binary...")
|
c.logf("Backing up current binary...")
|
||||||
if err := os.Rename(currentPath, backupPath); err != nil {
|
if err := os.Rename(currentPath, backupPath); err != nil {
|
||||||
c.logErrorf("Update failed: cannot backup current binary: %v", err)
|
c.logErrorf("Update failed: cannot backup current binary: %v", err)
|
||||||
c.logErrorf("This may be due to insufficient permissions or read-only filesystem.")
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// 复制新文件(不能用 rename,可能跨文件系统)
|
|
||||||
c.logf("Installing new binary...")
|
c.logf("Installing new binary...")
|
||||||
if err := update.CopyFile(binaryPath, currentPath); err != nil {
|
if err := update.CopyFile(binaryPath, currentPath); err != nil {
|
||||||
os.Rename(backupPath, currentPath)
|
os.Rename(backupPath, currentPath)
|
||||||
@@ -952,20 +977,31 @@ func (c *Client) performSelfUpdate(downloadURL string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置执行权限
|
|
||||||
if err := os.Chmod(currentPath, 0755); err != nil {
|
if err := os.Chmod(currentPath, 0755); err != nil {
|
||||||
os.Rename(backupPath, currentPath)
|
os.Rename(backupPath, currentPath)
|
||||||
c.logErrorf("Update failed: cannot set execute permission: %v", err)
|
c.logErrorf("Update failed: cannot set execute permission: %v", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除备份
|
|
||||||
os.Remove(backupPath)
|
os.Remove(backupPath)
|
||||||
|
} else {
|
||||||
|
// 回退路径:直接复制到回退目录
|
||||||
|
c.logf("Installing new binary to data directory...")
|
||||||
|
if err := update.CopyFile(binaryPath, targetPath); err != nil {
|
||||||
|
c.logErrorf("Update failed: cannot install new binary: %v", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := os.Chmod(targetPath, 0755); err != nil {
|
||||||
|
c.logErrorf("Update failed: cannot set execute permission: %v", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
c.logf("Update completed successfully, restarting...")
|
c.logf("Update completed successfully, restarting...")
|
||||||
|
|
||||||
// 重启进程
|
// 重启进程(从新路径启动)
|
||||||
restartClientProcess(currentPath, c.ServerAddr, c.Token, c.ID)
|
restartClientProcess(targetPath, c.ServerAddr, c.Token, c.ID)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1014,6 +1050,12 @@ func performWindowsClientUpdate(newFile, currentPath, serverAddr, token, id stri
|
|||||||
}
|
}
|
||||||
|
|
||||||
batchScript := fmt.Sprintf(`@echo off
|
batchScript := fmt.Sprintf(`@echo off
|
||||||
|
:: Check for admin rights, request UAC elevation if needed
|
||||||
|
net session >nul 2>&1
|
||||||
|
if %%errorlevel%% neq 0 (
|
||||||
|
powershell -Command "Start-Process cmd -ArgumentList '/C \\"\"%%~f0\"\"' -Verb RunAs"
|
||||||
|
exit /b
|
||||||
|
)
|
||||||
ping 127.0.0.1 -n 2 > nul
|
ping 127.0.0.1 -n 2 > nul
|
||||||
del "%s"
|
del "%s"
|
||||||
move "%s" "%s"
|
move "%s" "%s"
|
||||||
@@ -1244,3 +1286,104 @@ func (c *Client) handleSystemStatsRequest(stream net.Conn, msg *protocol.Message
|
|||||||
respMsg, _ := protocol.NewMessage(protocol.MsgTypeSystemStatsResponse, resp)
|
respMsg, _ := protocol.NewMessage(protocol.MsgTypeSystemStatsResponse, resp)
|
||||||
protocol.WriteMessage(stream, respMsg)
|
protocol.WriteMessage(stream, respMsg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handleScreenshotRequest 处理截图请求
|
||||||
|
func (c *Client) handleScreenshotRequest(stream net.Conn, msg *protocol.Message) {
|
||||||
|
defer stream.Close()
|
||||||
|
|
||||||
|
var req protocol.ScreenshotRequest
|
||||||
|
msg.ParsePayload(&req)
|
||||||
|
|
||||||
|
// 捕获截图
|
||||||
|
data, width, height, err := utils.CaptureScreenshot(req.Quality)
|
||||||
|
if err != nil {
|
||||||
|
c.logErrorf("Screenshot capture failed: %v", err)
|
||||||
|
resp := protocol.ScreenshotResponse{Error: err.Error()}
|
||||||
|
respMsg, _ := protocol.NewMessage(protocol.MsgTypeScreenshotResponse, resp)
|
||||||
|
protocol.WriteMessage(stream, respMsg)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 编码为 Base64
|
||||||
|
base64Data := base64.StdEncoding.EncodeToString(data)
|
||||||
|
|
||||||
|
resp := protocol.ScreenshotResponse{
|
||||||
|
Data: base64Data,
|
||||||
|
Width: width,
|
||||||
|
Height: height,
|
||||||
|
Timestamp: time.Now().UnixMilli(),
|
||||||
|
}
|
||||||
|
|
||||||
|
respMsg, _ := protocol.NewMessage(protocol.MsgTypeScreenshotResponse, resp)
|
||||||
|
protocol.WriteMessage(stream, respMsg)
|
||||||
|
}
|
||||||
|
|
||||||
|
// handleShellExecuteRequest 处理 Shell 执行请求
|
||||||
|
func (c *Client) handleShellExecuteRequest(stream net.Conn, msg *protocol.Message) {
|
||||||
|
defer stream.Close()
|
||||||
|
|
||||||
|
var req protocol.ShellExecuteRequest
|
||||||
|
if err := msg.ParsePayload(&req); err != nil {
|
||||||
|
resp := protocol.ShellExecuteResponse{Error: err.Error(), ExitCode: -1}
|
||||||
|
respMsg, _ := protocol.NewMessage(protocol.MsgTypeShellExecuteResponse, resp)
|
||||||
|
protocol.WriteMessage(stream, respMsg)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置默认超时
|
||||||
|
timeout := req.Timeout
|
||||||
|
if timeout <= 0 {
|
||||||
|
timeout = 30
|
||||||
|
}
|
||||||
|
|
||||||
|
c.logf("Executing shell command: %s", req.Command)
|
||||||
|
|
||||||
|
// 根据操作系统选择 shell
|
||||||
|
var cmd *exec.Cmd
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
cmd = exec.Command("cmd", "/C", req.Command)
|
||||||
|
} else {
|
||||||
|
cmd = exec.Command("sh", "-c", req.Command)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置超时上下文
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(timeout)*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
cmd = exec.CommandContext(ctx, cmd.Path, cmd.Args[1:]...)
|
||||||
|
|
||||||
|
// 执行命令并获取输出
|
||||||
|
output, err := cmd.CombinedOutput()
|
||||||
|
|
||||||
|
exitCode := 0
|
||||||
|
if err != nil {
|
||||||
|
if exitErr, ok := err.(*exec.ExitError); ok {
|
||||||
|
exitCode = exitErr.ExitCode()
|
||||||
|
} else if ctx.Err() == context.DeadlineExceeded {
|
||||||
|
resp := protocol.ShellExecuteResponse{
|
||||||
|
Output: string(output),
|
||||||
|
ExitCode: -1,
|
||||||
|
Error: "command timeout",
|
||||||
|
}
|
||||||
|
respMsg, _ := protocol.NewMessage(protocol.MsgTypeShellExecuteResponse, resp)
|
||||||
|
protocol.WriteMessage(stream, respMsg)
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
resp := protocol.ShellExecuteResponse{
|
||||||
|
Output: string(output),
|
||||||
|
ExitCode: -1,
|
||||||
|
Error: err.Error(),
|
||||||
|
}
|
||||||
|
respMsg, _ := protocol.NewMessage(protocol.MsgTypeShellExecuteResponse, resp)
|
||||||
|
protocol.WriteMessage(stream, respMsg)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resp := protocol.ShellExecuteResponse{
|
||||||
|
Output: string(output),
|
||||||
|
ExitCode: exitCode,
|
||||||
|
}
|
||||||
|
|
||||||
|
respMsg, _ := protocol.NewMessage(protocol.MsgTypeShellExecuteResponse, resp)
|
||||||
|
protocol.WriteMessage(stream, respMsg)
|
||||||
|
}
|
||||||
|
|||||||
@@ -466,6 +466,47 @@ func (h *ClientHandler) GetSystemStats(c *gin.Context) {
|
|||||||
Success(c, stats)
|
Success(c, stats)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetScreenshot 获取客户端截图
|
||||||
|
func (h *ClientHandler) GetScreenshot(c *gin.Context) {
|
||||||
|
clientID := c.Param("id")
|
||||||
|
quality := 0
|
||||||
|
if q, ok := c.GetQuery("quality"); ok {
|
||||||
|
fmt.Sscanf(q, "%d", &quality)
|
||||||
|
}
|
||||||
|
|
||||||
|
screenshot, err := h.app.GetServer().GetClientScreenshot(clientID, quality)
|
||||||
|
if err != nil {
|
||||||
|
InternalError(c, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
Success(c, screenshot)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecuteShellRequest Shell 执行请求体
|
||||||
|
type ExecuteShellRequest struct {
|
||||||
|
Command string `json:"command" binding:"required"`
|
||||||
|
Timeout int `json:"timeout"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecuteShell 执行 Shell 命令
|
||||||
|
func (h *ClientHandler) ExecuteShell(c *gin.Context) {
|
||||||
|
clientID := c.Param("id")
|
||||||
|
var req ExecuteShellRequest
|
||||||
|
if err := c.ShouldBindJSON(&req); err != nil {
|
||||||
|
BadRequest(c, "Invalid request: "+err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := h.app.GetServer().ExecuteClientShell(clientID, req.Command, req.Timeout)
|
||||||
|
if err != nil {
|
||||||
|
InternalError(c, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
Success(c, result)
|
||||||
|
}
|
||||||
|
|
||||||
// validateClientID 验证客户端 ID 格式
|
// validateClientID 验证客户端 ID 格式
|
||||||
func validateClientID(id string) bool {
|
func validateClientID(id string) bool {
|
||||||
if len(id) < 1 || len(id) > 64 {
|
if len(id) < 1 || len(id) > 64 {
|
||||||
|
|||||||
@@ -165,6 +165,12 @@ func performSelfUpdate(downloadURL string, restart bool) error {
|
|||||||
// performWindowsUpdate Windows 平台更新
|
// performWindowsUpdate Windows 平台更新
|
||||||
func performWindowsUpdate(newFile, currentPath string, restart bool) error {
|
func performWindowsUpdate(newFile, currentPath string, restart bool) error {
|
||||||
batchScript := fmt.Sprintf(`@echo off
|
batchScript := fmt.Sprintf(`@echo off
|
||||||
|
:: Check for admin rights, request UAC elevation if needed
|
||||||
|
net session >nul 2>&1
|
||||||
|
if %%errorlevel%% neq 0 (
|
||||||
|
powershell -Command "Start-Process cmd -ArgumentList '/C \\"\"%%~f0\"\"' -Verb RunAs"
|
||||||
|
exit /b
|
||||||
|
)
|
||||||
ping 127.0.0.1 -n 2 > nul
|
ping 127.0.0.1 -n 2 > nul
|
||||||
del "%s"
|
del "%s"
|
||||||
move "%s" "%s"
|
move "%s" "%s"
|
||||||
|
|||||||
@@ -61,7 +61,12 @@ type ServerInterface interface {
|
|||||||
// 插件 API 代理
|
// 插件 API 代理
|
||||||
ProxyPluginAPIRequest(clientID string, req protocol.PluginAPIRequest) (*protocol.PluginAPIResponse, error)
|
ProxyPluginAPIRequest(clientID string, req protocol.PluginAPIRequest) (*protocol.PluginAPIResponse, error)
|
||||||
// 系统状态
|
// 系统状态
|
||||||
|
// 系统状态
|
||||||
GetClientSystemStats(clientID string) (*protocol.SystemStatsResponse, error)
|
GetClientSystemStats(clientID string) (*protocol.SystemStatsResponse, error)
|
||||||
|
// 截图
|
||||||
|
GetClientScreenshot(clientID string, quality int) (*protocol.ScreenshotResponse, error)
|
||||||
|
// Shell 执行
|
||||||
|
ExecuteClientShell(clientID, command string, timeout int) (*protocol.ShellExecuteResponse, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ConfigField 配置字段
|
// ConfigField 配置字段
|
||||||
|
|||||||
@@ -70,6 +70,8 @@ func (r *GinRouter) SetupRoutes(app handler.AppInterface, jwtAuth *auth.JWTAuth,
|
|||||||
api.POST("/client/:id/install-plugins", clientHandler.InstallPlugins)
|
api.POST("/client/:id/install-plugins", clientHandler.InstallPlugins)
|
||||||
api.POST("/client/:id/plugin/:pluginID/:action", clientHandler.PluginAction)
|
api.POST("/client/:id/plugin/:pluginID/:action", clientHandler.PluginAction)
|
||||||
api.GET("/client/:id/system-stats", clientHandler.GetSystemStats)
|
api.GET("/client/:id/system-stats", clientHandler.GetSystemStats)
|
||||||
|
api.GET("/client/:id/screenshot", clientHandler.GetScreenshot)
|
||||||
|
api.POST("/client/:id/shell", clientHandler.ExecuteShell)
|
||||||
|
|
||||||
// 配置管理
|
// 配置管理
|
||||||
configHandler := handler.NewConfigHandler(app)
|
configHandler := handler.NewConfigHandler(app)
|
||||||
|
|||||||
@@ -514,8 +514,8 @@ func (s *Server) acceptProxyConns(cs *ClientSession, ln net.Listener, rule proto
|
|||||||
func (s *Server) acceptProxyServerConns(cs *ClientSession, ln net.Listener, rule protocol.ProxyRule) {
|
func (s *Server) acceptProxyServerConns(cs *ClientSession, ln net.Listener, rule protocol.ProxyRule) {
|
||||||
dialer := proxy.NewTunnelDialer(cs.Session)
|
dialer := proxy.NewTunnelDialer(cs.Session)
|
||||||
|
|
||||||
// 使用内置 proxy 实现
|
// 使用内置 proxy 实现 (带流量统计)
|
||||||
proxyServer := proxy.NewServer(rule.Type, dialer)
|
proxyServer := proxy.NewServer(rule.Type, dialer, s.recordTraffic)
|
||||||
for {
|
for {
|
||||||
conn, err := ln.Accept()
|
conn, err := ln.Accept()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -963,6 +963,9 @@ func (s *Server) sendUDPPacket(cs *ClientSession, conn *net.UDPConn, clientAddr
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 记录入站流量 (从外部接收的数据)
|
||||||
|
s.recordTraffic(int64(len(packet.Data)), 0)
|
||||||
|
|
||||||
// 等待客户端响应
|
// 等待客户端响应
|
||||||
respMsg, err := protocol.ReadMessage(stream)
|
respMsg, err := protocol.ReadMessage(stream)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -975,6 +978,8 @@ func (s *Server) sendUDPPacket(cs *ClientSession, conn *net.UDPConn, clientAddr
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
conn.WriteToUDP(respPacket.Data, clientAddr)
|
conn.WriteToUDP(respPacket.Data, clientAddr)
|
||||||
|
// 记录出站流量 (发送回外部的数据)
|
||||||
|
s.recordTraffic(0, int64(len(respPacket.Data)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1970,3 +1975,101 @@ func (s *Server) GetClientSystemStats(clientID string) (*protocol.SystemStatsRes
|
|||||||
|
|
||||||
return &stats, nil
|
return &stats, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetClientScreenshot 获取客户端截图
|
||||||
|
func (s *Server) GetClientScreenshot(clientID string, quality int) (*protocol.ScreenshotResponse, error) {
|
||||||
|
s.mu.RLock()
|
||||||
|
cs, ok := s.clients[clientID]
|
||||||
|
s.mu.RUnlock()
|
||||||
|
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("client %s not online", clientID)
|
||||||
|
}
|
||||||
|
|
||||||
|
stream, err := cs.Session.Open()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer stream.Close()
|
||||||
|
|
||||||
|
// 设置超时
|
||||||
|
stream.SetDeadline(time.Now().Add(15 * time.Second))
|
||||||
|
|
||||||
|
// 发送请求
|
||||||
|
req := protocol.ScreenshotRequest{Quality: quality}
|
||||||
|
msg, _ := protocol.NewMessage(protocol.MsgTypeScreenshotRequest, req)
|
||||||
|
if err := protocol.WriteMessage(stream, msg); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 读取响应
|
||||||
|
resp, err := protocol.ReadMessage(stream)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.Type != protocol.MsgTypeScreenshotResponse {
|
||||||
|
return nil, fmt.Errorf("unexpected response type: %d", resp.Type)
|
||||||
|
}
|
||||||
|
|
||||||
|
var screenshot protocol.ScreenshotResponse
|
||||||
|
if err := resp.ParsePayload(&screenshot); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if screenshot.Error != "" {
|
||||||
|
return nil, fmt.Errorf("screenshot failed: %s", screenshot.Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &screenshot, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecuteClientShell 执行客户端 Shell 命令
|
||||||
|
func (s *Server) ExecuteClientShell(clientID, command string, timeout int) (*protocol.ShellExecuteResponse, error) {
|
||||||
|
s.mu.RLock()
|
||||||
|
cs, ok := s.clients[clientID]
|
||||||
|
s.mu.RUnlock()
|
||||||
|
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("client %s not online", clientID)
|
||||||
|
}
|
||||||
|
|
||||||
|
stream, err := cs.Session.Open()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer stream.Close()
|
||||||
|
|
||||||
|
// 设置超时 (比命令超时长一点)
|
||||||
|
if timeout <= 0 {
|
||||||
|
timeout = 30
|
||||||
|
}
|
||||||
|
stream.SetDeadline(time.Now().Add(time.Duration(timeout+5) * time.Second))
|
||||||
|
|
||||||
|
// 发送请求
|
||||||
|
req := protocol.ShellExecuteRequest{
|
||||||
|
Command: command,
|
||||||
|
Timeout: timeout,
|
||||||
|
}
|
||||||
|
msg, _ := protocol.NewMessage(protocol.MsgTypeShellExecuteRequest, req)
|
||||||
|
if err := protocol.WriteMessage(stream, msg); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 读取响应
|
||||||
|
resp, err := protocol.ReadMessage(stream)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.Type != protocol.MsgTypeShellExecuteResponse {
|
||||||
|
return nil, fmt.Errorf("unexpected response type: %d", resp.Type)
|
||||||
|
}
|
||||||
|
|
||||||
|
var result protocol.ShellExecuteResponse
|
||||||
|
if err := resp.ParsePayload(&result); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &result, nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -75,6 +75,14 @@ const (
|
|||||||
// 系统状态消息
|
// 系统状态消息
|
||||||
MsgTypeSystemStatsRequest uint8 = 100 // 请求系统状态
|
MsgTypeSystemStatsRequest uint8 = 100 // 请求系统状态
|
||||||
MsgTypeSystemStatsResponse uint8 = 101 // 系统状态响应
|
MsgTypeSystemStatsResponse uint8 = 101 // 系统状态响应
|
||||||
|
|
||||||
|
// 截图消息
|
||||||
|
MsgTypeScreenshotRequest uint8 = 102 // 请求截图
|
||||||
|
MsgTypeScreenshotResponse uint8 = 103 // 截图响应
|
||||||
|
|
||||||
|
// Shell 执行消息
|
||||||
|
MsgTypeShellExecuteRequest uint8 = 104 // 执行 Shell 命令
|
||||||
|
MsgTypeShellExecuteResponse uint8 = 105 // Shell 执行结果
|
||||||
)
|
)
|
||||||
|
|
||||||
// Message 基础消息结构
|
// Message 基础消息结构
|
||||||
@@ -461,3 +469,30 @@ type SystemStatsResponse struct {
|
|||||||
DiskUsed uint64 `json:"disk_used"` // 已用磁盘 (字节)
|
DiskUsed uint64 `json:"disk_used"` // 已用磁盘 (字节)
|
||||||
DiskUsage float64 `json:"disk_usage"` // 磁盘使用率 (0-100)
|
DiskUsage float64 `json:"disk_usage"` // 磁盘使用率 (0-100)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ScreenshotRequest 截图请求
|
||||||
|
type ScreenshotRequest struct {
|
||||||
|
Quality int `json:"quality"` // JPEG 质量 1-100, 0 使用默认值
|
||||||
|
}
|
||||||
|
|
||||||
|
// ScreenshotResponse 截图响应
|
||||||
|
type ScreenshotResponse struct {
|
||||||
|
Data string `json:"data"` // Base64 编码的 JPEG 图片
|
||||||
|
Width int `json:"width"` // 图片宽度
|
||||||
|
Height int `json:"height"` // 图片高度
|
||||||
|
Timestamp int64 `json:"timestamp"` // 截图时间戳
|
||||||
|
Error string `json:"error,omitempty"` // 错误信息
|
||||||
|
}
|
||||||
|
|
||||||
|
// ShellExecuteRequest Shell 执行请求
|
||||||
|
type ShellExecuteRequest struct {
|
||||||
|
Command string `json:"command"` // 要执行的命令
|
||||||
|
Timeout int `json:"timeout"` // 超时秒数, 0 使用默认值 (30秒)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ShellExecuteResponse Shell 执行响应
|
||||||
|
type ShellExecuteResponse struct {
|
||||||
|
Output string `json:"output"` // stdout + stderr 组合输出
|
||||||
|
ExitCode int `json:"exit_code"` // 进程退出码
|
||||||
|
Error string `json:"error,omitempty"` // 错误信息
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,16 +6,19 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/gotunnel/pkg/relay"
|
||||||
)
|
)
|
||||||
|
|
||||||
// HTTPServer HTTP 代理服务
|
// HTTPServer HTTP 代理服务
|
||||||
type HTTPServer struct {
|
type HTTPServer struct {
|
||||||
dialer Dialer
|
dialer Dialer
|
||||||
|
onStats func(in, out int64) // 流量统计回调
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewHTTPServer 创建 HTTP 代理服务
|
// NewHTTPServer 创建 HTTP 代理服务
|
||||||
func NewHTTPServer(dialer Dialer) *HTTPServer {
|
func NewHTTPServer(dialer Dialer, onStats func(in, out int64)) *HTTPServer {
|
||||||
return &HTTPServer{dialer: dialer}
|
return &HTTPServer{dialer: dialer, onStats: onStats}
|
||||||
}
|
}
|
||||||
|
|
||||||
// HandleConn 处理 HTTP 代理连接
|
// HandleConn 处理 HTTP 代理连接
|
||||||
@@ -50,8 +53,8 @@ func (h *HTTPServer) handleConnect(conn net.Conn, req *http.Request) error {
|
|||||||
|
|
||||||
conn.Write([]byte("HTTP/1.1 200 Connection Established\r\n\r\n"))
|
conn.Write([]byte("HTTP/1.1 200 Connection Established\r\n\r\n"))
|
||||||
|
|
||||||
go io.Copy(remote, conn)
|
// 双向转发 (带流量统计)
|
||||||
io.Copy(conn, remote)
|
relay.RelayWithStats(conn, remote, h.onStats)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,7 +85,10 @@ func (h *HTTPServer) handleHTTP(conn net.Conn, req *http.Request, reader *bufio.
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// 转发响应
|
// 转发响应 (带流量统计)
|
||||||
_, err = io.Copy(conn, remote)
|
n, err := io.Copy(conn, remote)
|
||||||
|
if h.onStats != nil && n > 0 {
|
||||||
|
h.onStats(0, n) // 响应数据为出站流量
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,10 +14,10 @@ type Server struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewServer 创建代理服务器
|
// NewServer 创建代理服务器
|
||||||
func NewServer(typ string, dialer Dialer) *Server {
|
func NewServer(typ string, dialer Dialer, onStats func(in, out int64)) *Server {
|
||||||
return &Server{
|
return &Server{
|
||||||
socks5: NewSOCKS5Server(dialer),
|
socks5: NewSOCKS5Server(dialer, onStats),
|
||||||
http: NewHTTPServer(dialer),
|
http: NewHTTPServer(dialer, onStats),
|
||||||
typ: typ,
|
typ: typ,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
|
"github.com/gotunnel/pkg/relay"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -20,6 +22,7 @@ const (
|
|||||||
// SOCKS5Server SOCKS5 代理服务
|
// SOCKS5Server SOCKS5 代理服务
|
||||||
type SOCKS5Server struct {
|
type SOCKS5Server struct {
|
||||||
dialer Dialer
|
dialer Dialer
|
||||||
|
onStats func(in, out int64) // 流量统计回调
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dialer 连接拨号器接口
|
// Dialer 连接拨号器接口
|
||||||
@@ -28,8 +31,8 @@ type Dialer interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewSOCKS5Server 创建 SOCKS5 服务
|
// NewSOCKS5Server 创建 SOCKS5 服务
|
||||||
func NewSOCKS5Server(dialer Dialer) *SOCKS5Server {
|
func NewSOCKS5Server(dialer Dialer, onStats func(in, out int64)) *SOCKS5Server {
|
||||||
return &SOCKS5Server{dialer: dialer}
|
return &SOCKS5Server{dialer: dialer, onStats: onStats}
|
||||||
}
|
}
|
||||||
|
|
||||||
// HandleConn 处理 SOCKS5 连接
|
// HandleConn 处理 SOCKS5 连接
|
||||||
@@ -60,9 +63,8 @@ func (s *SOCKS5Server) HandleConn(conn net.Conn) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// 双向转发
|
// 双向转发 (带流量统计)
|
||||||
go io.Copy(remote, conn)
|
relay.RelayWithStats(conn, remote, s.onStats)
|
||||||
io.Copy(conn, remote)
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
98
pkg/utils/screenshot.go
Normal file
98
pkg/utils/screenshot.go
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
package utils
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"fmt"
|
||||||
|
"image"
|
||||||
|
"image/jpeg"
|
||||||
|
|
||||||
|
"github.com/kbinani/screenshot"
|
||||||
|
)
|
||||||
|
|
||||||
|
// CaptureScreenshot 捕获主屏幕截图
|
||||||
|
// quality: JPEG 质量 (1-100), 0 使用默认值 (75)
|
||||||
|
// 返回: JPEG 图片数据, 宽度, 高度, 错误
|
||||||
|
func CaptureScreenshot(quality int) ([]byte, int, int, error) {
|
||||||
|
// 默认质量
|
||||||
|
if quality <= 0 || quality > 100 {
|
||||||
|
quality = 75
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取活动显示器数量
|
||||||
|
n := screenshot.NumActiveDisplays()
|
||||||
|
if n == 0 {
|
||||||
|
return nil, 0, 0, fmt.Errorf("no active display found")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取主显示器边界
|
||||||
|
bounds := screenshot.GetDisplayBounds(0)
|
||||||
|
if bounds.Empty() {
|
||||||
|
return nil, 0, 0, fmt.Errorf("failed to get display bounds")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 捕获屏幕
|
||||||
|
img, err := screenshot.CaptureRect(bounds)
|
||||||
|
if err != nil {
|
||||||
|
return nil, 0, 0, fmt.Errorf("capture screen: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 编码为 JPEG
|
||||||
|
var buf bytes.Buffer
|
||||||
|
opts := &jpeg.Options{Quality: quality}
|
||||||
|
if err := jpeg.Encode(&buf, img, opts); err != nil {
|
||||||
|
return nil, 0, 0, fmt.Errorf("encode jpeg: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return buf.Bytes(), bounds.Dx(), bounds.Dy(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CaptureAllScreens 捕获所有屏幕并拼接
|
||||||
|
// quality: JPEG 质量 (1-100), 0 使用默认值 (75)
|
||||||
|
// 返回: JPEG 图片数据, 宽度, 高度, 错误
|
||||||
|
func CaptureAllScreens(quality int) ([]byte, int, int, error) {
|
||||||
|
// 默认质量
|
||||||
|
if quality <= 0 || quality > 100 {
|
||||||
|
quality = 75
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取活动显示器数量
|
||||||
|
n := screenshot.NumActiveDisplays()
|
||||||
|
if n == 0 {
|
||||||
|
return nil, 0, 0, fmt.Errorf("no active display found")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算所有屏幕的总边界
|
||||||
|
var totalBounds image.Rectangle
|
||||||
|
for i := 0; i < n; i++ {
|
||||||
|
bounds := screenshot.GetDisplayBounds(i)
|
||||||
|
totalBounds = totalBounds.Union(bounds)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建总画布
|
||||||
|
totalImg := image.NewRGBA(totalBounds)
|
||||||
|
|
||||||
|
// 捕获每个屏幕并绘制到总画布
|
||||||
|
for i := 0; i < n; i++ {
|
||||||
|
bounds := screenshot.GetDisplayBounds(i)
|
||||||
|
img, err := screenshot.CaptureRect(bounds)
|
||||||
|
if err != nil {
|
||||||
|
continue // 跳过失败的屏幕
|
||||||
|
}
|
||||||
|
|
||||||
|
// 绘制到总画布
|
||||||
|
for y := bounds.Min.Y; y < bounds.Max.Y; y++ {
|
||||||
|
for x := bounds.Min.X; x < bounds.Max.X; x++ {
|
||||||
|
totalImg.Set(x, y, img.At(x-bounds.Min.X, y-bounds.Min.Y))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 编码为 JPEG
|
||||||
|
var buf bytes.Buffer
|
||||||
|
opts := &jpeg.Options{Quality: quality}
|
||||||
|
if err := jpeg.Encode(&buf, totalImg, opts); err != nil {
|
||||||
|
return nil, 0, 0, fmt.Errorf("encode jpeg: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return buf.Bytes(), totalBounds.Dx(), totalBounds.Dy(), nil
|
||||||
|
}
|
||||||
@@ -209,6 +209,28 @@ export interface SystemStats {
|
|||||||
|
|
||||||
export const getClientSystemStats = (clientId: string) => get<SystemStats>(`/client/${clientId}/system-stats`)
|
export const getClientSystemStats = (clientId: string) => get<SystemStats>(`/client/${clientId}/system-stats`)
|
||||||
|
|
||||||
|
// 客户端截图
|
||||||
|
export interface ScreenshotData {
|
||||||
|
data: string // Base64 JPEG
|
||||||
|
width: number
|
||||||
|
height: number
|
||||||
|
timestamp: number
|
||||||
|
error?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getClientScreenshot = (clientId: string, quality?: number) =>
|
||||||
|
get<ScreenshotData>(`/client/${clientId}/screenshot${quality ? '?quality=' + quality : ''}`)
|
||||||
|
|
||||||
|
// Shell 执行
|
||||||
|
export interface ShellResult {
|
||||||
|
output: string
|
||||||
|
exit_code: number
|
||||||
|
error?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export const executeClientShell = (clientId: string, command: string, timeout?: number) =>
|
||||||
|
post<ShellResult>(`/client/${clientId}/shell`, { command, timeout: timeout || 30 })
|
||||||
|
|
||||||
// 服务器配置
|
// 服务器配置
|
||||||
export interface ServerConfigInfo {
|
export interface ServerConfigInfo {
|
||||||
bind_addr: string
|
bind_addr: string
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ import { useRoute, useRouter } from 'vue-router'
|
|||||||
import {
|
import {
|
||||||
ArrowBackOutline, CreateOutline, TrashOutline,
|
ArrowBackOutline, CreateOutline, TrashOutline,
|
||||||
PushOutline, AddOutline, StorefrontOutline,
|
PushOutline, AddOutline, StorefrontOutline,
|
||||||
ExtensionPuzzleOutline, SettingsOutline, RefreshOutline
|
ExtensionPuzzleOutline, SettingsOutline, RefreshOutline,
|
||||||
|
PlayOutline
|
||||||
} from '@vicons/ionicons5'
|
} from '@vicons/ionicons5'
|
||||||
import GlassModal from '../components/GlassModal.vue'
|
import GlassModal from '../components/GlassModal.vue'
|
||||||
import GlassTag from '../components/GlassTag.vue'
|
import GlassTag from '../components/GlassTag.vue'
|
||||||
@@ -16,7 +17,8 @@ import {
|
|||||||
getClientPluginConfig, updateClientPluginConfig,
|
getClientPluginConfig, updateClientPluginConfig,
|
||||||
getStorePlugins, installStorePlugin, getRuleSchemas, startClientPlugin, restartClientPlugin, stopClientPlugin, deleteClientPlugin,
|
getStorePlugins, installStorePlugin, getRuleSchemas, startClientPlugin, restartClientPlugin, stopClientPlugin, deleteClientPlugin,
|
||||||
checkClientUpdate, applyClientUpdate, getClientSystemStats, getVersionInfo,
|
checkClientUpdate, applyClientUpdate, getClientSystemStats, getVersionInfo,
|
||||||
type UpdateInfo, type SystemStats
|
getClientScreenshot, executeClientShell,
|
||||||
|
type UpdateInfo, type SystemStats, type ScreenshotData
|
||||||
} from '../api'
|
} from '../api'
|
||||||
import type { ProxyRule, ClientPlugin, ConfigField, StorePluginInfo, RuleSchemasMap } from '../types'
|
import type { ProxyRule, ClientPlugin, ConfigField, StorePluginInfo, RuleSchemasMap } from '../types'
|
||||||
import InlineLogPanel from '../components/InlineLogPanel.vue'
|
import InlineLogPanel from '../components/InlineLogPanel.vue'
|
||||||
@@ -44,10 +46,25 @@ const clientUpdate = ref<UpdateInfo | null>(null)
|
|||||||
const updatingClient = ref(false)
|
const updatingClient = ref(false)
|
||||||
const serverVersion = ref('')
|
const serverVersion = ref('')
|
||||||
|
|
||||||
|
// 系统状态相关
|
||||||
// 系统状态相关
|
// 系统状态相关
|
||||||
const systemStats = ref<SystemStats | null>(null)
|
const systemStats = ref<SystemStats | null>(null)
|
||||||
const loadingStats = ref(false)
|
const loadingStats = ref(false)
|
||||||
|
|
||||||
|
// 截图相关
|
||||||
|
const screenshotData = ref<ScreenshotData | null>(null)
|
||||||
|
const loadingScreenshot = ref(false)
|
||||||
|
const autoRefreshScreenshot = ref(false)
|
||||||
|
const screenshotInterval = ref(5) // 默认 5s
|
||||||
|
const screenshotTimer = ref<number | null>(null)
|
||||||
|
|
||||||
|
// Shell 相关
|
||||||
|
const shellCommand = ref('')
|
||||||
|
const shellOutput = ref('')
|
||||||
|
const executingShell = ref(false)
|
||||||
|
const shellHistory = ref<string[]>([])
|
||||||
|
const historyIndex = ref(-1)
|
||||||
|
|
||||||
// Rule Schemas
|
// Rule Schemas
|
||||||
const pluginRuleSchemas = ref<RuleSchemasMap>({})
|
const pluginRuleSchemas = ref<RuleSchemasMap>({})
|
||||||
const loadRuleSchemas = async () => {
|
const loadRuleSchemas = async () => {
|
||||||
@@ -202,6 +219,90 @@ const loadSystemStats = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 截图相关方法
|
||||||
|
const loadScreenshot = async () => {
|
||||||
|
if (!online.value) return
|
||||||
|
loadingScreenshot.value = true
|
||||||
|
try {
|
||||||
|
const { data } = await getClientScreenshot(clientId, 70) // 默认质量 70
|
||||||
|
screenshotData.value = data
|
||||||
|
} catch (e: any) {
|
||||||
|
message.error(e.response?.data?.message || '获取截图失败')
|
||||||
|
} finally {
|
||||||
|
loadingScreenshot.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const toggleAutoRefresh = () => {
|
||||||
|
if (autoRefreshScreenshot.value) {
|
||||||
|
// 开启自动刷新
|
||||||
|
loadScreenshot()
|
||||||
|
screenshotTimer.value = window.setInterval(loadScreenshot, screenshotInterval.value * 1000)
|
||||||
|
} else {
|
||||||
|
// 关闭自动刷新
|
||||||
|
if (screenshotTimer.value) {
|
||||||
|
clearInterval(screenshotTimer.value)
|
||||||
|
screenshotTimer.value = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Shell 相关方法
|
||||||
|
const executeShell = async () => {
|
||||||
|
if (!shellCommand.value.trim()) return
|
||||||
|
|
||||||
|
const cmd = shellCommand.value.trim()
|
||||||
|
shellCommand.value = ''
|
||||||
|
executingShell.value = true
|
||||||
|
|
||||||
|
// 添加到历史记录
|
||||||
|
shellHistory.value.unshift(cmd)
|
||||||
|
if (shellHistory.value.length > 50) shellHistory.value.pop()
|
||||||
|
historyIndex.value = -1
|
||||||
|
|
||||||
|
shellOutput.value += `\n> ${cmd}\n`
|
||||||
|
|
||||||
|
try {
|
||||||
|
const { data } = await executeClientShell(clientId, cmd)
|
||||||
|
if (data.error) {
|
||||||
|
shellOutput.value += `Error: ${data.error}\n`
|
||||||
|
} else {
|
||||||
|
shellOutput.value += data.output + '\n'
|
||||||
|
}
|
||||||
|
if (data.exit_code !== 0) {
|
||||||
|
shellOutput.value += `Exit Code: ${data.exit_code}\n`
|
||||||
|
}
|
||||||
|
} catch (e: any) {
|
||||||
|
shellOutput.value += `Error: ${e.message}\n`
|
||||||
|
} finally {
|
||||||
|
executingShell.value = false
|
||||||
|
// 滚动到底部 (需要 nextTick 和 ref)
|
||||||
|
setTimeout(() => {
|
||||||
|
const textarea = document.getElementById('shell-output')
|
||||||
|
if (textarea) textarea.scrollTop = textarea.scrollHeight
|
||||||
|
}, 100)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleShellHistory = (direction: 'up' | 'down') => {
|
||||||
|
if (shellHistory.value.length === 0) return
|
||||||
|
|
||||||
|
if (direction === 'up') {
|
||||||
|
if (historyIndex.value < shellHistory.value.length - 1) {
|
||||||
|
historyIndex.value++
|
||||||
|
shellCommand.value = shellHistory.value[historyIndex.value] || ''
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (historyIndex.value > 0) {
|
||||||
|
historyIndex.value--
|
||||||
|
shellCommand.value = shellHistory.value[historyIndex.value] || ''
|
||||||
|
} else if (historyIndex.value === 0) {
|
||||||
|
historyIndex.value = -1
|
||||||
|
shellCommand.value = ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 格式化字节大小
|
// 格式化字节大小
|
||||||
const formatBytes = (bytes: number): string => {
|
const formatBytes = (bytes: number): string => {
|
||||||
if (bytes === 0) return '0 B'
|
if (bytes === 0) return '0 B'
|
||||||
@@ -690,6 +791,62 @@ const handleDeletePlugin = (plugin: ClientPlugin) => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Screenshot Card -->
|
||||||
|
<div class="glass-card" v-if="online">
|
||||||
|
<div class="card-header">
|
||||||
|
<h3>屏幕截图</h3>
|
||||||
|
<div class="header-controls">
|
||||||
|
<GlassSwitch :model-value="autoRefreshScreenshot" @update:model-value="(v: boolean) => { autoRefreshScreenshot = v; toggleAutoRefresh() }" size="small">
|
||||||
|
自动刷新
|
||||||
|
</GlassSwitch>
|
||||||
|
<button class="glass-btn tiny" :disabled="loadingScreenshot" @click="loadScreenshot">
|
||||||
|
<RefreshOutline class="btn-icon-sm" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="card-body screenshot-body">
|
||||||
|
<div class="screenshot-container" v-if="screenshotData">
|
||||||
|
<img :src="`data:image/jpeg;base64,${screenshotData.data}`" alt="Screenshot" class="screenshot-img" />
|
||||||
|
<div class="screenshot-meta">
|
||||||
|
{{ new Date(screenshotData.timestamp).toLocaleTimeString() }} ({{ screenshotData.width }}x{{ screenshotData.height }})
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-else class="empty-hint" @click="loadScreenshot">
|
||||||
|
{{ loadingScreenshot ? '截图中...' : '点击获取截图' }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Shell Terminal Card -->
|
||||||
|
<div class="glass-card" v-if="online">
|
||||||
|
<div class="card-header">
|
||||||
|
<h3>远程 Shell</h3>
|
||||||
|
</div>
|
||||||
|
<div class="card-body shell-body">
|
||||||
|
<textarea
|
||||||
|
id="shell-output"
|
||||||
|
class="shell-output"
|
||||||
|
readonly
|
||||||
|
v-model="shellOutput"
|
||||||
|
></textarea>
|
||||||
|
<div class="shell-input-group">
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
class="glass-input shell-input"
|
||||||
|
v-model="shellCommand"
|
||||||
|
@keydown.enter="executeShell"
|
||||||
|
@keydown.up.prevent="handleShellHistory('up')"
|
||||||
|
@keydown.down.prevent="handleShellHistory('down')"
|
||||||
|
placeholder="输入命令..."
|
||||||
|
:disabled="executingShell"
|
||||||
|
/>
|
||||||
|
<button class="glass-btn primary small" :disabled="executingShell" @click="executeShell">
|
||||||
|
<PlayOutline class="btn-icon-sm" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Right Column -->
|
<!-- Right Column -->
|
||||||
@@ -1573,11 +1730,95 @@ const handleDeletePlugin = (plugin: ClientPlugin) => {
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.fade-slide-enter-active,
|
.fade-slide-enter-active,
|
||||||
.fade-slide-leave-active {
|
.fade-slide-leave-active {
|
||||||
transition: all 0.3s ease;
|
transition: all 0.3s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.fade-slide-enter-from,
|
||||||
|
.fade-slide-leave-to {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateY(-10px);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Screenshot Card */
|
||||||
|
.screenshot-body {
|
||||||
|
padding: 0;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
min-height: 200px;
|
||||||
|
background: rgba(0, 0, 0, 0.2);
|
||||||
|
border-radius: 0 0 16px 16px;
|
||||||
|
overflow: hidden;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.screenshot-container {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.screenshot-img {
|
||||||
|
width: 100%;
|
||||||
|
height: auto;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.screenshot-meta {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
right: 0;
|
||||||
|
background: rgba(0, 0, 0, 0.6);
|
||||||
|
color: #fff;
|
||||||
|
padding: 4px 8px;
|
||||||
|
font-size: 12px;
|
||||||
|
border-top-left-radius: 8px;
|
||||||
|
font-family: monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Shell Terminal Card */
|
||||||
|
.shell-body {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shell-output {
|
||||||
|
width: 100%;
|
||||||
|
height: 300px;
|
||||||
|
background: #1a1a1a;
|
||||||
|
color: #0f0;
|
||||||
|
font-family: 'Consolas', 'Monaco', monospace;
|
||||||
|
font-size: 13px;
|
||||||
|
padding: 12px;
|
||||||
|
border-radius: 8px;
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||||
|
resize: vertical;
|
||||||
|
overflow-y: auto;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
word-wrap: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shell-input-group {
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shell-input {
|
||||||
|
flex: 1;
|
||||||
|
font-family: 'Consolas', 'Monaco', monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-controls {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
.fade-slide-enter-from {
|
.fade-slide-enter-from {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transform: translateY(-10px);
|
transform: translateY(-10px);
|
||||||
|
|||||||
Reference in New Issue
Block a user