Skip to content

配置指南

SirrChat 使用 TOML 格式的配置文件,提供灵活且易读的配置选项。

配置文件位置

默认配置文件路径:

  • Linux: ~/.sirrchatd/config.toml
  • 自定义路径: 使用 --config 参数指定

基本配置

服务器配置

toml
[server]
# 服务器主机名
hostname = "mail.example.com"

# SMTP 端口
smtp_port = 25
submission_port = 587

# IMAP 端口
imap_port = 143
imaps_port = 993

TLS 配置

toml
[tls]
# 自动获取 Let's Encrypt 证书
acme = true

# DNS 提供商(用于 DNS-01 验证)
dns_provider = "cloudflare"

# Cloudflare API 令牌
[tls.cloudflare]
api_token = "your-cloudflare-api-token"

数据库配置

toml
[database]
# 数据库类型: sqlite, postgres, mysql
type = "postgres"

# PostgreSQL 连接字符串
dsn = "postgresql://user:password@localhost/sirrchat"

存储配置

toml
[storage]
# 存储类型: local, s3
type = "local"

# 本地存储路径
local_path = "/var/mail"

# S3 配置(如使用 S3)
[storage.s3]
endpoint = "s3.amazonaws.com"
bucket = "sirrchat-storage"
access_key = "your-access-key"
secret_key = "your-secret-key"

认证配置

区块链认证

toml
[auth.blockchain]
enabled = true

# 支持的区块链网络
networks = ["ethereum", "bsc", "polygon"]

# RPC 端点
[auth.blockchain.rpc]
ethereum = "https://mainnet.infura.io/v3/YOUR-PROJECT-ID"
bsc = "https://bsc-dataseed.binance.org"

LDAP 认证

toml
[auth.ldap]
enabled = true
server = "ldap://ldap.example.com:389"
bind_dn = "cn=admin,dc=example,dc=com"
bind_password = "password"
user_base = "ou=users,dc=example,dc=com"

安全配置

DKIM 配置

toml
[dkim]
enabled = true
selector = "default"
private_key_path = "/etc/sirrchatd/dkim/private.key"

SPF 配置

toml
[spf]
enabled = true
check_incoming = true

速率限制

toml
[rate_limit]
# 每小时最大发件数
max_emails_per_hour = 100

# 每分钟最大连接数
max_connections_per_minute = 10

日志配置

toml
[logging]
# 日志级别: debug, info, warn, error
level = "info"

# 日志格式: text, json
format = "json"

# 日志输出
output = "/var/log/sirrchatd/app.log"

高级配置

性能调优

toml
[performance]
# 工作线程数
workers = 4

# 数据库连接池大小
db_pool_size = 10

# 缓存大小(MB)
cache_size = 256

监控配置

toml
[monitoring]
# Prometheus 指标端点
metrics_enabled = true
metrics_port = 9090

# 健康检查端点
health_check_port = 8080

完整配置示例

toml
[server]
hostname = "mail.example.com"
smtp_port = 25
submission_port = 587
imap_port = 143
imaps_port = 993

[tls]
acme = true
dns_provider = "cloudflare"

[tls.cloudflare]
api_token = "your-cloudflare-api-token"

[database]
type = "postgres"
dsn = "postgresql://sirrchat:password@localhost/sirrchat"

[storage]
type = "local"
local_path = "/var/mail"

[auth.blockchain]
enabled = true
networks = ["ethereum", "bsc"]

[auth.blockchain.rpc]
ethereum = "https://mainnet.infura.io/v3/YOUR-PROJECT-ID"
bsc = "https://bsc-dataseed.binance.org"

[dkim]
enabled = true
selector = "default"
private_key_path = "/etc/sirrchatd/dkim/private.key"

[logging]
level = "info"
format = "json"
output = "/var/log/sirrchatd/app.log"

配置验证

启动前验证配置:

bash
sirrchatd config verify

环境变量

所有配置都可以通过环境变量覆盖:

bash
export SIRRCHAT_SERVER_HOSTNAME=mail.example.com
export SIRRCHAT_DATABASE_DSN=postgresql://user:pass@localhost/db

更多信息:

Released under the GPL 3.0 License.