model

package
v2.0.4+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2019 License: AGPL-3.0 Imports: 30 Imported by: 0

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/>.

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/>.

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/>.

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/>.

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/>.

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/>.

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/>.

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/>.

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/>.

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/>.

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/>.

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/>.

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

This section is empty.

Variables

View Source
var (
	// SMSWaitingSeconds 短信发送后等待秒数
	SMSWaitingSeconds int64 = 60
	// SMSMaxPerDay 短信每人每天发送上限
	SMSMaxPerDay int64 = 10
)
View Source
var (
	ErrNoneFtpDirectory = errors.New(`No accessible directory`)
	ErrBannedFtpUser    = errors.New(`The current account has been disabled`)
)
View Source
var CaddyLogRegexpList = sync.Map{}
View Source
var (
	Decode = func(r string) string { return r }
)
View Source
var DefaultSalt = ``

Functions

This section is empty.

Types

type AccessLog

type AccessLog struct {
	*dbschema.AccessLog
	// contains filtered or unexported fields
}

func NewAccessLog

func NewAccessLog(ctx echo.Context) *AccessLog

func (*AccessLog) Parse

func (l *AccessLog) Parse(line string, args ...interface{}) (err error)

Parse 解析单行字符串到日志对象

func (*AccessLog) ToLite

func (m *AccessLog) ToLite() *AccessLogLite

func (*AccessLog) ToMap

func (m *AccessLog) ToMap() echo.Store

type AccessLogLite

type AccessLogLite struct {
	Date   string
	OS     string
	Brower string
	Region string
	Type   string

	Version string
	User    string
	Method  string
	Scheme  string
	URI     string

	Referer string

	BodyBytes  uint64
	Elapsed    float64
	StatusCode uint
	UserAgent  string
}

type Code

type Code struct {
	Verification *dbschema.CodeVerification
	Invitation   *dbschema.CodeInvitation
	*base.Base
}

func NewCode

func NewCode(ctx echo.Context) *Code

func (*Code) AddVerificationCode

func (c *Code) AddVerificationCode() (interface{}, error)

func (*Code) CheckFrequency

func (c *Code) CheckFrequency(ownerID uint64, ownerType string, sendMethod string, frequencyCfg echo.H) error

func (*Code) CheckVerificationCode

func (c *Code) CheckVerificationCode(code string, purpose string, ownerID uint64, ownerType string, sendMethod string, sendTo string) (err error)

func (*Code) CountTodayVerificationCode

func (c *Code) CountTodayVerificationCode(ownerID uint64, ownerType string, sendMethod string) (int64, error)

func (*Code) LastVerificationCode

func (c *Code) LastVerificationCode(ownerID uint64, ownerType string, sendMethod string) (err error)

func (*Code) UseInvitationCode

func (c *Code) UseInvitationCode(m *dbschema.CodeInvitation, usedUid uint) (err error)

func (*Code) UseVerificationCode

func (c *Code) UseVerificationCode(m *dbschema.CodeVerification) (err error)

func (*Code) VerfyInvitationCode

func (c *Code) VerfyInvitationCode(code string) (err error)

type CollectorExport

type CollectorExport struct {
	*dbschema.CollectorExport
	*base.Base
}

func NewCollectorExport

func NewCollectorExport(ctx echo.Context) *CollectorExport

func (*CollectorExport) Add

func (c *CollectorExport) Add() (pk interface{}, err error)

func (*CollectorExport) Edit

func (c *CollectorExport) Edit(mw func(db.Result) db.Result, args ...interface{}) error

func (*CollectorExport) Export

func (c *CollectorExport) Export() (int64, error)

type CollectorExportAndGroup

type CollectorExportAndGroup struct {
	*dbschema.CollectorExport
	Group *dbschema.CollectorGroup
}

type CollectorGroup

type CollectorGroup struct {
	*dbschema.CollectorGroup
	*base.Base
}

func NewCollectorGroup

func NewCollectorGroup(ctx echo.Context) *CollectorGroup

type CollectorHistory

type CollectorHistory struct {
	*dbschema.CollectorHistory
	*base.Base
}

func NewCollectorHistory

func NewCollectorHistory(ctx echo.Context) *CollectorHistory

func (*CollectorHistory) Delete

func (this *CollectorHistory) Delete(mw func(db.Result) db.Result, args ...interface{}) error

func (*CollectorHistory) Reset

func (c *CollectorHistory) Reset() *CollectorHistory

type CollectorPage

type CollectorPage struct {
	*dbschema.CollectorPage
	*base.Base
}

func NewCollectorPage

func NewCollectorPage(ctx echo.Context) *CollectorPage

func (*CollectorPage) FullData

func (c *CollectorPage) FullData() (*exec.Rules, error)

type CollectorPageAndGroup

type CollectorPageAndGroup struct {
	*dbschema.CollectorPage
	Group *dbschema.CollectorGroup
}

type CollectorRule

type CollectorRule struct {
	*dbschema.CollectorRule
	*base.Base
}

func NewCollectorRule

func NewCollectorRule(ctx echo.Context) *CollectorRule

type Command

type Command struct {
	*dbschema.Command
	*base.Base
}

func NewCommand

func NewCommand(ctx echo.Context) *Command

func (*Command) CreateCmd

func (u *Command) CreateCmd() *exec.Cmd

func (*Command) Exists

func (u *Command) Exists(name string) (bool, error)

func (*Command) Exists2

func (u *Command) Exists2(name string, excludeID uint) (bool, error)

type Config

type Config struct {
	*dbschema.Config
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig(ctx echo.Context) *Config

func (*Config) Add

func (f *Config) Add() (pk interface{}, err error)

func (*Config) Edit

func (f *Config) Edit(mw func(db.Result) db.Result, args ...interface{}) error

func (*Config) EditByPK

func (f *Config) EditByPK(mw func(db.Result) db.Result, group string, key string) error

func (*Config) ListAllMapByGroup

func (f *Config) ListAllMapByGroup() (echo.H, error)

func (*Config) ListByGroup

func (f *Config) ListByGroup(group string) (func() int64, error)

func (*Config) ListMapByGroup

func (f *Config) ListMapByGroup(group string) (echo.H, error)

func (*Config) Upsert

func (f *Config) Upsert() (pk interface{}, err error)

func (*Config) ValueByKey

func (f *Config) ValueByKey(group, key string) string

type DbAccount added in v1.3.0

type DbAccount struct {
	*dbschema.DbAccount
	*base.Base
}

func NewDbAccount added in v1.3.0

func NewDbAccount(ctx echo.Context) *DbAccount

func (*DbAccount) Add added in v1.3.0

func (a *DbAccount) Add() (interface{}, error)

func (*DbAccount) Edit added in v1.3.0

func (a *DbAccount) Edit(id uint, mw func(db.Result) db.Result, args ...interface{}) error

func (*DbAccount) SetOptions

func (a *DbAccount) SetOptions() error

type DbSync

type DbSync struct {
	*dbschema.DbSync
	*base.Base
}

func NewDbSync

func NewDbSync(ctx echo.Context) *DbSync

func (*DbSync) Add

func (a *DbSync) Add() (interface{}, error)

func (*DbSync) Edit

func (a *DbSync) Edit(mw func(db.Result) db.Result, args ...interface{}) error

func (*DbSync) HidePassword

func (a *DbSync) HidePassword(dsn string) string

func (*DbSync) ParseDSN

func (a *DbSync) ParseDSN(dsn string) (user string, pwd string, host string, dbName string)

func (*DbSync) ToDSN

func (a *DbSync) ToDSN(user, pwd, host, db string) string

type DbSyncLog

type DbSyncLog struct {
	*dbschema.DbSyncLog
	*base.Base
}

func NewDbSyncLog

func NewDbSyncLog(ctx echo.Context) *DbSyncLog

func (*DbSyncLog) Add

func (a *DbSyncLog) Add() (interface{}, error)

func (*DbSyncLog) Edit

func (a *DbSyncLog) Edit(mw func(db.Result) db.Result, args ...interface{}) error

type ForeverProcess

type ForeverProcess struct {
	*dbschema.ForeverProcess
	*base.Base
}

func NewForeverProcess

func NewForeverProcess(ctx echo.Context) *ForeverProcess

func (*ForeverProcess) Add

func (u *ForeverProcess) Add() (pk interface{}, err error)

func (*ForeverProcess) ArgsSlice

func (u *ForeverProcess) ArgsSlice() []string

func (*ForeverProcess) Edit

func (u *ForeverProcess) Edit(mw func(db.Result) db.Result, args ...interface{}) error

func (*ForeverProcess) EnvSlice

func (u *ForeverProcess) EnvSlice() []string

func (*ForeverProcess) Exists

func (u *ForeverProcess) Exists(name string) (bool, error)

func (*ForeverProcess) Exists2

func (u *ForeverProcess) Exists2(name string, excludeID uint) (bool, error)

type FrpClient

type FrpClient struct {
	*dbschema.FrpClient
	*base.Base
}

func NewFrpClient

func NewFrpClient(ctx echo.Context) *FrpClient

func (*FrpClient) Exists

func (f *FrpClient) Exists(name string, excludeIds ...uint) (bool, error)

type FrpClientAndGroup

type FrpClientAndGroup struct {
	*dbschema.FrpClient
	Group   *dbschema.FrpGroup
	Running bool
}

type FrpGroup

type FrpGroup struct {
	*dbschema.FrpGroup
	*base.Base
}

func NewFrpGroup

func NewFrpGroup(ctx echo.Context) *FrpGroup

func (*FrpGroup) Exists

func (f *FrpGroup) Exists(name string) (bool, error)

func (*FrpGroup) ExistsOther

func (f *FrpGroup) ExistsOther(name string, id uint) (bool, error)

type FrpServer

type FrpServer struct {
	*dbschema.FrpServer
	*base.Base
}

func NewFrpServer

func NewFrpServer(ctx echo.Context) *FrpServer

func (*FrpServer) Exists

func (f *FrpServer) Exists(name string, excludeIds ...uint) (bool, error)

type FrpServerAndGroup

type FrpServerAndGroup struct {
	*dbschema.FrpServer
	Group   *dbschema.FrpGroup
	Running bool
}

type FtpUser

type FtpUser struct {
	*dbschema.FtpUser
	*base.Base
}

func NewFtpUser

func NewFtpUser(ctx echo.Context) *FtpUser

func (*FtpUser) CheckPasswd

func (f *FtpUser) CheckPasswd(username string, password string) (bool, error)

func (*FtpUser) Exists

func (f *FtpUser) Exists(username string) (bool, error)

func (*FtpUser) RootPath

func (f *FtpUser) RootPath(username string) (basePath string, err error)

type FtpUserAndGroup

type FtpUserAndGroup struct {
	*dbschema.FtpUser
	Group *dbschema.FtpUserGroup
}

type FtpUserGroup

type FtpUserGroup struct {
	*dbschema.FtpUserGroup
	*base.Base
}

func NewFtpUserGroup

func NewFtpUserGroup(ctx echo.Context) *FtpUserGroup

func (*FtpUserGroup) Exists

func (f *FtpUserGroup) Exists(name string) (bool, error)

func (*FtpUserGroup) ExistsOther

func (f *FtpUserGroup) ExistsOther(name string, id uint) (bool, error)

func (*FtpUserGroup) ListByActive

func (f *FtpUserGroup) ListByActive(page int, size int) (func() int64, []*dbschema.FtpUserGroup, error)

type Invitation

type Invitation struct {
	*dbschema.CodeInvitation
	*base.Base
}

func NewInvitation

func NewInvitation(ctx echo.Context) *Invitation

func (*Invitation) Exists

func (u *Invitation) Exists(code string) (bool, error)

func (*Invitation) Exists2

func (u *Invitation) Exists2(code string, excludeID uint) (bool, error)

type SendingLog

type SendingLog struct {
	*dbschema.SendingLog
	*base.Base
}

func NewSendingLog

func NewSendingLog(ctx echo.Context) *SendingLog

func (*SendingLog) Add

func (c *SendingLog) Add() (interface{}, error)

type SshUser

type SshUser struct {
	*dbschema.SshUser
	*base.Base
}

func NewSshUser

func NewSshUser(ctx echo.Context) *SshUser

func (*SshUser) Connect

func (s *SshUser) Connect(reader io.Reader, writer io.Writer) error

func (*SshUser) ExecMultiCMD

func (s *SshUser) ExecMultiCMD(writer io.Writer, commands ...string) error

type SshUserAndGroup

type SshUserAndGroup struct {
	*dbschema.SshUser
	Group *dbschema.SshUserGroup
}

type SshUserGroup

type SshUserGroup struct {
	*dbschema.SshUserGroup
	*base.Base
}

func NewSshUserGroup

func NewSshUserGroup(ctx echo.Context) *SshUserGroup

func (*SshUserGroup) Exists

func (f *SshUserGroup) Exists(name string) (bool, error)

func (*SshUserGroup) ExistsOther

func (f *SshUserGroup) ExistsOther(name string, id uint) (bool, error)

type Task

type Task struct {
	*dbschema.Task
	*base.Base
}

func NewTask

func NewTask(ctx echo.Context) *Task

type TaskAndGroup

type TaskAndGroup struct {
	*dbschema.Task
	Group *dbschema.TaskGroup
}

type TaskGroup

type TaskGroup struct {
	*dbschema.TaskGroup
	*base.Base
}

func NewTaskGroup

func NewTaskGroup(ctx echo.Context) *TaskGroup

type TaskLog

type TaskLog struct {
	*dbschema.TaskLog
	*base.Base
}

func NewTaskLog

func NewTaskLog(ctx echo.Context) *TaskLog

type User

type User struct {
	*dbschema.User
	*base.Base
}

func NewUser

func NewUser(ctx echo.Context) *User

func (*User) Add

func (u *User) Add() (err error)

func (*User) CheckPasswd

func (u *User) CheckPasswd(username string, password string) (exists bool, err error)

func (*User) ClearPasswordData

func (u *User) ClearPasswordData(users ...*dbschema.User) dbschema.User

func (*User) Exists

func (u *User) Exists(username string) (bool, error)

func (*User) Exists2

func (u *User) Exists2(username string, excludeUID uint) (bool, error)

func (*User) GetUserAllU2F

func (u *User) GetUserAllU2F(uid uint) ([]*dbschema.UserU2f, error)

func (*User) NeedCheckU2F

func (u *User) NeedCheckU2F(uid uint) bool

func (*User) Register

func (u *User) Register(user, pass, email string) error

func (*User) SetSession

func (u *User) SetSession(users ...*dbschema.User)

func (*User) U2F

func (u *User) U2F(uid uint, typ string) (u2f *dbschema.UserU2f, err error)

func (*User) UnsetSession

func (u *User) UnsetSession()

func (*User) UpdateField

func (u *User) UpdateField(uid uint, set map[string]interface{}) (err error)

func (*User) VerifySession

func (u *User) VerifySession(users ...*dbschema.User) error

type UserRole

type UserRole struct {
	*dbschema.UserRole
	*base.Base
	// contains filtered or unexported fields
}

func NewUserRole

func NewUserRole(ctx echo.Context) *UserRole

func (*UserRole) CheckCmdPerm

func (u *UserRole) CheckCmdPerm(permPath string) bool

func (*UserRole) CheckCmdPerm2

func (u *UserRole) CheckCmdPerm2(roleList []*dbschema.UserRole, perm string) (hasPerm bool)

func (*UserRole) CheckPerm

func (u *UserRole) CheckPerm(permPath string) bool

func (*UserRole) CheckPerm2

func (u *UserRole) CheckPerm2(roleList []*dbschema.UserRole, perm string) (hasPerm bool)

func (*UserRole) CleanPermAction

func (u *UserRole) CleanPermAction(values []string) *UserRole

func (*UserRole) Exists

func (u *UserRole) Exists(name string) (bool, error)

func (*UserRole) Exists2

func (u *UserRole) Exists2(name string, excludeID uint) (bool, error)

func (*UserRole) FilterNavigate

func (u *UserRole) FilterNavigate(roleList []*dbschema.UserRole, navList *navigate.List) navigate.List

FilterNavigate 过滤导航菜单,只显示有权限的菜单

func (*UserRole) ListByUser

func (u *UserRole) ListByUser(user *dbschema.User) (roleList []*dbschema.UserRole)

type Verification

type Verification struct {
	*dbschema.CodeVerification
	*base.Base
}

func NewVerification

func NewVerification(ctx echo.Context) *Verification

type Vhost

type Vhost struct {
	*dbschema.Vhost
	*base.Base
}

func NewVhost

func NewVhost(ctx echo.Context) *Vhost

type VhostAndGroup

type VhostAndGroup struct {
	*dbschema.Vhost
	Group *dbschema.VhostGroup
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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