conf

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: MIT Imports: 12 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"
)
View Source
const DefaultHardMaxConnections = 65535
View Source
const DefaultHardMaxSucessConnections = 10
View Source
const DefaultMaxConnections = 100
View Source
const DefaultMaxSuccessConnections = 5

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(f *flag.FlagSet, 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)

func (*AppConfig) FillDefault added in v0.5.0

func (c *AppConfig) FillDefault()

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"`

		RateLimits []*RateLimitConfig `toml:"rate_limit"`

		Users []*User `toml:"users"`

		MaxConn     MaxConnectionsConfig `toml:"max_conn"`
		MaxSuccConn MaxConnectionsConfig `toml:"max_succ_conn"`
	} `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

	// Rate Limit
	RateLimits []string

	// Users
	Users []string

	// Max connections
	MaxConns string

	// Max success connections
	MaxSuccConns string

	// Module Options
	Options []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 MaxConnectionsConfig added in v0.4.2

type MaxConnectionsConfig struct {
	Max       int     `toml:"max"`
	HardMax   int     `toml:"hard_max,omitempty"`
	LossRatio float64 `toml:"loss_ratio,omitempty"`
}

type ModulesConfig

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

func (*ModulesConfig) FillDefault added in v0.5.0

func (c *ModulesConfig) FillDefault()

type RateLimitConfig added in v0.4.0

type RateLimitConfig = utils.RateLimitConfig

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)

type User added in v0.4.2

type User struct {
	User     string `toml:"user"`
	Password string `toml:"password"`
}

Jump to

Keyboard shortcuts

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