first commit
This commit is contained in:
commit
494940afc9
87 files changed
+9589
No files matched your search
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"domain": "jinnrry.com",
|
||||
"dkimPrivateKeyPath": "config/dkim/dkim.priv",
|
||||
"SSLPrivateKeyPath": "config/ssl/private.key",
|
||||
"SSLPublicKeyPath": "config/ssl/public.crt",
|
||||
"mysqlDSN": "",
|
||||
"weChatPushAppId": "",
|
||||
"weChatPushSecret": "",
|
||||
"weChatPushTemplateId": "",
|
||||
"weChatPushUserId": ""
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"encoding/json"
|
||||
"io/fs"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Domain string `json:"domain"`
|
||||
DkimPrivateKeyPath string `json:"dkimPrivateKeyPath"`
|
||||
SSLPrivateKeyPath string `json:"SSLPrivateKeyPath"`
|
||||
SSLPublicKeyPath string `json:"SSLPublicKeyPath"`
|
||||
MysqlDSN string `json:"mysqlDSN"`
|
||||
|
||||
WeChatPushAppId string `json:"weChatPushAppId"`
|
||||
WeChatPushSecret string `json:"weChatPushSecret"`
|
||||
WeChatPushTemplateId string `json:"weChatPushTemplateId"`
|
||||
WeChatPushUserId string `json:"weChatPushUserId"`
|
||||
|
||||
Tables map[string]string
|
||||
TablesInitData map[string]string
|
||||
}
|
||||
|
||||
//go:embed tables/*
|
||||
var tableConfig embed.FS
|
||||
|
||||
var Instance *Config
|
||||
|
||||
func Init() {
|
||||
var cfgData []byte
|
||||
var err error
|
||||
args := os.Args
|
||||
|
||||
if len(args) >= 2 && args[len(args)-1] == "dev" {
|
||||
cfgData, err = os.ReadFile("./config/config.dev.json")
|
||||
if err != nil {
|
||||
panic("dev环境配置文件加载失败" + err.Error())
|
||||
}
|
||||
} else {
|
||||
cfgData, err = os.ReadFile("./config/config.json")
|
||||
if err != nil {
|
||||
panic("配置文件加载失败" + err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
err = json.Unmarshal(cfgData, &Instance)
|
||||
if err != nil {
|
||||
panic("配置文件加载失败" + err.Error())
|
||||
}
|
||||
|
||||
// 读取表设置
|
||||
Instance.Tables = map[string]string{}
|
||||
Instance.TablesInitData = map[string]string{}
|
||||
|
||||
err = fs.WalkDir(tableConfig, "tables", func(path string, info fs.DirEntry, err error) error {
|
||||
if !info.IsDir() && strings.HasSuffix(info.Name(), ".sql") {
|
||||
tableName := strings.ReplaceAll(info.Name(), ".sql", "")
|
||||
i, e := tableConfig.ReadFile(path)
|
||||
if e != nil {
|
||||
panic(e)
|
||||
}
|
||||
if strings.Contains(path, "data") {
|
||||
Instance.TablesInitData[tableName] = string(i)
|
||||
} else {
|
||||
Instance.Tables[tableName] = string(i)
|
||||
}
|
||||
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"domain": "demo.com",
|
||||
"dkimPrivateKeyPath": "config/dkim/dkim.priv",
|
||||
"SSLPrivateKeyPath": "config/ssl/private.key",
|
||||
"SSLPublicKeyPath": "config/ssl/public.crt",
|
||||
"mysqlDSN": "",
|
||||
"weChatPushAppId": "",
|
||||
"weChatPushSecret": "",
|
||||
"weChatPushTemplateId": "",
|
||||
"weChatPushUserId": ""
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
使用[go-msgauth](https://github.com/emersion/go-msgauth)项目的dkim-keygen工具生成公钥和私钥
|
||||
Whitespace-only changes.
Whitespace-only changes.
Whitespace-only changes.
Whitespace-only changes.
@@ -0,0 +1,2 @@
|
||||
INSERT INTO user (account, name, password) VALUES ('admin', 'admin', 'faddb6ec2efe16116a342f5512583c48');
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
INSERT INTO pmail.user_auth (user_id, email_account) VALUES (1, '*');
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
CREATE table email
|
||||
(
|
||||
id INT unsigned AUTO_INCREMENT PRIMARY KEY COMMENT '自增id',
|
||||
type tinyint(4) NOT NULL DEFAULT 0 COMMENT '邮件类型,0:收到的邮件,1:发送的邮件',
|
||||
subject varchar(1000) NOT NULL DEFAULT '' COMMENT '邮件标题',
|
||||
reply_to json COMMENT '回复人',
|
||||
from_name varchar(50) NOT NULL DEFAULT '' COMMENT '发件人名称',
|
||||
from_address varchar(150) NOT NULL DEFAULT '' COMMENT '发件人邮件地址',
|
||||
`to` json COMMENT '收件人信息',
|
||||
bcc json COMMENT '抄送',
|
||||
cc json COMMENT '抄送',
|
||||
`text` text COMMENT '邮件文本内容',
|
||||
html text COMMENT 'html格式内容',
|
||||
sender json COMMENT '发件人',
|
||||
attachments json COMMENT '附件内容',
|
||||
spf_check tinyint(1) DEFAULT 0 COMMENT '0未校验,1校验通过,2校验未通过',
|
||||
dkim_check tinyint(1) DEFAULT 0 COMMENT '0未校验,1校验通过,2校验未通过',
|
||||
status tinyint(4) NOT NULL DEFAULT 0 COMMENT '0未发送,1已发送,2发送失败',
|
||||
send_user_id int unsigned NOT NULL DEFAULT 0 COMMENT '发件人用户id',
|
||||
is_read tinyint(1) NOT NULL DEFAULT 0 COMMENT '未读0,已读1',
|
||||
error text COMMENT '错误信息记录',
|
||||
cron_send_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '定时发送邮件的发送时间',
|
||||
send_date datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '发件日期',
|
||||
create_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
update_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间'
|
||||
)COMMENT='邮件内容表'
|
||||
@@ -0,0 +1,7 @@
|
||||
CREATE TABLE sessions
|
||||
(
|
||||
token CHAR(43) PRIMARY KEY,
|
||||
data BLOB NOT NULL,
|
||||
expiry TIMESTAMP(6) NOT NULL,
|
||||
KEY `sessions_expiry_idx` (`expiry`)
|
||||
)COMMENT='系统session数据表';
|
||||
@@ -0,0 +1,8 @@
|
||||
CREATE TABLE user
|
||||
(
|
||||
id INT unsigned AUTO_INCREMENT PRIMARY KEY COMMENT '自增id',
|
||||
account varchar(20) COMMENT '账号登陆名',
|
||||
name varchar(10) COMMENT '用户名',
|
||||
password char(32) COMMENT '登陆密码,两次md5加盐,md5(md5(password+"pmail") +"pmail2023")',
|
||||
UNIQUE INDEX udx_account ( account )
|
||||
)COMMENT='登陆信息表'
|
||||
@@ -0,0 +1,8 @@
|
||||
CREATE TABLE user_auth
|
||||
(
|
||||
id INT unsigned AUTO_INCREMENT PRIMARY KEY COMMENT '自增id',
|
||||
user_id int COMMENT '用户id',
|
||||
email_account varchar(30) COMMENT '收件人前缀',
|
||||
UNIQUE INDEX udx_uid_ename ( user_id, email_account),
|
||||
UNIQUE INDEX udx_ename_uid ( email_account,user_id )
|
||||
)COMMENT='登陆信息表'
|
||||
Reference in new issue
Block a user