Documentation
¶
Index ¶
- Constants
- Variables
- func GetHashFuncByFrontendConf(conf *Config) func(string) string
- func RetrieveConfigFile() string
- func Template(locale string) string
- type AdminEmailConf
- type AdminNotifyConf
- type AdminUserConf
- type AliDMConf
- type AliyunAntispamConf
- type AuthConf
- type AuthEmailConf
- type CacheConf
- type CacheType
- type CaptchaConf
- type CaptchaType
- type Config
- type DBConf
- type DBType
- type EmailConf
- type EmailQueueConf
- type EmailSenderType
- type GeetestConf
- type HCaptchaConf
- type HTTPConf
- type IPRegionConf
- type IPRegionPrecision
- type ImgUploadConf
- type KeyWordsAntispamConf
- type LogConf
- type ModeratorConf
- type NotifyBarkConf
- type NotifyDingTalkConf
- type NotifyLINEConf
- type NotifyLarkConf
- type NotifySlackConf
- type NotifyTelegramConf
- type NotifyWebHookConf
- type ReCaptchaConf
- type RedisConf
- type SMTPConf
- type SSLConf
- type TencentAntispamConf
- type TurnstileConf
- type UpgitConf
Constants ¶
View Source
const CONF_TPL_DEFAULT_PATH = "conf/artalk.example.yml"
View Source
const IMG_UPLOAD_PUBLIC_PATH = "/static/images"
图片上传目录路由重写路径
Variables ¶
View Source
var ( Version string CommitHash string )
版本信息
View Source
var CONF_DEFAULT_FILENAMES = [...]string{
"artalk.yml",
"artalk-go.yml",
"config.yml",
"conf.yml",
"artalk.yaml",
"artalk-go.yaml",
"config.yml",
"conf.yml",
}
默认配置文件名
View Source
var EnvPathMapCache = map[string]string{} /* 338 elements not displayed */
Cache result of `meta.GetEnvPathMap(config.Config{}, config.Template("en"))`
View Source
var OptionsMetaCache = []meta.OptionsMeta{} /* 247 elements not displayed */
Cache result of `meta.GetOptionsMetaData(config.Template("en"))`
Functions ¶
func GetHashFuncByFrontendConf ¶
Get the hash function according to the frontend gravatar.params configuration
Types ¶
type AdminEmailConf ¶
type AdminNotifyConf ¶
type AdminNotifyConf struct {
NotifyTpl string `koanf:"notify_tpl" json:"notify_tpl"` // 通知模板
NotifySubject string `koanf:"notify_subject" json:"notify_subject"` // 通知标题
Email *AdminEmailConf `koanf:"email" json:"email"` // 邮件通知
Telegram NotifyTelegramConf `koanf:"telegram" json:"telegram"` // TG
Lark NotifyLarkConf `koanf:"lark" json:"lark"` // 飞书
DingTalk NotifyDingTalkConf `koanf:"ding_talk" json:"ding_talk"` // 钉钉
Bark NotifyBarkConf `koanf:"bark" json:"bark"` // bark
Slack NotifySlackConf `koanf:"slack" json:"slack"` // slack
LINE NotifyLINEConf `koanf:"line" json:"line"` // LINE
WebHook NotifyWebHookConf `koanf:"webhook" json:"webhook"` // WebHook
NotifyPending bool `koanf:"notify_pending" json:"notify_pending"` // 待审核评论通知
NoiseMode bool `koanf:"noise_mode" json:"noise_mode"` // 嘈杂模式 (非回复管理员的评论也发送通知)
}
其他通知方式
type AdminUserConf ¶
type AdminUserConf struct {
Name string `koanf:"name" json:"name"`
Email string `koanf:"email" json:"email"`
Link string `koanf:"link" json:"link"`
Password string `koanf:"password" json:"password"`
BadgeName string `koanf:"badge_name" json:"badge_name"`
BadgeColor string `koanf:"badge_color" json:"badge_color"`
ReceiveEmail *bool `koanf:"receive_email" json:"receive_email"`
}
type AliyunAntispamConf ¶
type AliyunAntispamConf struct {
Enabled bool `koanf:"enabled" json:"enabled"`
AccessKeyID string `koanf:"access_key_id" json:"access_key_id"`
AccessKeySecret string `koanf:"access_key_secret" json:"access_key_secret"`
Region string `koanf:"region" json:"region"`
}
阿里云反垃圾
type AuthConf ¶
type AuthConf struct {
Enabled bool `koanf:"enabled" json:"enabled"`
Anonymous bool `koanf:"anonymous" json:"anonymous"`
Callback string `koanf:"callback" json:"callback"`
Email AuthEmailConf `koanf:"email" json:"email"`
Github struct {
Enabled bool `koanf:"enabled" json:"enabled"`
ClientID string `koanf:"client_id" json:"client_id"`
ClientSecret string `koanf:"client_secret" json:"client_secret"`
} `koanf:"github" json:"github"`
Gitlab struct {
Enabled bool `koanf:"enabled" json:"enabled"`
ClientID string `koanf:"client_id" json:"client_id"`
ClientSecret string `koanf:"client_secret" json:"client_secret"`
} `koanf:"gitlab" json:"gitlab"`
Gitea struct {
Enabled bool `koanf:"enabled" json:"enabled"`
ClientID string `koanf:"client_id" json:"client_id"`
ClientSecret string `koanf:"client_secret" json:"client_secret"`
} `koanf:"gitea" json:"gitea"`
Google struct {
Enabled bool `koanf:"enabled" json:"enabled"`
ClientID string `koanf:"client_id" json:"client_id"`
ClientSecret string `koanf:"client_secret" json:"client_secret"`
} `koanf:"google" json:"google"`
Mastodon struct {
Enabled bool `koanf:"enabled" json:"enabled"`
ClientID string `koanf:"client_id" json:"client_id"`
ClientSecret string `koanf:"client_secret" json:"client_secret"`
} `koanf:"mastodon" json:"mastodon"`
Twitter struct {
Enabled bool `koanf:"enabled" json:"enabled"`
ClientID string `koanf:"client_id" json:"client_id"`
ClientSecret string `koanf:"client_secret" json:"client_secret"`
} `koanf:"twitter" json:"twitter"`
Facebook struct {
Enabled bool `koanf:"enabled" json:"enabled"`
ClientID string `koanf:"client_id" json:"client_id"`
ClientSecret string `koanf:"client_secret" json:"client_secret"`
} `koanf:"facebook" json:"facebook"`
Discord struct {
Enabled bool `koanf:"enabled" json:"enabled"`
ClientID string `koanf:"client_id" json:"client_id"`
ClientSecret string `koanf:"client_secret" json:"client_secret"`
} `koanf:"discord" json:"discord"`
Steam struct {
Enabled bool `koanf:"enabled" json:"enabled"`
ApiKey string `koanf:"api_key" json:"api_key"`
} `koanf:"steam" json:"steam"`
Apple struct {
Enabled bool `koanf:"enabled" json:"enabled"`
ClientID string `koanf:"client_id" json:"client_id"`
ClientSecret string `koanf:"client_secret" json:"client_secret"`
} `koanf:"apple" json:"apple"`
Microsoft struct {
Enabled bool `koanf:"enabled" json:"enabled"`
ClientID string `koanf:"client_id" json:"client_id"`
ClientSecret string `koanf:"client_secret" json:"client_secret"`
} `koanf:"microsoft" json:"microsoft"`
Wechat struct {
Enabled bool `koanf:"enabled" json:"enabled"`
ClientID string `koanf:"client_id" json:"client_id"`
ClientSecret string `koanf:"client_secret" json:"client_secret"`
} `koanf:"wechat" json:"wechat"`
Tiktok struct {
Enabled bool `koanf:"enabled" json:"enabled"`
ClientID string `koanf:"client_id" json:"client_id"`
ClientSecret string `koanf:"client_secret" json:"client_secret"`
} `koanf:"tiktok" json:"tiktok"`
Slack struct {
Enabled bool `koanf:"enabled" json:"enabled"`
ClientID string `koanf:"client_id" json:"client_id"`
ClientSecret string `koanf:"client_secret" json:"client_secret"`
} `koanf:"slack" json:"slack"`
Line struct {
Enabled bool `koanf:"enabled" json:"enabled"`
ClientID string `koanf:"client_id" json:"client_id"`
ClientSecret string `koanf:"client_secret" json:"client_secret"`
} `koanf:"line" json:"line"`
Patreon struct {
Enabled bool `koanf:"enabled" json:"enabled"`
ClientID string `koanf:"client_id" json:"client_id"`
ClientSecret string `koanf:"client_secret" json:"client_secret"`
} `koanf:"patreon" json:"patreon"`
Auth0 struct {
Enabled bool `koanf:"enabled" json:"enabled"`
ClientID string `koanf:"client_id" json:"client_id"`
ClientSecret string `koanf:"client_secret" json:"client_secret"`
Domain string `koanf:"domain" json:"domain"`
} `koanf:"auth0" json:"auth0"`
}
type AuthEmailConf ¶
type CacheConf ¶
type CacheConf struct {
Enabled bool `koanf:"enabled" json:"enabled"`
Type CacheType `koanf:"type" json:"type"`
Expires int `koanf:"expires" json:"expires"` // 过期时间
WarmUp bool `koanf:"warm_up" json:"warm_up"` // 启动时缓存预热
Server string `koanf:"server" json:"server"` // 缓存服务器
Redis RedisConf `koanf:"redis" json:"redis"`
}
func (*CacheConf) GetExpiresTime ¶
type CaptchaConf ¶
type CaptchaConf struct {
Enabled bool `koanf:"enabled" json:"enabled"`
Always bool `koanf:"always" json:"always"`
CaptchaType CaptchaType `koanf:"captcha_type" json:"captcha_type"`
ActionTimeout int `koanf:"action_timeout" json:"-"` // @deprecated 已废弃 (请使用 ActionReset)
ActionReset int `koanf:"action_reset" json:"action_reset"`
ActionLimit int `koanf:"action_limit" json:"action_limit"`
Turnstile TurnstileConf `koanf:"turnstile" json:"turnstile"`
ReCaptcha ReCaptchaConf `koanf:"recaptcha" json:"recaptcha"`
HCaptcha HCaptchaConf `koanf:"hcaptcha" json:"hcaptcha"`
Geetest GeetestConf `koanf:"geetest" json:"geetest"`
}
type CaptchaType ¶
type CaptchaType string
const ( TypeImage CaptchaType = "image" TypeTurnstile CaptchaType = "turnstile" TypeReCaptcha CaptchaType = "recaptcha" TypeHCaptcha CaptchaType = "hcaptcha" TypeGeetest CaptchaType = "geetest" )
type Config ¶
type Config struct {
AppKey string `koanf:"app_key" json:"app_key"` // 加密密钥
Debug bool `koanf:"debug" json:"debug"` // 调试模式
Locale string `koanf:"locale" json:"locale"` // 语言
TimeZone string `koanf:"timezone" json:"timezone"` // 时区
Host string `koanf:"host" json:"host"` // HTTP Server 监听 IP
Port int `koanf:"port" json:"port"` // HTTP Server 监听 Port
DB DBConf `koanf:"db" json:"db"` // 数据库配置
HTTP HTTPConf `koanf:"http" json:"http"` // HTTP 配置
Cache CacheConf `koanf:"cache" json:"cache"` // 缓存
Log LogConf `koanf:"log" json:"log"` // 日志文件
TrustedDomains []string `koanf:"trusted_domains" json:"trusted_domains"` // 可信任的域名 (新)
SSL SSLConf `koanf:"ssl" json:"ssl"` // SSL
SiteDefault string `koanf:"site_default" json:"site_default"` // 默认站点名(当请求无指定 site_name 时使用)
SiteURL string `koanf:"site_url" json:"site_url"` // 默认站点 URL
AdminUsers []AdminUserConf `koanf:"admin_users" json:"admin_users"` // 管理员账户
LoginTimeout int `koanf:"login_timeout" json:"login_timeout"` // 登录超时
Moderator ModeratorConf `koanf:"moderator" json:"moderator"` // 评论审查
Captcha CaptchaConf `koanf:"captcha" json:"captcha"` // 验证码
Email EmailConf `koanf:"email" json:"email"` // 邮箱提醒
IPRegion IPRegionConf `koanf:"ip_region" json:"ip_region"` // IP 属地展示
ImgUpload ImgUploadConf `koanf:"img_upload" json:"img_upload"` // 图片上传
AdminNotify AdminNotifyConf `koanf:"admin_notify" json:"admin_notify"` // 其他通知方式
Auth AuthConf `koanf:"auth" json:"auth"` // Social Login
Frontend map[string]interface{} `koanf:"frontend" json:"frontend"`
AllowOrigins []string `koanf:"allow_origins" json:"-"` // @deprecated 已废弃 (请使用 TrustedDomains)
Notify *AdminNotifyConf `koanf:"notify" json:"-"` // @deprecated 已废弃 (请使用 AdminNotify)
// contains filtered or unexported fields
}
Config 配置 @link https://github.com/knadh/koanf
func (*Config) GetCfgFileLoaded ¶
type DBConf ¶
type DBConf struct {
Type DBType `koanf:"type" json:"type"`
Dsn string `koanf:"dsn" json:"dsn"` // 最高优先级
File string `koanf:"file" json:"file"`
Name string `koanf:"name" json:"name"`
Host string `koanf:"host" json:"host"`
Port int `koanf:"port" json:"port"`
User string `koanf:"user" json:"user"`
Password string `koanf:"password" json:"password"`
TablePrefix string `koanf:"table_prefix" json:"table_prefix"`
Charset string `koanf:"charset" json:"charset"`
SSL bool `koanf:"ssl" json:"ssl"`
PrepareStmt *bool `koanf:"prepare_stmt" json:"prepare_stmt"`
}
type EmailConf ¶
type EmailConf struct {
Enabled bool `koanf:"enabled" json:"enabled"` // 总开关
SendType EmailSenderType `koanf:"send_type" json:"send_type"` // 发送方式
SendName string `koanf:"send_name" json:"send_name"` // 发件人名
SendAddr string `koanf:"send_addr" json:"send_addr"` // 发件人地址
MailSubject string `koanf:"mail_subject" json:"mail_subject"` // 邮件标题
MailSubjectToAdmin string `koanf:"mail_subject_to_admin" json:"-"` // @deprecated 已废弃 (请使用 AdminNotify.Email.MailSubject) - 邮件标题 (发送给管理员用)
MailTpl string `koanf:"mail_tpl" json:"mail_tpl"` // 邮件模板
SMTP SMTPConf `koanf:"smtp" json:"smtp"` // SMTP 配置
AliDM AliDMConf `koanf:"ali_dm" json:"ali_dm"` // 阿里云邮件配置
Queue EmailQueueConf `koanf:"queue" json:"queue"` // 邮件发送队列配置
}
type EmailQueueConf ¶
type EmailQueueConf struct {
BufferSize int `koanf:"buffer_size" json:"buffer_size"` // Channel buffer size (default is zero that not create buffer)
}
type EmailSenderType ¶
type EmailSenderType string
const ( TypeSMTP EmailSenderType = "smtp" TypeAliDM EmailSenderType = "ali_dm" TypeSendmail EmailSenderType = "sendmail" )
type GeetestConf ¶
type HCaptchaConf ¶
type HTTPConf ¶
type HTTPConf struct {
BodyLimit int `koanf:"body_limit" json:"body_limit"` // 请求体大小限制 MB
ProxyHeader *string `koanf:"proxy_header" json:"proxy_header"` // 代理头
}
func (*HTTPConf) GetProxyHeader ¶
type IPRegionConf ¶
type IPRegionPrecision ¶
type IPRegionPrecision string
const ( IPRegionProvince IPRegionPrecision = "province" IPRegionCity IPRegionPrecision = "city" IPRegionCountry IPRegionPrecision = "country" )
type ImgUploadConf ¶
type ImgUploadConf struct {
Enabled bool `koanf:"enabled" json:"enabled"` // 总开关
Path string `koanf:"path" json:"path"` // 图片存放路径
MaxSize int64 `koanf:"max_size" json:"max_size"` // 图片大小限制
Quality string `koanf:"quality" json:"quality"` // 图片质量
PublicPath string `koanf:"public_path" json:"public_path"` // 图片 URL 基础路径
Upgit UpgitConf `koanf:"upgit" json:"upgit"` // upgit
}
type KeyWordsAntispamConf ¶
type KeyWordsAntispamConf struct {
Enabled bool `koanf:"enabled" json:"enabled"`
Pending bool `koanf:"pending" json:"pending"`
Files []string `koanf:"files" json:"files"`
FileSep string `koanf:"file_sep" json:"file_sep"`
ReplaceTo string `koanf:"replace_to" json:"replace_to"`
}
关键词词库过滤
type ModeratorConf ¶
type ModeratorConf struct {
PendingDefault bool `koanf:"pending_default" json:"pending_default"`
ApiFailBlock bool `koanf:"api_fail_block" json:"api_fail_block"` // API 请求错误仍然拦截
AkismetKey string `koanf:"akismet_key" json:"akismet_key"`
Tencent TencentAntispamConf `koanf:"tencent" json:"tencent"`
Aliyun AliyunAntispamConf `koanf:"aliyun" json:"aliyun"`
Keywords KeyWordsAntispamConf `koanf:"keywords" json:"keywords"`
}
type NotifyBarkConf ¶
type NotifyDingTalkConf ¶
type NotifyLINEConf ¶
type NotifyLarkConf ¶
type NotifySlackConf ¶
type NotifyTelegramConf ¶
type NotifyWebHookConf ¶
type ReCaptchaConf ¶
type RedisConf ¶
type RedisConf struct {
Network string `koanf:"network" json:"network"` // tcp or unix
Username string `koanf:"username" json:"username"`
Password string `koanf:"password" json:"password"`
DB int `koanf:"db" json:"db"` // Redis 默认数据库 0
}
# Redis 配置 redis:
network: "tcp" username: "" password: "" db: 0
type TencentAntispamConf ¶
type TencentAntispamConf struct {
Enabled bool `koanf:"enabled" json:"enabled"`
SecretID string `koanf:"secret_id" json:"secret_id"`
SecretKey string `koanf:"secret_key" json:"secret_key"`
Region string `koanf:"region" json:"region"`
}
腾讯云反垃圾
type TurnstileConf ¶
Click to show internal directories.
Click to hide internal directories.