Files
v2rayA/service/server/controller/version.go
T
89aca5911c feat(tun): migrate transparent proxy from Sing-Tun to TinyTun
Squashed from:
- bc2e2215 Remove all Sing-Tun related code, frontend and build tags
- 51c11701 Add TinyTun support for TUN-based transparent proxy
- d203a9e9 Add TinyTun auto_route toggle and custom route script dialog
- 4c67a319 Improve UI consistency and add tinytun build tag
- 6e411be6 use TinyTun instead of SIng-Tun

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Markson Hon <50002150+MarksonHon@users.noreply.github.com>
2026-03-21 15:01:17 +08:00

62 lines
1.7 KiB
Go

package controller
import (
"net/http"
"os"
"runtime"
"github.com/gin-gonic/gin"
"github.com/v2rayA/v2rayA/common"
"github.com/v2rayA/v2rayA/conf"
v2ray "github.com/v2rayA/v2rayA/core/v2ray"
"github.com/v2rayA/v2rayA/core/v2ray/asset/dat"
"github.com/v2rayA/v2rayA/core/v2ray/service"
"github.com/v2rayA/v2rayA/core/v2ray/where"
"github.com/v2rayA/v2rayA/pkg/util/privilege"
)
func GetVersion(ctx *gin.Context) {
var lite int
if conf.GetEnvironmentConfig().Lite {
lite = 1
}
// Detect if running as root (Linux/macOS only)
isRoot := false
switch runtime.GOOS {
case "linux", "darwin":
isRoot = os.Geteuid() == 0
case "windows":
isRoot = privilege.IsRootOrAdmin()
}
variant, versionErr := service.CheckV5()
common.ResponseSuccess(ctx, gin.H{
"version": conf.Version,
"foundNew": conf.FoundNew,
"remoteVersion": conf.RemoteVersion,
"serviceValid": service.IsV2rayServiceValid(),
"v5": versionErr == nil, // FIXME: Compomise on compatibility.
"lite": lite,
"loadBalanceValid": (variant == where.V2ray || variant == where.Xray) && versionErr == nil,
"variant": variant,
"os": runtime.GOOS,
"isRoot": isRoot,
"tinytunSupported": v2ray.IsTinyTunEnabled(),
})
}
func GetRemoteGFWListVersion(ctx *gin.Context) {
//c, err := httpClient.GetHttpClientAutomatically()
//if err != nil {
// tools.ResponseError(ctx, err)
// return
//}
g, err := dat.GetRemoteGFWListUpdateTime(http.DefaultClient)
if err != nil {
common.ResponseError(ctx, logError(err))
return
}
common.ResponseSuccess(ctx, gin.H{"remoteGFWListVersion": g.UpdateTime.Local().Format("2006-01-02")})
}