mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-06-21 06:06:34 +00:00

## Summary In order to make cloudflared behavior more predictable and prevent an exhaustion of resources, we have decided to add session limits that can be configured by the user. This first commit introduces the session limiter and adds it to the UDP handling path. For now the limiter is set to run only in unlimited mode.
42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"log"
|
|
"os"
|
|
)
|
|
|
|
const (
|
|
deprecatedFlagProgOnly = "prog_only"
|
|
deprecatedFlagExecOnly = "exec_only"
|
|
)
|
|
|
|
var (
|
|
_ = flag.Bool("prog_only", false, "DEPRECATED (reflect mode) Only generate the reflection program; write it to stdout and exit.")
|
|
_ = flag.String("exec_only", "", "DEPRECATED (reflect mode) If set, execute this reflection program.")
|
|
)
|
|
|
|
// notifyAboutDeprecatedFlags prints a warning message for a deprecated flags if they are set.
|
|
func notifyAboutDeprecatedFlags() {
|
|
const resetColorPostfix = "\033[0m"
|
|
logger := initWarningLogger()
|
|
|
|
flag.Visit(func(f *flag.Flag) {
|
|
switch f.Name {
|
|
case deprecatedFlagProgOnly:
|
|
logger.Println("The -prog_only flag is deprecated and has no effect.", resetColorPostfix)
|
|
case deprecatedFlagExecOnly:
|
|
logger.Println("The -exec_only flag is deprecated and has no effect.", resetColorPostfix)
|
|
}
|
|
})
|
|
}
|
|
|
|
func initWarningLogger() *log.Logger {
|
|
const (
|
|
yellowColor = "\033[33m"
|
|
warningPrefix = yellowColor + "WARNING: "
|
|
)
|
|
|
|
return log.New(os.Stdout, warningPrefix, log.Ldate|log.Ltime)
|
|
}
|