CI / test (push) Failing after 1m18s
**ACLs (Access Control Lists):** - Ajout du type AclConfig dans sources/event.v (allowed_ips CIDR + allowed_tokens) - Chaque source webhook (Gitea, Uptime Kuma, Cron, Generic) supporte les ACLs - Validation IP via X-Forwarded-For / X-Real-IP avant HMAC - Validation Bearer token via Authorization header - Tests: 7 tests ACL (IP exact, CIDR, parse IPv4, ACL vide, IP+token combiné) **Plugin system:** - sources/plugin.v: runner exécutable externe, stdout JSON → Event - Exit 0 = publish, exit ≠ 0 = skip. Timeout configurable - Plugin loop dans server.v (goroutine, toutes les 60s) - Example: scripts/example-plugin-disk.sh (vérifie espace disque) **Docs:** - README.md: ajout source Plugin + section Features complète - ARCHITECTURE.md: flux Plugin, flux ACL, endpoints /metrics /api/silence - ROADMAP.md: Phase 5 → 8/8 complet, ajout v0.6.0 - ntfy-bridge.example.yaml: sections ACLs et Plugins commentées - Version bump: 0.5.0 → 0.6.0
54 lines
1.2 KiB
V
54 lines
1.2 KiB
V
module main
|
|
|
|
// WebhookRoute maps a webhook path to its source type and index for O(1) dispatch.
|
|
pub enum SourceKind {
|
|
gitea
|
|
uptime_kuma
|
|
cron
|
|
generic
|
|
plugin
|
|
}
|
|
|
|
pub struct WebhookRoute {
|
|
kind SourceKind
|
|
index int // index in the config's source array
|
|
}
|
|
|
|
// build_webhook_routes constructs a map of webhook_path → WebhookRoute
|
|
// for O(1) dispatch instead of scanning all sources on every request.
|
|
pub fn build_webhook_routes(cfg Config) map[string]WebhookRoute {
|
|
mut routes := map[string]WebhookRoute{}
|
|
|
|
for i, src in cfg.sources.gitea {
|
|
routes[src.webhook_path] = WebhookRoute{
|
|
kind: .gitea
|
|
index: i
|
|
}
|
|
}
|
|
for i, src in cfg.sources.uptime_kuma {
|
|
routes[src.webhook_path] = WebhookRoute{
|
|
kind: .uptime_kuma
|
|
index: i
|
|
}
|
|
}
|
|
for i, src in cfg.sources.cron {
|
|
routes[src.webhook_path] = WebhookRoute{
|
|
kind: .cron
|
|
index: i
|
|
}
|
|
}
|
|
for i, src in cfg.sources.generic {
|
|
routes[src.webhook_path] = WebhookRoute{
|
|
kind: .generic
|
|
index: i
|
|
}
|
|
}
|
|
for i, _ in cfg.sources.plugin {
|
|
// Plugin sources don't have webhook_path — they run as background tasks
|
|
// Reserved for future webhook-triggered plugin support
|
|
_ = i
|
|
}
|
|
|
|
return routes
|
|
}
|