websitectl

package
v0.0.1-beta5 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultWebsiteCtl = SqliteWebsiteCtl(conf.GetPHPWebsiteDbFile(), conf.GetPHPWebsiteConfRoot())

	Create                      = DefaultWebsiteCtl.Create
	List                        = DefaultWebsiteCtl.List
	Get                         = DefaultWebsiteCtl.Get
	Delete                      = DefaultWebsiteCtl.Delete
	DeleteMultiple              = DefaultWebsiteCtl.DeleteMultiple
	Start                       = DefaultWebsiteCtl.Start
	StartMultiple               = DefaultWebsiteCtl.StartMultiple
	Stop                        = DefaultWebsiteCtl.Stop
	StopMultiple                = DefaultWebsiteCtl.StopMultiple
	SetPHPVersion               = DefaultWebsiteCtl.SetPHPVersion
	SetPHPVersionMultiple       = DefaultWebsiteCtl.SetPHPVersionMultiple
	SetTypeName                 = DefaultWebsiteCtl.SetTypeName
	SetTypeNameMultiple         = DefaultWebsiteCtl.SetTypeNameMultiple
	Index                       = DefaultWebsiteCtl.Index
	ServerName                  = DefaultWebsiteCtl.ServerName
	Webroot                     = DefaultWebsiteCtl.Webroot
	ExecRoot                    = DefaultWebsiteCtl.ExecRoot
	ConfFile                    = DefaultWebsiteCtl.ConfFile
	ConfLoad                    = DefaultWebsiteCtl.ConfLoad
	ConfUpdate                  = DefaultWebsiteCtl.ConfUpdate
	ConfDir                     = DefaultWebsiteCtl.ConfDir
	ConfEval                    = DefaultWebsiteCtl.ConfEval
	NginxReload                 = DefaultWebsiteCtl.NginxReload
	NginxTestConf               = DefaultWebsiteCtl.NginxTestConf
	Composer                    = DefaultWebsiteCtl.Composer
	PHPVersionList              = DefaultWebsiteCtl.PHPVersionList
	PHPVersionRequired          = DefaultWebsiteCtl.PHPVersionRequired
	PHPConfFile                 = DefaultWebsiteCtl.PHPConfFile
	PHPVersionField             = DefaultWebsiteCtl.PHPVersionField
	AccessLogEnable             = DefaultWebsiteCtl.AccessLogEnable
	AccessLogDisable            = DefaultWebsiteCtl.AccessLogDisable
	AccessLogFile               = DefaultWebsiteCtl.AccessLogFile
	AccessLogLoad               = DefaultWebsiteCtl.AccessLogLoad
	ErrorLogEnable              = DefaultWebsiteCtl.ErrorLogEnable
	ErrorLogDisable             = DefaultWebsiteCtl.ErrorLogDisable
	ErrorLogFile                = DefaultWebsiteCtl.ErrorLogFile
	ErrorLogLoad                = DefaultWebsiteCtl.ErrorLogLoad
	BasicAuthEnable             = DefaultWebsiteCtl.BasicAuthEnable
	BasicAuthConfFile           = DefaultWebsiteCtl.BasicAuthConfFile
	BasicAuthPasswdFile         = DefaultWebsiteCtl.BasicAuthPasswdFile
	BaseDirOpen                 = DefaultWebsiteCtl.BaseDirOpen
	BaseDirClose                = DefaultWebsiteCtl.BaseDirClose
	EncryptAccessCreate         = DefaultWebsiteCtl.EncryptAccessCreate
	EncryptAccessList           = DefaultWebsiteCtl.EncryptAccessList
	EncryptAccessUpdate         = DefaultWebsiteCtl.EncryptAccessUpdate
	EncryptAccessDelete         = DefaultWebsiteCtl.EncryptAccessDelete
	EncryptAccessDeleteMultiple = DefaultWebsiteCtl.EncryptAccessDeleteMultiple
	DenyAccessCreate            = DefaultWebsiteCtl.DenyAccessCreate
	DenyAccessUpdate            = DefaultWebsiteCtl.DenyAccessUpdate
	DenyAccessList              = DefaultWebsiteCtl.DenyAccessList
	DenyAccessDelete            = DefaultWebsiteCtl.DenyAccessDelete
	DenyAccessDeleteMultiple    = DefaultWebsiteCtl.DenyAccessDeleteMultiple
	LimitGet                    = DefaultWebsiteCtl.LimitGet
	LimitUpdate                 = DefaultWebsiteCtl.LimitUpdate
	LimitPlanList               = DefaultWebsiteCtl.LimitPlanList
	RedirectList                = DefaultWebsiteCtl.RedirectList
	RedirectCreate              = DefaultWebsiteCtl.RedirectCreate
	RedirectUpdate              = DefaultWebsiteCtl.RedirectUpdate
	RedirectDelete              = DefaultWebsiteCtl.RedirectDelete
	RedirectDeleteMultiple      = DefaultWebsiteCtl.RedirectDeleteMultiple
	RedirectConfLoad            = DefaultWebsiteCtl.RedirectConfLoad
	RedirectConfUpdate          = DefaultWebsiteCtl.RedirectConfUpdate
	RedirectStart               = DefaultWebsiteCtl.RedirectStart
	RedirectStartMultiple       = DefaultWebsiteCtl.RedirectStartMultiple
	RedirectStop                = DefaultWebsiteCtl.RedirectStop
	RedirectStopMultiple        = DefaultWebsiteCtl.RedirectStopMultiple
	RewriteLoad                 = DefaultWebsiteCtl.RewriteLoad
	RewriteUpdate               = DefaultWebsiteCtl.RewriteUpdate
	RewriteTemplateList         = DefaultWebsiteCtl.RewriteTemplateList
	RewriteTemplateCreate       = DefaultWebsiteCtl.RewriteTemplateCreate
	ReverseProxyList            = DefaultWebsiteCtl.ReverseProxyList
	ReverseProxyCreate          = DefaultWebsiteCtl.ReverseProxyCreate
	ReverseProxyUpdate          = DefaultWebsiteCtl.ReverseProxyUpdate
	ReverseProxyDelete          = DefaultWebsiteCtl.ReverseProxyDelete
	ReverseProxyDeleteMultiple  = DefaultWebsiteCtl.ReverseProxyDeleteMultiple
	ReverseProxyConfLoad        = DefaultWebsiteCtl.ReverseProxyConfLoad
	ReverseProxyConfUpdate      = DefaultWebsiteCtl.ReverseProxyConfUpdate
	ReverseProxyStart           = DefaultWebsiteCtl.ReverseProxyStart
	ReverseProxyStartMultiple   = DefaultWebsiteCtl.ReverseProxyStartMultiple
	ReverseProxyStop            = DefaultWebsiteCtl.ReverseProxyStop
	ReverseProxyStopMultiple    = DefaultWebsiteCtl.ReverseProxyStopMultiple
	SecurityLoad                = DefaultWebsiteCtl.SecurityLoad
	SecurityUpdate              = DefaultWebsiteCtl.SecurityUpdate
)

Functions

This section is empty.

Types

type ComposerInfo

type ComposerInfo struct {
	Version     string           `json:"version"`      // Composer 版本
	PHPVersions []string         `json:"php_versions"` // PHP版本列表
	ExecDir     string           `json:"exec_dir"`     // 执行目录
	ExecArgs    string           `json:"exec_args"`    // 执行参数
	Mirrors     []ComposerMirror `json:"mirrors"`      // 镜像源列表
	Users       []string         `json:"users"`        // 执行用户 www/root
}

type ComposerMirror

type ComposerMirror struct {
	Name   string `json:"name"`   // 镜像源名称
	Mirror string `json:"mirror"` // 镜像源地址
}

type DenyAccess

type DenyAccess struct {
	ID        uint   `db:"id" json:"id"`                 // ID
	WebsiteID uint   `db:"website_id" json:"website_id"` // 站点ID
	Name      string `db:"name" json:"name"`             // 名称
	Dir       string `db:"dir" json:"dir"`               // 目录
	Ext       string `db:"ext" json:"ext"`               // 后缀名
}

type EncryptAccess

type EncryptAccess struct {
	ID        uint   `db:"id" json:"id"`                 // ID
	WebsiteID uint   `db:"website_id" json:"website_id"` // 站点ID
	Name      string `db:"name" json:"name"`             // 名称
	Dir       string `db:"dir" json:"dir"`               // 目录
	User      string `db:"user" json:"user"`             // 用户名
	Passwd    string `db:"passwd" json:"passwd"`         // 密码
}

type Limit

type Limit struct {
	ID        uint `db:"id" json:"id"`                 // ID
	WebsiteID uint `db:"website_id" json:"website_id"` // 站点ID
	Enable    byte `db:"enable" json:"enable"`         // 开启流量控制 0未开启 1开启
	PerServer uint `db:"per_server" json:"per_server"` // 并发限制 限制当前站点最大并发数
	PerIP     uint `db:"per_ip" json:"per_ip"`         // 单IP限制 限制单个IP访问最大并发数
	Rate      uint `db:"rate" json:"rate"`             // 流量限制 限制每个请求的流量上限(单位:KB)
}

type LimitPlan

type LimitPlan struct {
	ID        uint   `db:"id" json:"id"`
	Name      string `db:"name" json:"name"`
	PerServer uint   `db:"per_server" json:"per_server"`
	PerIP     uint   `db:"per_ip" json:"per_ip"`
	Rate      uint   `db:"rate" json:"rate"`
}

type Redirect

type Redirect struct {
	ID           uint   `db:"id" json:"id"`                         // ID
	WebsiteID    uint   `db:"website_id" json:"website_id"`         // 站点ID
	Enable       byte   `db:"enable" json:"enable"`                 // 开启重定向 0未开启 1开启
	Name         string `db:"name" json:"name"`                     // 重定向名称 配置域名或路径
	ConfFile     string `db:"conf_file" json:"conf_file"`           // 配置文件名称
	Type         byte   `db:"type" json:"type"`                     // 重定向类型 0域名 1路径
	RedirectCode byte   `db:"redirect_code" json:"redirect_code"`   // 重定向方式 0->301 1->302
	TargetURL    string `db:"target_url" json:"target_url"`         // 目标URL
	KeepURIParam byte   `db:"keep_uri_param" json:"keep_uri_param"` // 保留URI参数 0不保留 1保留
}

type ReverseProxy

type ReverseProxy struct {
	ID                 uint   `db:"id" json:"id"`                                     // ID
	WebsiteID          uint   `db:"website_id" json:"website_id"`                     // 站点ID
	Enable             byte   `db:"enable" json:"enable"`                             // 开启反向代理 0未开启 1开启
	Name               string `db:"name" json:"name"`                                 // 反向代理名称
	CacheEnable        byte   `db:"cache_enable" json:"cache_enable"`                 // 开启缓存 0未开启 1开启
	CacheTime          string `db:"cache_time" json:"cache_time"`                     // 缓存时间,分钟
	AdvancedEnable     byte   `db:"advanced_enable" json:"advanced_enable"`           // 开启高级功能 0未开启 1开启
	AdvancedProxyDir   string `db:"advanced_proxy_dir" json:"advanced_proxy_dir"`     // 代理目录
	TargetURL          string `db:"target_url" json:"target_url"`                     // 目标URL
	SendDomain         string `db:"send_domain" json:"send_domain"`                   // 发送域名
	ContentReplaceJSON string `db:"content_replace_json" json:"content_replace_json"` // 内容替换 [{"content":"","replace":""}]
}

type RewriteTemplate

type RewriteTemplate struct {
	ID   uint   `db:"id" json:"id"`     // ID
	Name string `db:"name" json:"name"` // 模板名称
	Conf string `db:"conf" json:"conf"` // 重写配置
}

type SecurityInfo

type SecurityInfo struct {
	ID                    uint   `db:"id" json:"id"`                                             // ID
	WebsiteID             uint   `db:"website_id" json:"website_id"`                             // 站点ID
	Enable                byte   `db:"enable" json:"enable"`                                     // 是否开启防盗链 0未开启 1开启
	URLSuffix             string `db:"url_suffix" json:"url_suffix"`                             // URL后缀
	AllowDomain           string `db:"allow_domain" json:"allow_domain"`                         // 许可域名
	ResponseCode          string `db:"response_code" json:"response_code"`                       // 响应资源Code
	AllowEmptyHttpReferer byte   `db:"allow_empty_http_referer" json:"allow_empty_http_referer"` // 允许空HTTP_REFERER请求 0不允许 1允许
}

type WebsiteCtl

type WebsiteCtl interface {
	Create(info WebsiteInfo) (err error)                             // 创建
	List(text string) (list []WebsiteInfo, err error)                // 列表
	Get(ID uint) (info WebsiteInfo, err error)                       // 获取单个
	Delete(ID uint) (err error)                                      // 删除
	DeleteMultiple(IDs []uint) (err error)                           // 删除多个
	Start(ID uint) (err error)                                       // 启动
	StartMultiple(IDs []uint) (err error)                            // 启动多个
	Stop(ID uint) (err error)                                        // 停止
	StopMultiple(IDs []uint) (err error)                             // 停止多个
	SetPHPVersion(ID uint, phpVersion string) (err error)            // 设置PHP版本
	SetPHPVersionMultiple(IDs []uint, phpVersion string) (err error) // 设置PHP版本多个
	SetTypeName(ID uint, typeName string) (err error)                // 设置分类
	SetTypeNameMultiple(IDs []uint, typeName string) (err error)     // 设置分类多个

	Index(ID uint, index string) (err error)           // 重设默认文档 index.html,index.php,...
	ServerName(ID uint, serverName string) (err error) // 重设域名 site1.me,site2.me,...
	Webroot(ID uint, webroot string) (err error)       // 重设网站目录
	ExecRoot(ID uint, execRoot string) (err error)     // 重设运行目录

	ConfFile(info WebsiteInfo) (confFile string)          // 配置文件
	ConfLoad(info WebsiteInfo) (conf string, err error)   // 配置文件获取
	ConfUpdate(info WebsiteInfo, conf string) (err error) // 配置文件修改
	ConfDir(info WebsiteInfo) (confDir string)            // 站点其他配置根目录
	ConfEval(info WebsiteInfo) (conf string, err error)   // 解析配置

	NginxReload() (err error)   // Nginx重载服务
	NginxTestConf() (err error) // Nginx测试配置

	Composer() (info ComposerInfo) // Composer信息

	PHPVersionList() (list []appfs.VersionDesc)     // PHP版本列表
	PHPVersionRequired(phpVer string) (err error)   // PHP版本依赖检查
	PHPConfFile(phpVer string) (phpConfFile string) // PHP配置文件
	PHPVersionField(info *WebsiteInfo) (err error)  // PHP版本设置

	AccessLogEnable(ID uint) (err error)                     // 写访问日志 access.log
	AccessLogDisable(ID uint) (err error)                    // 不写访问日志 access.log
	AccessLogFile(ID uint) (accessLogFile string, err error) // 访问日志文件
	AccessLogLoad(ID uint) (log string, err error)           // 访问日志

	ErrorLogEnable(ID uint) (err error)                    // 写错误日志文件 error.log
	ErrorLogDisable(ID uint) (err error)                   // 不写错误日志文件 error.log
	ErrorLogFile(ID uint) (errorLogFile string, err error) // 错误日志文件
	ErrorLogLoad(ID uint) (log string, err error)          // 错误日志

	BasicAuthEnable(ID uint, user, passwd string) (err error)       // 开启密码访问
	BasicAuthConfFile(ID uint) (authConfFile string, err error)     // 密码访问配置文件
	BasicAuthPasswdFile(ID uint) (authPasswdFile string, err error) // 密码访问密码文件

	BaseDirOpen(ID uint) (err error)  // 开启防跨站攻击(open_basedir)
	BaseDirClose(ID uint) (err error) // 关闭防跨站攻击(open_basedir)

	EncryptAccessCreate(enc EncryptAccess) (err error)           // 加密访问新增
	EncryptAccessList(ID uint) (list []EncryptAccess, err error) // 加密访问列表
	EncryptAccessUpdate(enc EncryptAccess) (err error)           // 加密访问修改
	EncryptAccessDelete(ID uint) (err error)                     // 加密访问删除
	EncryptAccessDeleteMultiple(IDs []uint) (err error)          // 加密访问删除多个

	DenyAccessCreate(deny DenyAccess) (err error)          // 禁止访问新增
	DenyAccessUpdate(deny DenyAccess) (err error)          // 禁止访问修改
	DenyAccessList(ID uint) (list []DenyAccess, err error) // 禁止访问列表
	DenyAccessDelete(ID uint) (err error)                  // 禁止访问删除
	DenyAccessDeleteMultiple(IDs []uint) (err error)       // 禁止访问删除多个

	LimitGet(ID uint) (limit Limit, err error)    // 流量控制获取
	LimitUpdate(limit Limit) (err error)          // 流量控制修改
	LimitPlanList() (list []LimitPlan, err error) // 流量控制方案列表

	RedirectList(ID uint) (list []Redirect, err error)   // 重定向列表
	RedirectCreate(red Redirect) (err error)             // 重定向创建
	RedirectUpdate(red Redirect) (err error)             // 重定向创建
	RedirectDelete(ID uint) (err error)                  // 重定向删除
	RedirectDeleteMultiple(IDs []uint) (err error)       // 重定向删除多个
	RedirectConfLoad(ID uint) (conf string, err error)   // 重定向配置获取
	RedirectConfUpdate(ID uint, conf string) (err error) // 重定向配置修改
	RedirectStart(ID uint) (err error)                   // 重定向开启
	RedirectStartMultiple(IDs []uint) (err error)        // 重定向开启多个
	RedirectStop(ID uint) (err error)                    // 重定向停止
	RedirectStopMultiple(IDs []uint) (err error)         // 重定向停止多个

	RewriteLoad(ID uint) (conf string, err error)             // 重写配置获取
	RewriteUpdate(ID uint, conf string) (err error)           // 重写配置修改
	RewriteTemplateList() (list []RewriteTemplate, err error) // 重写配置模板列表
	RewriteTemplateCreate(name, conf string) (err error)      // 重写配置模板创建

	ReverseProxyList(ID uint) (list []ReverseProxy, err error) // 反向代理列表
	ReverseProxyCreate(rev ReverseProxy) (err error)           // 反向代理创建
	ReverseProxyUpdate(rev ReverseProxy) (err error)           // 反向代理创建
	ReverseProxyDelete(ID uint) (err error)                    // 反向代理删除
	ReverseProxyDeleteMultiple(IDs []uint) (err error)         // 反向代理删除多个
	ReverseProxyConfLoad(ID uint) (conf string, err error)     // 反向代理配置获取
	ReverseProxyConfUpdate(ID uint, conf string) (err error)   // 反向代理配置修改
	ReverseProxyStart(ID uint) (err error)                     // 反向代理开启
	ReverseProxyStartMultiple(IDs []uint) (err error)          // 反向代理开启多个
	ReverseProxyStop(ID uint) (err error)                      // 反向代理停止
	ReverseProxyStopMultiple(IDs []uint) (err error)           // 反向代理停止多个

	SecurityLoad(ID uint) (secInfo SecurityInfo, err error) // 防盗链配置获取
	SecurityUpdate(secInfo SecurityInfo) (err error)        // 防盗链配置修改
}

func SqliteWebsiteCtl

func SqliteWebsiteCtl(dbFile, confRoot string) WebsiteCtl

type WebsiteInfo

type WebsiteInfo struct {
	ID         uint   `db:"id" json:"id"`                   // ID
	SiteName   string `db:"site_name" json:"site_name"`     // 网站名称 www.example.com
	Port       uint   `db:"port" json:"port"`               // 端口 listen 80;
	ServerName string `db:"server_name" json:"server_name"` // 域名 site1.me,site2.me,...
	Index      string `db:"_index" json:"index"`            // 默认文档 index.html,index.php,...
	Webroot    string `db:"webroot" json:"webroot"`         // 根目录
	ExecRoot   string `db:"exec_root" json:"exec_root"`     // 运行目录
	Root       string `db:"root" json:"root"`               // root /tmp/webroot;
	PHPVersion string `db:"php_version" json:"php_version"` // PHP版本
	TypeName   string `db:"type_name" json:"type_name"`     // 分类名称
	Remark     string `db:"remark" json:"remark"`           // 备注
	Status     byte   `db:"status" json:"status"`           // 状态 0停止 1开启

	AccessLogEnable byte   `db:"access_log_enable" json:"access_log_enable"`
	AccessLogFile   string `db:"access_log_file" json:"access_log_file"` // access_log  /tmp/www.log;

	ErrorLogEnable byte   `db:"error_log_enable" json:"error_log_enable"`
	ErrorLogFile   string `db:"error_log_file" json:"error_log_file"` // error_log  /tmp/www.error.log;

	PHPVersionEnable   byte   `db:"php_version_enable" json:"php_version_enable"`
	PHPVersionConfFile string `db:"php_version_conf_file" json:"php_version_conf_file"` // include /tmp/conf/php.conf

	AuthEnable   byte   `db:"auth_enable" json:"auth_enable"`
	AuthConfFile string `db:"auth_conf_file" json:"auth_conf_file"` // include /tmp/conf/auth.conf;

	BaseDirOpenEnable byte `db:"base_dir_open_enable" json:"base_dir_open_enable"`

	LimitEnable   byte   `db:"limit_enable" json:"limit_enable"`
	LimitConfFile string `db:"limit_conf_file" json:"limit_conf_file"` // include /tmp/conf/limit.conf;

	DenyAccessEnable   byte   `db:"deny_access_enable" json:"deny_access_enable"`
	DenyAccessConfFile string `db:"deny_access_conf_file" json:"deny_access_conf_file"` // include /tmp/conf/deny_access.conf;

	EncryptAccessEnable   byte   `db:"encrypt_access_enable" json:"encrypt_access_enable"`
	EncryptAccessConfFile string `db:"encrypt_access_conf_file" json:"encrypt_access_conf_file"` // include /tmp/conf/encrypt_access.conf;

	RedirectEnable   byte   `db:"redirect_enable" json:"redirect_enable"`
	RedirectConfFile string `db:"redirect_conf_file" json:"redirect_conf_file"` // include /tmp/conf/redirect.conf;

	ReverseProxyEnable   byte   `db:"reverse_proxy_enable" json:"reverse_proxy_enable"`
	ReverseProxyConfFile string `db:"reverse_proxy_conf_file" json:"reverse_proxy_conf_file"` // include /tmp/conf/reverse_proxy.conf;

	RewriteEnable   byte   `db:"rewrite_enable" json:"rewrite_enable"`
	RewriteConfFile string `db:"rewrite_conf_file" json:"rewrite_conf_file"` // include /tmp/conf/rewrite.conf;

	SecurityEnable   byte   `db:"security_enable" json:"security_enable"`
	SecurityConfFile string `db:"security_conf_file" json:"security_conf_file"` // include /tmp/conf/security.conf;
}

Jump to

Keyboard shortcuts

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