Help us shape the future of Go! Take the 2026 Go Developer Survey

configs

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Sqlite - SQLite protocol
	Sqlite = "sqlite3"
	// Postgres - Postgresql protocol
	Postgres = "postgresql"
	// MySQL - MySQL protocol
	MySQL = "mysql"
)
View Source
const (
	DefaultChromeBaseVer = 106
	DefaultMacOSVer      = "10_15_7"
)

Variables

View Source
var (
	ServerConfigFileName        = "config.yaml"
	ServerRootPath              = files.GetExcPath() + ".malice"
	CurrentServerConfigFilename = "config.yaml"
	LogPath                     = path.Join(ServerRootPath, "logs")
	CertsPath                   = path.Join(ServerRootPath, "certs")
	ListenerPath                = path.Join(ServerRootPath, "listener")
	TempPath                    = path.Join(ServerRootPath, "temp")
	PluginPath                  = path.Join(ServerRootPath, "plugins")
	AuditPath                   = path.Join(ServerRootPath, "audit")
	CachePath                   = path.Join(TempPath, "cache")
	ErrNoConfig                 = errors.New("no config found")
	WebsitePath                 = path.Join(ServerRootPath, "web")
)
View Source
var (
	// ErrInvalidDialect - An invalid dialect was specified
	ErrInvalidDialect = errors.New("invalid SQL Dialect")
)
View Source
var ListenerConfigFileName = "listener.yaml"

Functions

func InitConfig

func InitConfig() error

func InitDefaultConfig added in v0.0.2

func InitDefaultConfig(cfg interface{}, indentLevel int) []byte

func LoadConfig

func LoadConfig(filename string, v interface{}) error

func LoadMiscConfig

func LoadMiscConfig() ([]byte, []byte, error)

func NewDebugLog

func NewDebugLog(filename string) *logs.Logger

func NewFileLog

func NewFileLog(filename string) *logs.Logger

Types

type DatabaseConfig

type DatabaseConfig struct {
	Dialect  string `json:"dialect"`
	Database string `json:"database"`
	Username string `json:"username"`
	Password string `json:"password"`
	Host     string `json:"host"`
	Port     uint16 `json:"port"`

	Params map[string]string `json:"params"`

	MaxIdleConns int `json:"max_idle_conns"`
	MaxOpenConns int `json:"max_open_conns"`

	LogLevel string `json:"log_level"`
}

DatabaseConfig - Server config

func GetDatabaseConfig

func GetDatabaseConfig() *DatabaseConfig

GetDatabaseConfig - Get config value

func (*DatabaseConfig) DSN

func (c *DatabaseConfig) DSN() (string, error)

DSN - Get the db connections string https://github.com/go-sql-driver/mysql#examples

func (*DatabaseConfig) Save added in v0.0.2

func (c *DatabaseConfig) Save() error

Save - Save config file to disk

type EncryptionConfig

type EncryptionConfig struct {
	Enable bool   `config:"enable"`
	Type   string `config:"type"`
	Key    string `config:"key"`
}

type HttpPipelineConfig

type HttpPipelineConfig struct {
	Enable    bool       `config:"enable" default:"false"`
	Name      string     `config:"name" default:"http"`
	Host      string     `config:"host" default:"0.0.0.0"`
	Port      uint16     `config:"port" default:"8443"`
	TlsConfig *TlsConfig `config:"tls" default:""`
}

type ListenerConfig

type ListenerConfig struct {
	Enable       bool                 `config:"enable" default:"true"`
	Name         string               `config:"name" default:"listener"`
	Auth         string               `config:"auth" default:"listener.auth"`
	TcpPipelines []*TcpPipelineConfig `config:"tcp" default:""`
	//HttpPipelines []*HttpPipelineConfig `config:"http" default:""`
	Websites []*WebsiteConfig `config:"websites" default:""`
}

func GetListenerConfig

func GetListenerConfig() *ListenerConfig

type LogConfig

type LogConfig struct {
	Level int `json:"level" default:"20" config:"level"`
}

LogConfig - Server logging config

type MiscConfig

type MiscConfig struct {
	PacketLength int    `config:"packet_length" default:"4194304"`
	Certificate  string `config:"cert" default:""`
	PrivateKey   string `config:"key" default:""`
}

type NotifyConfig added in v0.0.2

type NotifyConfig struct {
	Enable   bool `config:"enable" default:"true"`
	Telegram struct {
		Enable bool   `config:"enable" default:"false"`
		APIKey string `config:"api_key"`
		ChatID int64  `config:"chat_id"`
	} `config:"telegram"`
	DingTalk struct {
		Enable bool   `config:"enable" default:"false"`
		Secret string `config:"secret"`
		Token  string `config:"token"`
	} `config:"dingtalk"`
	Lark struct {
		Enable     bool   `config:"enable" default:"false"`
		WebHookUrl string `config:"webhook_url"`
	} `config:"lark"`
	ServerChan struct {
		Enable       bool                `config:"enable" default:"false"`
		URL          string              `config:"url"`
		Method       string              `config:"method"`
		Headers      map[string][]string `config:"headers"`
		ContentType  string              `config:"content_type"`
		BodyTemplate string              `config:"bodyTemplate"`
	} `config:"serverchan"`
}

type ServerConfig

type ServerConfig struct {
	Enable       bool          `config:"enable" default:"true"`
	GRPCPort     uint16        `config:"grpc_port" default:"5004"`
	GRPCHost     string        `config:"grpc_host" default:"0.0.0.0"`
	IP           string        `config:"ip" default:""`
	DaemonConfig bool          `config:"daemon" default:"false"`
	LogConfig    *LogConfig    `config:"log" default:""`
	MiscConfig   *MiscConfig   `config:"config" default:""`
	NotifyConfig *NotifyConfig `config:"notify" default:""`
}

func GetServerConfig

func GetServerConfig() *ServerConfig

func (*ServerConfig) Address

func (c *ServerConfig) Address() string

func (*ServerConfig) Save

func (c *ServerConfig) Save() error

type TcpPipelineConfig

type TcpPipelineConfig struct {
	Enable           bool              `config:"enable" default:"false"`
	Name             string            `config:"name" default:"tcp"`
	Host             string            `config:"host" default:"0.0.0.0"`
	Port             uint16            `config:"port" default:"5001"`
	TlsConfig        *TlsConfig        `config:"tls" default:""`
	EncryptionConfig *EncryptionConfig `config:"encryption" default:""`
}

type TlsConfig

type TlsConfig struct {
	Enable   bool   `config:"enable"`
	Name     string `config:"name"`
	CN       string `config:"CN"`
	O        string `config:"O"`
	C        string `config:"C"`
	L        string `config:"L"`
	OU       string `config:"OU"`
	ST       string `config:"ST"`
	Validity string `config:"validity"`
	CertFile string `config:"cert"`
	KeyFile  string `config:"key"`
}

func GenerateTlsConfig added in v0.0.2

func GenerateTlsConfig(name string) TlsConfig

func (*TlsConfig) ToPkix

func (t *TlsConfig) ToPkix() *pkix.Name

func (*TlsConfig) ToProtobuf added in v0.0.2

func (t *TlsConfig) ToProtobuf() *lispb.TLS

type WebsiteConfig

type WebsiteConfig struct {
	Enable      bool       `config:"enable" default:"false"`
	RootPath    string     `config:"root" default:"."`
	WebsiteName string     `config:"name" default:"web"`
	Port        uint16     `config:"port" default:"443"`
	ContentPath string     `config:"content_path" default:""`
	TlsConfig   *TlsConfig `config:"tls" default:""`
}

Jump to

Keyboard shortcuts

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