add tls
All checks were successful
Build Multi-Platform Binaries / build (push) Successful in 11m8s

This commit is contained in:
Flik
2025-12-26 00:00:29 +08:00
parent f1038a132b
commit 1870b59214
6 changed files with 80 additions and 36 deletions

View File

@@ -5,18 +5,28 @@ import (
"log"
"github.com/gotunnel/internal/client/tunnel"
"github.com/gotunnel/pkg/crypto"
)
func main() {
server := flag.String("s", "", "server address (ip:port)")
token := flag.String("t", "", "auth token")
id := flag.String("id", "", "client id (optional)")
noTLS := flag.Bool("no-tls", false, "disable TLS")
flag.Parse()
if *server == "" || *token == "" {
log.Fatal("Usage: client -s <server:port> -t <token> [-id <client_id>]")
log.Fatal("Usage: client -s <server:port> -t <token> [-id <client_id>] [-no-tls]")
}
client := tunnel.NewClient(*server, *token, *id)
// TLS 默认启用
if !*noTLS {
client.TLSEnabled = true
client.TLSConfig = crypto.ClientTLSConfig()
log.Printf("[Client] TLS enabled")
}
client.Run()
}