Documentation ¶
Overview ¶
Nging is a toolbox for webmasters Copyright (C) 2018-present Wenhui Shen <swh@admpub.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
Index ¶
- Constants
- Variables
- func AddDaemon(p *dbschema.NgingForeverProcess, run ...bool) *goforever.Process
- func ConnectDB(c *Config) error
- func ConnectMongoDB(c *Config) error
- func ConnectMySQL(c *Config) error
- func CreaterMySQL(err error, c *Config) error
- func DaemonCommonHook(p *goforever.Process)
- func ExecMySQL(sqlStr string) error
- func FireInitSettings(configs echo.H) error
- func FireSetSettings(group string, diffs Diffs) error
- func GetPreupgradeSQLFiles() []string
- func GetSQLInsertFiles() []string
- func GetSQLInstallFiles() ([]string, error)
- func InitSessionOptions(c *Config)
- func IsInstalled() bool
- func MustOK(err error)
- func OnExitedDaemon(processM *dbschema.NgingForeverProcess)
- func OnGroupSetSettings(groupAndKey string, fn func(Diffs) error)
- func OnKeySetSettings(groupAndKey string, fn func(Diff) error)
- func OnceUpgradeDB() error
- func ParseArgsSlice(a string) []string
- func ParseConfig() error
- func ParseEnvSlice(a string) []string
- func ParseTimeDuration(timeout string) time.Duration
- func QueryTo(sqlStr string, result interface{}) (sqlbuilder.Iterator, error)
- func RestartDaemon()
- func RunDaemon()
- func SetInstalled(lockFile string) error
- func Table(table string) string
- func ToTable(m sqlbuilder.Name_) string
- func UpgradeDB()
- func WatchConfig(fn func(string) error)
- type CLIConfig
- func (c *CLIConfig) CaddyReload() error
- func (c *CLIConfig) CaddyRestart(writer ...io.Writer) error
- func (c *CLIConfig) CaddyStart(writer ...io.Writer) (err error)
- func (c *CLIConfig) CaddyStop() error
- func (c *CLIConfig) CaddyStopHistory() (err error)
- func (c *CLIConfig) Close() error
- func (c *CLIConfig) CmdGet(typeName string) *exec.Cmd
- func (c *CLIConfig) CmdGroupStop(groupName string) error
- func (c *CLIConfig) CmdHasGroup(groupName string) bool
- func (c *CLIConfig) CmdSendSignal(typeName string, sig os.Signal) error
- func (c *CLIConfig) CmdSet(name string, cmd *exec.Cmd)
- func (c *CLIConfig) CmdStop(typeName string) error
- func (c *CLIConfig) FRPClientRestart(writer ...io.Writer) error
- func (c *CLIConfig) FRPClientRestartID(id string, writer ...io.Writer) error
- func (c *CLIConfig) FRPClientStart(writer ...io.Writer) (err error)
- func (c *CLIConfig) FRPClientStartID(id uint, writer ...io.Writer) (err error)
- func (c *CLIConfig) FRPClientStop() error
- func (c *CLIConfig) FRPClientStopHistory(ids ...string) (err error)
- func (c *CLIConfig) FRPClientStopID(id string) error
- func (c *CLIConfig) FRPConfigFile(id uint, isServer bool) string
- func (c *CLIConfig) FRPPidFile(id string, isServer bool) string
- func (c *CLIConfig) FRPRebuildConfigFile(data interface{}, configFiles ...string) error
- func (c *CLIConfig) FRPRestart(writer ...io.Writer) error
- func (c *CLIConfig) FRPRestartID(id string, writer ...io.Writer) error
- func (c *CLIConfig) FRPSaveConfigFile(data interface{}) (err error)
- func (c *CLIConfig) FRPStart(writer ...io.Writer) (err error)
- func (c *CLIConfig) FRPStartID(id uint, writer ...io.Writer) (err error)
- func (c *CLIConfig) FRPStop() error
- func (c *CLIConfig) FRPStopHistory(ids ...string) (err error)
- func (c *CLIConfig) FRPStopID(id string) error
- func (c *CLIConfig) FTPRestart(writer ...io.Writer) error
- func (c *CLIConfig) FTPStart(writer ...io.Writer) (err error)
- func (c *CLIConfig) FTPStop() error
- func (c *CLIConfig) FTPStopHistory() (err error)
- func (c *CLIConfig) GenerateIDFromConfigFileName(configFile string, musts ...bool) string
- func (c *CLIConfig) InitEnviron(needFindEnvFile ...bool) (err error)
- func (c *CLIConfig) InitFlag(flagSet *pflag.FlagSet)
- func (c *CLIConfig) IsRunning(ct string) bool
- func (c *CLIConfig) Kill(cmd *exec.Cmd) error
- func (c *CLIConfig) MustFRPRebuildConfigFile(data interface{}, configFiles ...string) error
- func (c *CLIConfig) OnlyRunServer() bool
- func (c *CLIConfig) ParseConfig()
- func (c *CLIConfig) Pid() int
- func (c *CLIConfig) Reload(cfg *Config, cts ...string) error
- func (c *CLIConfig) RunStartup()
- func (c *CLIConfig) SendSignal(cmd *exec.Cmd, sig os.Signal) error
- func (c *CLIConfig) SetLogWriter(cmdType string, writer ...io.Writer) error
- func (c *CLIConfig) WatchEnvConfig()
- type Config
- func (c *Config) APIKey() string
- func (c *Config) AsDefault()
- func (c *Config) Codec(lengths ...int) codec.Codec
- func (c *Config) ConfigFromDB() echo.H
- func (c *Config) ConnectedDB(autoConn ...bool) bool
- func (c *Config) CookieConfig() scookie.Config
- func (c *Config) Decode(encrypted string, keys ...string) string
- func (c *Config) Encode(raw string, keys ...string) string
- func (c *Config) GenerateRandomKey() string
- func (c *Config) GenerateSample() error
- func (c *Config) GetMaxRequestBodySize() int
- func (c *Config) InitExtend() *Config
- func (c *Config) InitSecretKey() *Config
- func (c *Config) IsEnv(env string) bool
- func (c *Config) IsEnvDev() bool
- func (c *Config) IsEnvProd() bool
- func (c *Config) Reload(newConfig *Config) error
- func (c *Config) SaveToFile() error
- func (c *Config) SetDebug(on bool) *Config
- func (c *Config) SetDefaults(configFile string)
- type DBOperators
- type Diff
- type Diffs
- type Email
- type Log
- type Navigation
- type ReloadByConfig
- type Settings
- func (c *Settings) GetConfig() echo.H
- func (c *Settings) Init(ctx echo.Context) error
- func (c *Settings) SetBy(r echo.H, defaults echo.H) *Settings
- func (c *Settings) SetConfig(group string, ngingConfig echo.H, defaults echo.H)
- func (c *Settings) SetConfigs(ctx echo.Context, groups ...string) error
- func (c *Settings) SetDebug(on bool)
- type VersionInfo
Constants ¶
const FRPConfigExtension = `.json` //`.yaml`
Variables ¶
var ( EmptyBytes = []byte{} ErrNoAvailibaleConfigFound = errors.New(`no available configurations found`) )
var ( Daemon = goforever.Default DaemonDefaultHook = DaemonCommonHook )
var ( Installed sql.NullBool DefaultConfig *Config DefaultCLIConfig = NewCLIConfig() OAuthUserSessionKey = `oauthUser` ErrUnknowDatabaseType = errors.New(`unkown database type`) )
var ( SessionOptions *echo.SessionOptions CookieOptions *cookie.CookieOptions SessionEngine = `file` SessionName = `SID` )
var ( DBConnecters = map[string]func(*Config) error{ `mysql`: ConnectMySQL, `mongo`: ConnectMongoDB, } DBInstallers = map[string]func(string) error{ `mysql`: ExecMySQL, } DBCreaters = map[string]func(error, *Config) error{ `mysql`: CreaterMySQL, } DBUpgraders = map[string]func(string, *sync.Config, *Config) (DBOperators, error){ `mysql`: UpgradeMySQL, } DBEngines = echo.NewKVData().Add(`mysql`, `MySQL`) )
var CmdIsRunning = com.CmdIsRunning
var DefaultLogCategories = []string{`db`, `echo,mock`}
var DefaultPort = 9999
var DefaultStartup = `webserver,task,daemon,ftpserver,frpserver,frpclient`
var ErrCmdNotRunning = errors.New(`command is not running`)
var Setting = common.Setting
var Version = &VersionInfo{Name: `Nging`}
Version 版本信息
Functions ¶
func ConnectMongoDB ¶
func ConnectMySQL ¶
func CreaterMySQL ¶
func DaemonCommonHook ¶
func FireInitSettings ¶
func FireSetSettings ¶
func GetPreupgradeSQLFiles ¶
func GetPreupgradeSQLFiles() []string
func GetSQLInsertFiles ¶
func GetSQLInsertFiles() []string
func GetSQLInstallFiles ¶
func InitSessionOptions ¶
func InitSessionOptions(c *Config)
func IsInstalled ¶
func IsInstalled() bool
func OnExitedDaemon ¶
func OnExitedDaemon(processM *dbschema.NgingForeverProcess)
OnExitedDaemon 当值守程序达到最大重试次数退出时
func OnGroupSetSettings ¶ added in v3.6.2
func OnKeySetSettings ¶ added in v3.6.2
func OnceUpgradeDB ¶
func OnceUpgradeDB() error
func ParseArgsSlice ¶
func ParseConfig ¶
func ParseConfig() error
func ParseEnvSlice ¶
func ParseTimeDuration ¶
func SetInstalled ¶
func ToTable ¶
func ToTable(m sqlbuilder.Name_) string
func WatchConfig ¶
Types ¶
type CLIConfig ¶
type CLIConfig struct { BackendDomain string //后台绑定域名 FrontendDomain string //前台绑定域名 Address string //监听IP地址 Port int //监听端口 Conf string Confx string Type string //启动类型: webserver/ftpserver/manager Startup string //manager启动时同时启动的服务,可选的有webserver/ftpserver,如有多个需用半角逗号“,”隔开 // contains filtered or unexported fields }
func NewCLIConfig ¶
func NewCLIConfig() *CLIConfig
func (*CLIConfig) CaddyReload ¶
func (*CLIConfig) CaddyStopHistory ¶
func (*CLIConfig) CmdGroupStop ¶
func (*CLIConfig) CmdHasGroup ¶
func (*CLIConfig) CmdSendSignal ¶
func (*CLIConfig) FRPClientRestart ¶
func (*CLIConfig) FRPClientRestartID ¶
func (*CLIConfig) FRPClientStart ¶
func (*CLIConfig) FRPClientStartID ¶
func (*CLIConfig) FRPClientStop ¶
func (*CLIConfig) FRPClientStopHistory ¶
func (*CLIConfig) FRPClientStopID ¶
func (*CLIConfig) FRPRebuildConfigFile ¶
func (*CLIConfig) FRPRestartID ¶
func (*CLIConfig) FRPSaveConfigFile ¶
func (*CLIConfig) FRPStartID ¶
func (*CLIConfig) FRPStopHistory ¶
func (*CLIConfig) FTPStopHistory ¶
func (*CLIConfig) GenerateIDFromConfigFileName ¶
func (*CLIConfig) InitEnviron ¶ added in v3.6.2
func (*CLIConfig) MustFRPRebuildConfigFile ¶
func (*CLIConfig) OnlyRunServer ¶
func (*CLIConfig) ParseConfig ¶
func (c *CLIConfig) ParseConfig()
func (*CLIConfig) SetLogWriter ¶
func (*CLIConfig) WatchEnvConfig ¶ added in v3.6.2
func (c *CLIConfig) WatchEnvConfig()
type Config ¶
type Config struct { DB sdb.DB `json:"db"` Sys ssystem.System `json:"sys"` Cron scron.Cron `json:"cron"` Cookie scookie.Config `json:"cookie"` Caddy caddy.Config `json:"caddy"` FTP ftp.Config `json:"ftp"` Language language.Config `json:"language"` Download struct { SavePath string `json:"savePath"` } `json:"download"` //License lib.LicenseData `json:"license,omitempty"` Extend echo.H `json:"extend,omitempty"` *Settings `json:"-"` // contains filtered or unexported fields }
func InitConfig ¶
func (*Config) ConfigFromDB ¶
func (*Config) ConnectedDB ¶
ConnectedDB 数据库是否已连接,如果没有连接则自动连接
func (*Config) CookieConfig ¶
func (*Config) GenerateRandomKey ¶
func (*Config) GenerateSample ¶ added in v3.5.7
func (*Config) GetMaxRequestBodySize ¶
func (*Config) InitExtend ¶
func (*Config) InitSecretKey ¶
func (*Config) SaveToFile ¶
func (*Config) SetDefaults ¶ added in v3.6.3
type DBOperators ¶
type DBOperators struct { Source sync.DBOperator Destination sync.DBOperator }
func UpgradeMySQL ¶
type Email ¶
type Log ¶
type Log struct { Debug bool `json:"debug"` Colorable bool `json:"colorable"` // for console SaveFile string `json:"saveFile"` // for file FileMaxBytes int64 `json:"fileMaxBytes"` // for file Targets string `json:"targets" form_delimiter:","` Categories []string `json:"cagegories"` }
func (*Log) LogCategories ¶ added in v3.6.3
type ReloadByConfig ¶
type Settings ¶
type Settings struct { Email Email `json:"email"` Log Log `json:"log"` APIKey string `json:"-"` //API密钥 Debug bool `json:"debug"` MaxRequestBodySize int `json:"maxRequestBodySize"` Base echo.H `json:"base"` // contains filtered or unexported fields }
func NewSettings ¶
func (*Settings) SetConfigs ¶
type VersionInfo ¶
type VersionInfo struct { Name string //软件名称 Number string //版本号 1.0.1 Package string //套餐 Label string //版本标签 beta/alpha/stable DBSchema float64 //数据库表版本 例如:1.2 BuildTime string //构建时间 BuildOS string //构建目标系统 BuildArch string //构建目标架构 CommitID string //GIT提交ID Licensed bool //是否已授权 Expired time.Time //过期时间 }
func (*VersionInfo) IsExpired ¶
func (v *VersionInfo) IsExpired() bool
func (*VersionInfo) String ¶
func (v *VersionInfo) String() string
func (*VersionInfo) VString ¶
func (v *VersionInfo) VString() string