conf

package
v0.3.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultBind       = ":22"
	DefaultSSHVersion = "OpenSSH_9.3p1"

	DefaultLogLevel    = "info"
	DefaultLogFormat   = "plain"
	DefaultLogPassword = false

	DefaultKeyType = "ed25519"

	DefaultMaxTry = 3

	DefaultDelay     = 0
	DefaultDeviation = 0

	DefaultEnableAntiScan = true

	DefaultSuccessRatio float64 = 0.
)
View Source
const (
	FlagLogFile   = "log"
	FlagLogLevel  = "level"
	FlagLogFormat = "format"
	FlagLogPasswd = "passwd"

	FlagKeyPaths = "key"
	FlagKeyType  = "type"

	FlagBind       = "bind"
	FlagSSHVersion = "version"

	FlagDelay     = "delay"
	FlagDeviation = "devia"

	FlagMaxTry = "try"

	FlagEnableAntiScan  = "a"
	FlagDisableAntiScan = "A"

	FlagSuccessRatio = "r"
	FlagSuccessSeed  = "seed"
)

Variables

Functions

func GetArg

func GetArg() (args *FlagArgsStruct, set StringSet, helper func())

GetArg : get args

func MergeConfig

func MergeConfig(c *AppConfig, f *FlagArgsStruct, set StringSet) error

func StringArrayVar

func StringArrayVar(ps *[]string, name, usage string)

Types

type AppConfig

type AppConfig struct {
	BaseConfig

	Modules ModulesConfig `toml:"modules"`
}

func LoadFromFile

func LoadFromFile(file string) (*AppConfig, error)

func NewDefaultAppConfig

func NewDefaultAppConfig() *AppConfig

func ParseConfig

func ParseConfig(s []byte) (*AppConfig, error)

type BaseConfig

type BaseConfig struct {
	Server struct {
		ServPort   string `toml:"bind"`
		SSHVersion string `toml:"version"`

		MaxTry    int `toml:"max_try"`
		Delay     int `toml:"delay"`
		Deviation int `toml:"deviation"`

		AntiScan bool `toml:"anti_scan"`

		SuccessRatio float64 `toml:"success_ratio"`
		SuccessSeed  []byte  `toml:"success_seed"`
	} `toml:"server"`

	Log struct {
		LogFile     string `toml:"file"`
		LogLevel    string `toml:"level"`
		LogFormat   string `toml:"format"`
		IsLogPasswd bool   `toml:"log_passwd"`
	} `toml:"log"`

	Key struct {
		KeyFiles []string `toml:"key"`
		KeyType  string   `toml:"type"`
	} `toml:"key"`
}

func (*BaseConfig) CheckConfig

func (c *BaseConfig) CheckConfig() error

func (*BaseConfig) FillDefault

func (c *BaseConfig) FillDefault() error

type FlagArgsStruct

type FlagArgsStruct struct {
	Help       bool
	AppVersion bool

	// Log
	LogFile   string
	LogLevel  string
	LogFormat string

	// Key
	KeyFiles   []string
	GenKeyFile bool
	KeyType    string

	// Serve
	ServPort   string
	SSHVersion string

	// Wait time
	Delay     int
	Deviation int

	// Log password
	IsLogPasswd bool

	// Anti honeypot scan
	AntiScan bool

	// Max try times
	MaxTry int

	// ConfigPath
	ConfigPath string

	// Success Ratio
	SuccessRatio float64

	// Success Seed
	SuccessSeed string
}

FlagArgsStruct : a struct of args

type FlagValues

type FlagValues []string

FlagValues : for multi values

func (*FlagValues) Set

func (p *FlagValues) Set(v string) error

Set : implement for `flag.Value`

func (*FlagValues) String

func (p *FlagValues) String() string

String : implement for `flag.Value`

type ModulesConfig

type ModulesConfig struct {
	GitServer gitserver.Config `toml:"gitserver"`
}

type StringSet

type StringSet map[string]struct{}

func NewStringSet

func NewStringSet(xs ...string) StringSet

func (StringSet) Add

func (s StringSet) Add(str string)

func (StringSet) Clone

func (s StringSet) Clone() StringSet

func (StringSet) Contains

func (s StringSet) Contains(x string) bool

func (StringSet) ContainsAll

func (s StringSet) ContainsAll(xs ...string) bool

func (StringSet) ContainsOne

func (s StringSet) ContainsOne(xs ...string) bool

func (StringSet) Equals

func (s StringSet) Equals(other StringSet) bool

func (StringSet) ForEach

func (s StringSet) ForEach(fn func(string) error) error

func (StringSet) Keys

func (s StringSet) Keys() []string

func (StringSet) Len

func (s StringSet) Len() int

func (StringSet) Remove

func (s StringSet) Remove(str string)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL