-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.example.yaml
More file actions
102 lines (89 loc) · 5.18 KB
/
Copy pathconfig.example.yaml
File metadata and controls
102 lines (89 loc) · 5.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# Gotify → MQTT 转发服务配置示例
# 所有连接参数(Gotify 和 MQTT)均使用 DSN 统一表达。
# PID 文件路径(可选,默认 /tmp/gotify2mqtt.pid)
pid_file: /var/run/gotify2mqtt.pid
groups:
# ── 示例1:HTTP Gotify + 本地 MQTT ──────────────────────────────────
- name: home-gotify
# Gotify DSN 格式:scheme://token@host[:port][/basepath][?params]
# scheme:ws | wss
# token 填在 userinfo 的 username 位置(无需密码)
gotify: "ws://gotify.example.com:8080?token=my-client-token"
targets:
- name: all-messages
filter: {} # 空 filter 表示转发所有消息
brokers:
# ── mqtt:// ── 明文 TCP ───────────────────────────────────────
- dsn: "mqtt://user:pass@localhost:1883?client_id=home-forwarder&qos=1&keep_alive=30s"
topics:
- "gotify/app/{{.AppID}}/messages"
- "gotify/user/{{.UserName}}/messages"
# ── mqtts:// ── TLS 加密 TCP ──────────────────────────────────
- dsn: "mqtts://user:pass@mqtt.example.com:8883?ca=/etc/ssl/ca.crt&reconnect_delay_max=120s"
topics:
- "gotify/{{.AppID}}/{{.Priority}}"
# ── ws:// ── WebSocket over HTTP ──────────────────────────────
- dsn: "ws://mqtt.example.com:8083/mqtt?queue_size=512"
topics:
- "gotify/ws/{{.ID}}"
# ── wss:// ── WebSocket over TLS ─────────────────────────────
- dsn: "wss://mqtt.example.com:8084/mqtt?insecure=true"
topics:
- "gotify/wss/all"
# 只转发特定 App,按优先级过滤
- name: alert-only
filter:
app_ids: [3, 7]
priority_min: 5
brokers:
- dsn: "mqtt://localhost:1883?client_id=home-alert&qos=2&retain=true"
topics:
- "alerts/{{.AppID}}/{{.Title}}"
# ── 示例2:HTTPS Gotify + mTLS MQTT ─────────────────────────────────
- name: office-gotify
# 带反向代理 Basic Auth + TLS
gotify: "wss://proxyuser:p%40ssword@gotify-office.example.com?token=office-token&reconnect_delay=2s&reconnect_delay_max=120s"
targets:
- name: office-all
filter:
user_ids: [1]
brokers:
- dsn: "mqtts://admin:secret@mqtt-office.example.com:8883?cert=/etc/ssl/client.crt&key=/etc/ssl/client.key&ca=/etc/ssl/ca.crt"
topics:
- "office/gotify/{{.AppID}}"
# ── Gotify DSN 参数速查 ───────────────────────────────────────────────
# 格式:scheme://[user:pass@]host[:port][/base]?token=xxx[¶ms]
# scheme:ws(明文)| wss(TLS)
# user:pass:可选,用于反向代理 Basic Auth;特殊字符需 percent-encode
# 如密码含 @ 写为 %40,含 : 写为 %3A
#
# 参数名 | 默认值 | 说明
# --------------------|---------|------------------------------------
# token | 必填 | Gotify Client Token
# insecure | false | 跳过 TLS 证书校验(wss 自签名场景)
# connect_timeout | 10s | WebSocket 握手超时
# reconnect_delay | 1s | 初始重连延迟(指数退避起点)
# reconnect_delay_max | 60s | 最大重连延迟
# ── MQTT DSN 参数速查 ─────────────────────────────────────────────────
# 参数名 | 默认值 | 说明
# --------------------|---------|------------------------------------
# client_id | 自动 | 自动 = {group}-{target}-{host}
# qos | 0 | QoS 等级:0 / 1 / 2
# retain | true | 是否设置 RETAIN 标志
# queue_size | 256 | 异步发布队列深度
# connect_timeout | 10s | 连接超时
# keep_alive | 30s | MQTT 心跳间隔
# reconnect_delay | 1s | 初始重连延迟
# reconnect_delay_max | 60s | 最大重连延迟
# ca | "" | CA 证书路径(mqtts/wss)
# cert | "" | 客户端证书路径(双向 TLS)
# key | "" | 客户端私钥路径(双向 TLS)
# insecure | false | 跳过 TLS 证书校验
# ── Topic 模板变量 ────────────────────────────────────────────────────
# {{.ID}} 消息 ID(uint)
# {{.AppID}} 应用 ID(uint)
# {{.UserID}} 用户 ID(uint,来自 /current/user)
# {{.UserName}} 用户名(string)
# {{.Title}} 消息标题(特殊字符已转义为 _)
# {{.Priority}} 优先级(int)
# {{.Date}} 消息时间(RFC3339)