Some checks failed
Build Multi-Platform Binaries / build-frontend (push) Failing after 16s
Build Multi-Platform Binaries / build-binaries (amd64, darwin, server, false) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (amd64, linux, client, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (amd64, linux, server, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (amd64, windows, client, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (amd64, windows, server, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, client, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, server, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (arm64, darwin, server, false) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (arm64, linux, client, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (arm64, linux, server, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (arm64, windows, server, false) (push) Has been skipped
- 集成主题切换功能,支持浅色、深色和自动模式 - 添加SunnyOutline、MoonOutline、ContrastOutline图标用于主题选择 - 创建主题下拉菜单组件,允许用户切换不同主题模式 - 重构CSS样式使用CSS变量替代硬编码颜色值 - 优化导航栏、用户菜单、客户端卡片等组件的视觉效果 - 调整头部高度从60px到56px,修改品牌文字样式 - 更新按钮、下拉菜单、模态框等交互元素的样式 - 在客户端视图中添加心跳指示器显示连接状态 - 实现客户端页面数据自动轮询刷新功能 - 优化版本号显示逻辑,确保始终以v开头显示 - 修复更新检查按钮只在有可用更新时才显示的问题
82 lines
1.9 KiB
Go
82 lines
1.9 KiB
Go
package main
|
||
|
||
import (
|
||
"flag"
|
||
"log"
|
||
|
||
"github.com/gotunnel/internal/client/config"
|
||
"github.com/gotunnel/internal/client/tunnel"
|
||
"github.com/gotunnel/pkg/crypto"
|
||
"github.com/gotunnel/pkg/plugin"
|
||
"github.com/gotunnel/pkg/version"
|
||
)
|
||
|
||
// 版本信息(通过 ldflags 注入)
|
||
var Version string
|
||
var BuildTime string
|
||
var GitCommit string
|
||
|
||
func init() {
|
||
version.SetVersion(Version)
|
||
version.SetBuildInfo(GitCommit, BuildTime)
|
||
}
|
||
|
||
func main() {
|
||
server := flag.String("s", "", "server address (ip:port)")
|
||
token := flag.String("t", "", "auth token")
|
||
id := flag.String("id", "", "client id (optional, auto-assigned if empty)")
|
||
noTLS := flag.Bool("no-tls", false, "disable TLS")
|
||
configPath := flag.String("c", "", "config file path")
|
||
flag.Parse()
|
||
|
||
// 优先加载配置文件
|
||
var cfg *config.ClientConfig
|
||
if *configPath != "" {
|
||
var err error
|
||
cfg, err = config.LoadClientConfig(*configPath)
|
||
if err != nil {
|
||
log.Fatalf("Failed to load config: %v", err)
|
||
}
|
||
} else {
|
||
cfg = &config.ClientConfig{}
|
||
}
|
||
|
||
// 命令行参数覆盖配置文件
|
||
if *server != "" {
|
||
cfg.Server = *server
|
||
}
|
||
if *token != "" {
|
||
cfg.Token = *token
|
||
}
|
||
if *id != "" {
|
||
cfg.ID = *id
|
||
}
|
||
if *noTLS {
|
||
cfg.NoTLS = *noTLS
|
||
}
|
||
|
||
if cfg.Server == "" || cfg.Token == "" {
|
||
log.Fatal("Usage: client [-c config.yaml] | [-s <server:port> -t <token> [-id <client_id>] [-no-tls]]")
|
||
}
|
||
|
||
client := tunnel.NewClient(cfg.Server, cfg.Token, cfg.ID)
|
||
|
||
// TLS 默认启用,默认跳过证书验证(类似 frp)
|
||
if !cfg.NoTLS {
|
||
client.TLSEnabled = true
|
||
client.TLSConfig = crypto.ClientTLSConfig()
|
||
log.Printf("[Client] TLS enabled")
|
||
}
|
||
|
||
// 初始化插件注册表(用于 JS 插件)
|
||
registry := plugin.NewRegistry()
|
||
client.SetPluginRegistry(registry)
|
||
|
||
// 初始化版本存储
|
||
if err := client.InitVersionStore(); err != nil {
|
||
log.Printf("[Client] Warning: failed to init version store: %v", err)
|
||
}
|
||
|
||
client.Run()
|
||
}
|