diff --git a/cmd/frpc/sub/http.go b/cmd/frpc/sub/http.go index 4e193b7e..22eeefe6 100644 --- a/cmd/frpc/sub/http.go +++ b/cmd/frpc/sub/http.go @@ -39,6 +39,8 @@ func init() { httpCmd.PersistentFlags().StringVarP(&hostHeaderRewrite, "host_header_rewrite", "", "", "host header rewrite") httpCmd.PersistentFlags().BoolVarP(&useEncryption, "ue", "", false, "use encryption") httpCmd.PersistentFlags().BoolVarP(&useCompression, "uc", "", false, "use compression") + httpCmd.PersistentFlags().StringVarP(&bandwidthLimit, "bandwidth_limit", "", "", "bandwidth limit") + httpCmd.PersistentFlags().StringVarP(&bandwidthLimitMode, "bandwidth_limit_mode", "", config.BandwidthLimitModeClient, "bandwidth limit mode") rootCmd.AddCommand(httpCmd) } @@ -70,6 +72,12 @@ var httpCmd = &cobra.Command{ cfg.HostHeaderRewrite = hostHeaderRewrite cfg.UseEncryption = useEncryption cfg.UseCompression = useCompression + cfg.BandwidthLimit, err = config.NewBandwidthQuantity(bandwidthLimit) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + cfg.BandwidthLimitMode = bandwidthLimitMode err = cfg.CheckForCli() if err != nil { diff --git a/cmd/frpc/sub/https.go b/cmd/frpc/sub/https.go index 8a14d39d..187aa99b 100644 --- a/cmd/frpc/sub/https.go +++ b/cmd/frpc/sub/https.go @@ -35,6 +35,8 @@ func init() { httpsCmd.PersistentFlags().StringVarP(&subDomain, "sd", "", "", "sub domain") httpsCmd.PersistentFlags().BoolVarP(&useEncryption, "ue", "", false, "use encryption") httpsCmd.PersistentFlags().BoolVarP(&useCompression, "uc", "", false, "use compression") + httpsCmd.PersistentFlags().StringVarP(&bandwidthLimit, "bandwidth_limit", "", "", "bandwidth limit") + httpsCmd.PersistentFlags().StringVarP(&bandwidthLimitMode, "bandwidth_limit_mode", "", config.BandwidthLimitModeClient, "bandwidth limit mode") rootCmd.AddCommand(httpsCmd) } @@ -62,6 +64,12 @@ var httpsCmd = &cobra.Command{ cfg.SubDomain = subDomain cfg.UseEncryption = useEncryption cfg.UseCompression = useCompression + cfg.BandwidthLimit, err = config.NewBandwidthQuantity(bandwidthLimit) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + cfg.BandwidthLimitMode = bandwidthLimitMode err = cfg.CheckForCli() if err != nil { diff --git a/cmd/frpc/sub/root.go b/cmd/frpc/sub/root.go index 19206c6b..cd39d882 100644 --- a/cmd/frpc/sub/root.go +++ b/cmd/frpc/sub/root.go @@ -54,24 +54,26 @@ var ( logMaxDays int disableLogColor bool - proxyName string - localIP string - localPort int - remotePort int - useEncryption bool - useCompression bool - customDomains string - subDomain string - httpUser string - httpPwd string - locations string - hostHeaderRewrite string - role string - sk string - multiplexer string - serverName string - bindAddr string - bindPort int + proxyName string + localIP string + localPort int + remotePort int + useEncryption bool + useCompression bool + bandwidthLimit string + bandwidthLimitMode string + customDomains string + subDomain string + httpUser string + httpPwd string + locations string + hostHeaderRewrite string + role string + sk string + multiplexer string + serverName string + bindAddr string + bindPort int tlsEnable bool ) diff --git a/cmd/frpc/sub/stcp.go b/cmd/frpc/sub/stcp.go index d84b23b7..ad0a57ce 100644 --- a/cmd/frpc/sub/stcp.go +++ b/cmd/frpc/sub/stcp.go @@ -37,6 +37,8 @@ func init() { stcpCmd.PersistentFlags().IntVarP(&bindPort, "bind_port", "", 0, "bind port") stcpCmd.PersistentFlags().BoolVarP(&useEncryption, "ue", "", false, "use encryption") stcpCmd.PersistentFlags().BoolVarP(&useCompression, "uc", "", false, "use compression") + stcpCmd.PersistentFlags().StringVarP(&bandwidthLimit, "bandwidth_limit", "", "", "bandwidth limit") + stcpCmd.PersistentFlags().StringVarP(&bandwidthLimitMode, "bandwidth_limit_mode", "", config.BandwidthLimitModeClient, "bandwidth limit mode") rootCmd.AddCommand(stcpCmd) } @@ -70,6 +72,12 @@ var stcpCmd = &cobra.Command{ cfg.Sk = sk cfg.LocalIP = localIP cfg.LocalPort = localPort + cfg.BandwidthLimit, err = config.NewBandwidthQuantity(bandwidthLimit) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + cfg.BandwidthLimitMode = bandwidthLimitMode err = cfg.CheckForCli() if err != nil { fmt.Println(err) diff --git a/cmd/frpc/sub/sudp.go b/cmd/frpc/sub/sudp.go index f96a12e1..0ae8498b 100644 --- a/cmd/frpc/sub/sudp.go +++ b/cmd/frpc/sub/sudp.go @@ -37,6 +37,8 @@ func init() { sudpCmd.PersistentFlags().IntVarP(&bindPort, "bind_port", "", 0, "bind port") sudpCmd.PersistentFlags().BoolVarP(&useEncryption, "ue", "", false, "use encryption") sudpCmd.PersistentFlags().BoolVarP(&useCompression, "uc", "", false, "use compression") + sudpCmd.PersistentFlags().StringVarP(&bandwidthLimit, "bandwidth_limit", "", "", "bandwidth limit") + sudpCmd.PersistentFlags().StringVarP(&bandwidthLimitMode, "bandwidth_limit_mode", "", config.BandwidthLimitModeClient, "bandwidth limit mode") rootCmd.AddCommand(sudpCmd) } @@ -70,6 +72,12 @@ var sudpCmd = &cobra.Command{ cfg.Sk = sk cfg.LocalIP = localIP cfg.LocalPort = localPort + cfg.BandwidthLimit, err = config.NewBandwidthQuantity(bandwidthLimit) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + cfg.BandwidthLimitMode = bandwidthLimitMode err = cfg.CheckForCli() if err != nil { fmt.Println(err) diff --git a/cmd/frpc/sub/tcp.go b/cmd/frpc/sub/tcp.go index 7e867345..2c597f19 100644 --- a/cmd/frpc/sub/tcp.go +++ b/cmd/frpc/sub/tcp.go @@ -33,6 +33,8 @@ func init() { tcpCmd.PersistentFlags().IntVarP(&remotePort, "remote_port", "r", 0, "remote port") tcpCmd.PersistentFlags().BoolVarP(&useEncryption, "ue", "", false, "use encryption") tcpCmd.PersistentFlags().BoolVarP(&useCompression, "uc", "", false, "use compression") + tcpCmd.PersistentFlags().StringVarP(&bandwidthLimit, "bandwidth_limit", "", "", "bandwidth limit") + tcpCmd.PersistentFlags().StringVarP(&bandwidthLimitMode, "bandwidth_limit_mode", "", config.BandwidthLimitModeClient, "bandwidth limit mode") rootCmd.AddCommand(tcpCmd) } @@ -59,6 +61,12 @@ var tcpCmd = &cobra.Command{ cfg.RemotePort = remotePort cfg.UseEncryption = useEncryption cfg.UseCompression = useCompression + cfg.BandwidthLimit, err = config.NewBandwidthQuantity(bandwidthLimit) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + cfg.BandwidthLimitMode = bandwidthLimitMode err = cfg.CheckForCli() if err != nil { diff --git a/cmd/frpc/sub/tcpmux.go b/cmd/frpc/sub/tcpmux.go index cef845d6..ecdd6002 100644 --- a/cmd/frpc/sub/tcpmux.go +++ b/cmd/frpc/sub/tcpmux.go @@ -36,6 +36,8 @@ func init() { tcpMuxCmd.PersistentFlags().StringVarP(&multiplexer, "mux", "", "", "multiplexer") tcpMuxCmd.PersistentFlags().BoolVarP(&useEncryption, "ue", "", false, "use encryption") tcpMuxCmd.PersistentFlags().BoolVarP(&useCompression, "uc", "", false, "use compression") + tcpMuxCmd.PersistentFlags().StringVarP(&bandwidthLimit, "bandwidth_limit", "", "", "bandwidth limit") + tcpMuxCmd.PersistentFlags().StringVarP(&bandwidthLimitMode, "bandwidth_limit_mode", "", config.BandwidthLimitModeClient, "bandwidth limit mode") rootCmd.AddCommand(tcpMuxCmd) } @@ -64,6 +66,12 @@ var tcpMuxCmd = &cobra.Command{ cfg.Multiplexer = multiplexer cfg.UseEncryption = useEncryption cfg.UseCompression = useCompression + cfg.BandwidthLimit, err = config.NewBandwidthQuantity(bandwidthLimit) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + cfg.BandwidthLimitMode = bandwidthLimitMode err = cfg.CheckForCli() if err != nil { diff --git a/cmd/frpc/sub/udp.go b/cmd/frpc/sub/udp.go index 984ad068..f9dfa3f6 100644 --- a/cmd/frpc/sub/udp.go +++ b/cmd/frpc/sub/udp.go @@ -33,6 +33,8 @@ func init() { udpCmd.PersistentFlags().IntVarP(&remotePort, "remote_port", "r", 0, "remote port") udpCmd.PersistentFlags().BoolVarP(&useEncryption, "ue", "", false, "use encryption") udpCmd.PersistentFlags().BoolVarP(&useCompression, "uc", "", false, "use compression") + udpCmd.PersistentFlags().StringVarP(&bandwidthLimit, "bandwidth_limit", "", "", "bandwidth limit") + udpCmd.PersistentFlags().StringVarP(&bandwidthLimitMode, "bandwidth_limit_mode", "", config.BandwidthLimitModeClient, "bandwidth limit mode") rootCmd.AddCommand(udpCmd) } @@ -59,6 +61,12 @@ var udpCmd = &cobra.Command{ cfg.RemotePort = remotePort cfg.UseEncryption = useEncryption cfg.UseCompression = useCompression + cfg.BandwidthLimit, err = config.NewBandwidthQuantity(bandwidthLimit) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + cfg.BandwidthLimitMode = bandwidthLimitMode err = cfg.CheckForCli() if err != nil { diff --git a/cmd/frpc/sub/xtcp.go b/cmd/frpc/sub/xtcp.go index b8426989..ea201d53 100644 --- a/cmd/frpc/sub/xtcp.go +++ b/cmd/frpc/sub/xtcp.go @@ -37,6 +37,8 @@ func init() { xtcpCmd.PersistentFlags().IntVarP(&bindPort, "bind_port", "", 0, "bind port") xtcpCmd.PersistentFlags().BoolVarP(&useEncryption, "ue", "", false, "use encryption") xtcpCmd.PersistentFlags().BoolVarP(&useCompression, "uc", "", false, "use compression") + xtcpCmd.PersistentFlags().StringVarP(&bandwidthLimit, "bandwidth_limit", "", "", "bandwidth limit") + xtcpCmd.PersistentFlags().StringVarP(&bandwidthLimitMode, "bandwidth_limit_mode", "", config.BandwidthLimitModeClient, "bandwidth limit mode") rootCmd.AddCommand(xtcpCmd) } @@ -70,6 +72,12 @@ var xtcpCmd = &cobra.Command{ cfg.Sk = sk cfg.LocalIP = localIP cfg.LocalPort = localPort + cfg.BandwidthLimit, err = config.NewBandwidthQuantity(bandwidthLimit) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + cfg.BandwidthLimitMode = bandwidthLimitMode err = cfg.CheckForCli() if err != nil { fmt.Println(err)