rebrand: frp -> kanhole (kanhole server, kanholec client)
golangci-lint / lint (push) Failing after 1m5s

This commit is contained in:
kannn
2026-05-29 09:05:34 +00:00
Unverified
parent a0a42a4966
commit 2cd3052da1
265 changed files with 949 additions and 962 deletions
+3 -3
View File
@@ -15,9 +15,9 @@
package main
import (
_ "github.com/fatedier/frp/pkg/metrics"
"github.com/fatedier/frp/pkg/util/system"
_ "github.com/fatedier/frp/web/frps"
_ "kanhole/pkg/metrics"
"kanhole/pkg/util/system"
_ "kanhole/web/frps"
)
func main() {
+17 -17
View File
@@ -8,14 +8,14 @@ import (
"github.com/spf13/cobra"
"github.com/fatedier/frp/pkg/config"
v1 "github.com/fatedier/frp/pkg/config/v1"
"github.com/fatedier/frp/pkg/config/v1/validation"
"github.com/fatedier/frp/pkg/db"
"github.com/fatedier/frp/pkg/policy/security"
"github.com/fatedier/frp/pkg/util/log"
"github.com/fatedier/frp/pkg/util/version"
"github.com/fatedier/frp/server"
"kanhole/pkg/config"
v1 "kanhole/pkg/config/v1"
"kanhole/pkg/config/v1/validation"
"kanhole/pkg/db"
"kanhole/pkg/policy/security"
"kanhole/pkg/util/log"
"kanhole/pkg/util/version"
"kanhole/server"
)
var (
@@ -28,8 +28,8 @@ var (
)
func init() {
rootCmd.PersistentFlags().StringVarP(&cfgFile, "config", "c", "", "config file of frps")
rootCmd.PersistentFlags().BoolVarP(&showVersion, "version", "v", false, "version of frps")
rootCmd.PersistentFlags().StringVarP(&cfgFile, "config", "c", "", "config file of kanhole")
rootCmd.PersistentFlags().BoolVarP(&showVersion, "version", "v", false, "version of kanhole")
rootCmd.PersistentFlags().BoolVarP(&strictConfigMode, "strict_config", "", true, "strict config parsing mode, unknown fields will cause errors")
rootCmd.PersistentFlags().StringSliceVarP(&allowUnsafe, "allow-unsafe", "", []string{},
fmt.Sprintf("allowed unsafe features, one or more of: %s", strings.Join(security.ServerUnsafeFeatures, ", ")))
@@ -38,8 +38,8 @@ func init() {
}
var rootCmd = &cobra.Command{
Use: "frps",
Short: "frps is the server of frp (https://github.com/fatedier/frp)",
Use: "kanhole",
Short: "kanhole is the server component of kanhole",
RunE: func(cmd *cobra.Command, args []string) error {
if showVersion {
fmt.Println(version.Full())
@@ -114,7 +114,7 @@ func loadConfigFromDB() (*v1.ServerConfig, error) {
if err := cfg.Complete(); err != nil {
return nil, fmt.Errorf("failed to complete server config: %w", err)
}
log.Infof("frps uses database configuration")
log.Infof("kanhole uses database configuration")
return cfg, nil
}
@@ -125,7 +125,7 @@ func loadConfigFromDB() (*v1.ServerConfig, error) {
if err := db.SaveServerConfig(cfg); err != nil {
log.Warnf("failed to save default config to db: %v", err)
}
log.Infof("frps started with default configuration (first run)")
log.Infof("kanhole started with default configuration (first run)")
return cfg, nil
}
@@ -133,16 +133,16 @@ func runServer(cfg *v1.ServerConfig) (err error) {
log.InitLogger(cfg.Log.To, cfg.Log.Level, int(cfg.Log.MaxDays), cfg.Log.DisablePrintColor)
if cfgFile != "" {
log.Infof("frps uses config file: %s", cfgFile)
log.Infof("kanhole uses config file: %s", cfgFile)
} else {
log.Infof("frps uses database configuration")
log.Infof("kanhole uses database configuration")
}
svr, err := server.NewService(cfg)
if err != nil {
return err
}
log.Infof("frps started successfully")
log.Infof("kanhole started successfully")
svr.Run(context.Background())
return
}
+5 -5
View File
@@ -20,9 +20,9 @@ import (
"github.com/spf13/cobra"
"github.com/fatedier/frp/pkg/config"
"github.com/fatedier/frp/pkg/config/v1/validation"
"github.com/fatedier/frp/pkg/policy/security"
"kanhole/pkg/config"
"kanhole/pkg/config/v1/validation"
"kanhole/pkg/policy/security"
)
func init() {
@@ -34,7 +34,7 @@ var verifyCmd = &cobra.Command{
Short: "Verify that the configures is valid",
RunE: func(cmd *cobra.Command, args []string) error {
if cfgFile == "" {
fmt.Println("frps: the configuration file is not specified")
fmt.Println("kanhole: the configuration file is not specified")
return nil
}
svrCfg, _, err := config.LoadServerConfig(cfgFile, strictConfigMode)
@@ -53,7 +53,7 @@ var verifyCmd = &cobra.Command{
fmt.Println(err)
os.Exit(1)
}
fmt.Printf("frps: the configuration file %s syntax is ok\n", cfgFile)
fmt.Printf("kanhole: the configuration file %s syntax is ok\n", cfgFile)
return nil
},
}
+3 -3
View File
@@ -15,9 +15,9 @@
package main
import (
"github.com/fatedier/frp/cmd/frpc/sub"
"github.com/fatedier/frp/pkg/util/system"
_ "github.com/fatedier/frp/web/frpc"
"kanhole/cmd/kanholec/sub"
"kanhole/pkg/util/system"
_ "kanhole/web/frpc"
)
func main() {
@@ -1,4 +1,4 @@
// Copyright 2023 The frp Authors
// Copyright 2023 The kanhole Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -24,9 +24,9 @@ import (
"github.com/rodaine/table"
"github.com/spf13/cobra"
"github.com/fatedier/frp/pkg/config"
v1 "github.com/fatedier/frp/pkg/config/v1"
clientsdk "github.com/fatedier/frp/pkg/sdk/client"
"kanhole/pkg/config"
v1 "kanhole/pkg/config/v1"
clientsdk "kanhole/pkg/sdk/client"
)
var adminAPITimeout = 30 * time.Second
@@ -37,9 +37,9 @@ func init() {
description string
handler func(*v1.ClientCommonConfig) error
}{
{"reload", "Hot-Reload frpc configuration", ReloadHandler},
{"reload", "Hot-Reload kanholec configuration", ReloadHandler},
{"status", "Overview of all proxies status", StatusHandler},
{"stop", "Stop the running frpc", StopHandler},
{"stop", "Stop the running kanholec", StopHandler},
}
for _, cmdConfig := range commands {
@@ -11,7 +11,7 @@ import (
"github.com/spf13/cobra"
"github.com/fatedier/frp/pkg/util/log"
"kanhole/pkg/util/log"
)
var (
@@ -22,14 +22,14 @@ var (
func init() {
authCmd := &cobra.Command{
Use: "auth",
Short: "Authenticate frpc with a frp server",
Long: `Authenticate this frpc instance with a frp server.
Short: "Authenticate kanholec with a kanhole server",
Long: `Authenticate this kanholec instance with a kanhole server.
One-time token:
frpc auth token <token> --server http://server:7500
kanholec auth token <token> --server http://server:7500
Interactive login:
frpc auth login --server http://server:7500 --client-name myclient
kanholec auth login --server http://server:7500 --client-name myclient
`,
}
@@ -39,16 +39,16 @@ Interactive login:
Args: cobra.ExactArgs(1),
RunE: runAuthToken,
}
tokenCmd.Flags().StringVarP(&authServer, "server", "s", "http://localhost:7500", "frp server admin URL")
tokenCmd.Flags().StringVarP(&authOutput, "output", "o", "", "output config file path (default: ./frpc-<client-name>.toml)")
tokenCmd.Flags().StringVarP(&authServer, "server", "s", "http://localhost:7500", "kanhole server admin URL")
tokenCmd.Flags().StringVarP(&authOutput, "output", "o", "", "output config file path (default: ./kanholec-<client-name>.toml)")
loginCmd := &cobra.Command{
Use: "login",
Short: "Authenticate using admin credentials",
RunE: runAuthLogin,
}
loginCmd.Flags().StringVarP(&authServer, "server", "s", "http://localhost:7500", "frp server admin URL")
loginCmd.Flags().StringVarP(&authOutput, "output", "o", "", "output config file path (default: ./frpc-<client-name>.toml)")
loginCmd.Flags().StringVarP(&authServer, "server", "s", "http://localhost:7500", "kanhole server admin URL")
loginCmd.Flags().StringVarP(&authOutput, "output", "o", "", "output config file path (default: ./kanholec-<client-name>.toml)")
loginCmd.Flags().String("username", "", "admin username (prompts if empty)")
loginCmd.Flags().String("password", "", "admin password (prompts if empty)")
loginCmd.Flags().String("client-name", "", "client name (fetches list if empty)")
@@ -161,7 +161,7 @@ func saveConfig(data []byte) error {
outputPath := authOutput
if outputPath == "" {
// Try to extract client name from config
outputPath = "frpc.toml"
outputPath = "kanholec.toml"
}
if err := os.MkdirAll(filepath.Dir(outputPath), 0755); err != nil {
@@ -174,7 +174,7 @@ func saveConfig(data []byte) error {
log.Infof("config saved to %s", outputPath)
fmt.Printf("Config saved to %s\n", outputPath)
fmt.Printf("Run: frpc -c %s\n", outputPath)
fmt.Printf("Run: kanholec -c %s\n", outputPath)
return nil
}
@@ -1,17 +1,17 @@
//go:build frpc_gui
//go:build kanholec_gui
package sub
import (
"github.com/spf13/cobra"
"github.com/fatedier/frp/client/gui"
"kanhole/client/gui"
)
func init() {
guiCmd := &cobra.Command{
Use: "gui",
Short: "Start the frpc graphical user interface",
Short: "Start the kanholec graphical user interface",
RunE: func(cmd *cobra.Command, args []string) error {
gui.Run()
return nil
@@ -1,4 +1,4 @@
//go:build !frpc_gui
//go:build !kanholec_gui
package sub
@@ -11,11 +11,11 @@ import (
func init() {
guiCmd := &cobra.Command{
Use: "gui",
Short: "Start the frpc graphical user interface",
Short: "Start the kanholec graphical user interface",
RunE: func(cmd *cobra.Command, args []string) error {
fmt.Println("frpc GUI is not available in this build.")
fmt.Println("kanholec GUI is not available in this build.")
fmt.Println("To build with GUI support, install OpenGL and X11 dev libraries, then:")
fmt.Println(" CGO_ENABLED=1 go build -tags frpc_gui -o frpc ./cmd/frpc")
fmt.Println(" CGO_ENABLED=1 go build -tags kanholec_gui -o kanholec ./cmd/kanholec")
return nil
},
}
@@ -1,4 +1,4 @@
// Copyright 2023 The frp Authors
// Copyright 2023 The kanhole Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -20,9 +20,9 @@ import (
"github.com/spf13/cobra"
"github.com/fatedier/frp/pkg/config"
v1 "github.com/fatedier/frp/pkg/config/v1"
"github.com/fatedier/frp/pkg/nathole"
"kanhole/pkg/config"
v1 "kanhole/pkg/config/v1"
"kanhole/pkg/nathole"
)
var (
@@ -1,4 +1,4 @@
// Copyright 2023 The frp Authors
// Copyright 2023 The kanhole Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -21,11 +21,11 @@ import (
"github.com/spf13/cobra"
"github.com/fatedier/frp/pkg/config"
"github.com/fatedier/frp/pkg/config/source"
v1 "github.com/fatedier/frp/pkg/config/v1"
"github.com/fatedier/frp/pkg/config/v1/validation"
"github.com/fatedier/frp/pkg/policy/security"
"kanhole/pkg/config"
"kanhole/pkg/config/source"
v1 "kanhole/pkg/config/v1"
"kanhole/pkg/config/v1/validation"
"kanhole/pkg/policy/security"
)
var proxyTypes = []v1.ProxyType{
@@ -73,7 +73,7 @@ func init() {
func NewProxyCommand(name string, c v1.ProxyConfigurer, clientCfg *v1.ClientCommonConfig) *cobra.Command {
return &cobra.Command{
Use: name,
Short: fmt.Sprintf("Run frpc with a single %s proxy", name),
Short: fmt.Sprintf("Run kanholec with a single %s proxy", name),
Run: func(cmd *cobra.Command, args []string) {
if err := clientCfg.Complete(); err != nil {
fmt.Println(err)
@@ -106,7 +106,7 @@ func NewProxyCommand(name string, c v1.ProxyConfigurer, clientCfg *v1.ClientComm
func NewVisitorCommand(name string, c v1.VisitorConfigurer, clientCfg *v1.ClientCommonConfig) *cobra.Command {
return &cobra.Command{
Use: "visitor",
Short: fmt.Sprintf("Run frpc with a single %s visitor", name),
Short: fmt.Sprintf("Run kanholec with a single %s visitor", name),
Run: func(cmd *cobra.Command, args []string) {
if err := clientCfg.Complete(); err != nil {
fmt.Println(err)
@@ -30,15 +30,15 @@ import (
"github.com/spf13/cobra"
"github.com/fatedier/frp/client"
"github.com/fatedier/frp/pkg/config"
"github.com/fatedier/frp/pkg/config/source"
v1 "github.com/fatedier/frp/pkg/config/v1"
"github.com/fatedier/frp/pkg/config/v1/validation"
"github.com/fatedier/frp/pkg/policy/featuregate"
"github.com/fatedier/frp/pkg/policy/security"
"github.com/fatedier/frp/pkg/util/log"
"github.com/fatedier/frp/pkg/util/version"
"kanhole/client"
"kanhole/pkg/config"
"kanhole/pkg/config/source"
v1 "kanhole/pkg/config/v1"
"kanhole/pkg/config/v1/validation"
"kanhole/pkg/policy/featuregate"
"kanhole/pkg/policy/security"
"kanhole/pkg/util/log"
"kanhole/pkg/util/version"
)
var (
@@ -51,9 +51,9 @@ var (
)
func init() {
rootCmd.PersistentFlags().StringVarP(&cfgFile, "config", "c", "./frpc.ini", "config file of frpc")
rootCmd.PersistentFlags().StringVarP(&cfgDir, "config_dir", "", "", "config directory, run one frpc service for each file in config directory")
rootCmd.PersistentFlags().BoolVarP(&showVersion, "version", "v", false, "version of frpc")
rootCmd.PersistentFlags().StringVarP(&cfgFile, "config", "c", "./kanholec.toml", "config file of kanholec")
rootCmd.PersistentFlags().StringVarP(&cfgDir, "config_dir", "", "", "config directory, run one kanholec service for each file in config directory")
rootCmd.PersistentFlags().BoolVarP(&showVersion, "version", "v", false, "version of kanholec")
rootCmd.PersistentFlags().BoolVarP(&strictConfigMode, "strict_config", "", true, "strict config parsing mode, unknown fields will cause an errors")
rootCmd.PersistentFlags().StringVarP(&serverConfigURL, "server-config", "", "", "fetch config from frps server URL (auto-reloads on change)")
@@ -62,8 +62,8 @@ func init() {
}
var rootCmd = &cobra.Command{
Use: "frpc",
Short: "frpc is the client of frp (https://github.com/fatedier/frp)",
Use: "kanholec",
Short: "kanholec is the client component of kanhole",
RunE: func(cmd *cobra.Command, args []string) error {
if showVersion {
fmt.Println(version.Full())
@@ -72,7 +72,7 @@ var rootCmd = &cobra.Command{
unsafeFeatures := security.NewUnsafeFeatures(allowUnsafe)
// If cfgDir is not empty, run multiple frpc service for each config file in cfgDir.
// If cfgDir is not empty, run multiple kanholec service for each config file in cfgDir.
// Note that it's only designed for testing. It's not guaranteed to be stable.
if cfgDir != "" {
_ = runMultipleClients(cfgDir, unsafeFeatures)
@@ -111,7 +111,7 @@ func runMultipleClients(cfgDir string, unsafeFeatures *security.UnsafeFeatures)
defer wg.Done()
err := runClient(path, unsafeFeatures)
if err != nil {
fmt.Printf("frpc service error for config file [%s]\n", path)
fmt.Printf("kanholec service error for config file [%s]\n", path)
}
}()
return nil
@@ -243,8 +243,8 @@ func startServiceWithAggregator(
log.InitLogger(cfg.Log.To, cfg.Log.Level, int(cfg.Log.MaxDays), cfg.Log.DisablePrintColor)
if cfgFile != "" {
log.Infof("start frpc service for config file [%s] with aggregated configuration", cfgFile)
defer log.Infof("frpc service for config file [%s] stopped", cfgFile)
log.Infof("start kanholec service for config file [%s] with aggregated configuration", cfgFile)
defer log.Infof("kanholec service for config file [%s] stopped", cfgFile)
}
svr, err := client.NewService(client.ServiceOptions{
Common: cfg,
@@ -1,4 +1,4 @@
// Copyright 2021 The frp Authors
// Copyright 2021 The kanhole Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -20,9 +20,9 @@ import (
"github.com/spf13/cobra"
"github.com/fatedier/frp/pkg/config"
"github.com/fatedier/frp/pkg/config/v1/validation"
"github.com/fatedier/frp/pkg/policy/security"
"kanhole/pkg/config"
"kanhole/pkg/config/v1/validation"
"kanhole/pkg/policy/security"
)
func init() {
@@ -34,7 +34,7 @@ var verifyCmd = &cobra.Command{
Short: "Verify that the configures is valid",
RunE: func(cmd *cobra.Command, args []string) error {
if cfgFile == "" {
fmt.Println("frpc: the configuration file is not specified")
fmt.Println("kanholec: the configuration file is not specified")
return nil
}
@@ -53,7 +53,7 @@ var verifyCmd = &cobra.Command{
os.Exit(1)
}
fmt.Printf("frpc: the configuration file %s syntax is ok\n", cfgFile)
fmt.Printf("kanholec: the configuration file %s syntax is ok\n", cfgFile)
return nil
},
}