mirror of
https://github.com/qingchencloud/cftunnel.git
synced 2026-08-29 02:32:37 +08:00
d976ee2c33
- 新增 relay 模式: frp 中继引擎,TCP/UDP 全协议穿透 - 新增 relay server setup: SSH 远程安装 frps 服务端 - 新增 sshutil 包: 纯 Go SSH 连接/远程执行 - 官网: 移动端响应式适配 (480/768/900px 三断点) - 官网: 修复 Star 按钮样式,特性卡片 11→12 - install.sh: 国内镜像源加速 (ghfast/gh-proxy/ghproxy) - Docker Compose + install-relay.sh 服务端部署方案
48 lines
998 B
Go
48 lines
998 B
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"text/tabwriter"
|
|
|
|
"github.com/qingchencloud/cftunnel/internal/config"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func init() {
|
|
relayCmd.AddCommand(relayListCmd)
|
|
}
|
|
|
|
var relayListCmd = &cobra.Command{
|
|
Use: "list",
|
|
Short: "列出所有中继穿透规则",
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
cfg, err := config.Load()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if len(cfg.Relay.Rules) == 0 {
|
|
fmt.Println("暂无中继规则")
|
|
return nil
|
|
}
|
|
|
|
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
|
|
fmt.Fprintln(w, "名称\t协议\t本地端口\t远程端口\t域名")
|
|
fmt.Fprintln(w, "----\t----\t--------\t--------\t----")
|
|
for _, r := range cfg.Relay.Rules {
|
|
remote := "-"
|
|
if r.RemotePort > 0 {
|
|
remote = fmt.Sprintf("%d", r.RemotePort)
|
|
}
|
|
domain := "-"
|
|
if r.Domain != "" {
|
|
domain = r.Domain
|
|
}
|
|
fmt.Fprintf(w, "%s\t%s\t%d\t%s\t%s\n",
|
|
r.Name, r.Proto, r.LocalPort, remote, domain)
|
|
}
|
|
w.Flush()
|
|
return nil
|
|
},
|
|
}
|