fix: token 改为配置文件读取,不再自动生成;UI 全部汉化
This commit is contained in:
28
main.go
28
main.go
@@ -49,8 +49,8 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Generate auth token
|
||||
token := server.GenerateToken()
|
||||
// Read token from config (empty = no auth required)
|
||||
token := cfg.Security.Token
|
||||
|
||||
// TLS setup
|
||||
var tlsResult *vpTLS.Result
|
||||
@@ -67,24 +67,34 @@ func main() {
|
||||
host = tlsResult.Host
|
||||
}
|
||||
// Build URL
|
||||
url := fmt.Sprintf("%s://%s:%d/?token=%s", scheme, host, cfg.Server.Port, token)
|
||||
var url string
|
||||
if token != "" {
|
||||
url = fmt.Sprintf("%s://%s:%d/?token=%s", scheme, host, cfg.Server.Port, token)
|
||||
} else {
|
||||
url = fmt.Sprintf("%s://%s:%d/", scheme, host, cfg.Server.Port)
|
||||
}
|
||||
// Print connection info
|
||||
fmt.Println()
|
||||
fmt.Println("╔══════════════════════════════════════╗")
|
||||
fmt.Println("║ VoicePaste Ready ║")
|
||||
fmt.Println("║ VoicePaste 就绪 ║")
|
||||
fmt.Println("╚══════════════════════════════════════╝")
|
||||
fmt.Println()
|
||||
fmt.Printf(" URL: %s\n", url)
|
||||
fmt.Printf(" 地址: %s\n", url)
|
||||
if tlsResult != nil && tlsResult.AnyIP {
|
||||
fmt.Println(" TLS: AnyIP (browser-trusted)")
|
||||
fmt.Println(" 证书: AnyIP(浏览器信任)")
|
||||
} else if cfg.Server.TLSAuto {
|
||||
fmt.Println(" TLS: self-signed (browser will warn)")
|
||||
fmt.Println(" 证书: 自签名(浏览器会警告)")
|
||||
}
|
||||
if token != "" {
|
||||
fmt.Println(" 认证: 已启用")
|
||||
} else {
|
||||
fmt.Println(" 认证: 未启用(无需 token)")
|
||||
}
|
||||
fmt.Println()
|
||||
printQRCode(url)
|
||||
fmt.Println()
|
||||
fmt.Println(" Scan QR code with your phone to connect.")
|
||||
fmt.Println(" Press Ctrl+C to stop.")
|
||||
fmt.Println(" 用手机扫描二维码连接")
|
||||
fmt.Println(" 按 Ctrl+C 停止服务")
|
||||
fmt.Println()
|
||||
// Create and start server
|
||||
webContent, _ := fs.Sub(webFS, "web")
|
||||
|
||||
Reference in New Issue
Block a user