All checks were successful
Build Multi-Platform Binaries / build (push) Successful in 11m54s
43 lines
1.1 KiB
Go
43 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"log"
|
|
|
|
"github.com/gotunnel/internal/client/tunnel"
|
|
"github.com/gotunnel/pkg/crypto"
|
|
"github.com/gotunnel/pkg/plugin"
|
|
"github.com/gotunnel/pkg/plugin/builtin"
|
|
)
|
|
|
|
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")
|
|
flag.Parse()
|
|
|
|
if *server == "" || *token == "" {
|
|
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")
|
|
}
|
|
|
|
// 初始化插件系统
|
|
registry := plugin.NewRegistry()
|
|
if err := registry.RegisterAll(builtin.GetAll()); err != nil {
|
|
log.Fatalf("[Plugin] Register error: %v", err)
|
|
}
|
|
client.SetPluginRegistry(registry)
|
|
log.Printf("[Plugin] Registered %d plugins", len(builtin.GetAll()))
|
|
|
|
client.Run()
|
|
}
|