fea: access: support match rules.

This commit is contained in:
Daniel Ding
2025-04-12 16:25:56 +08:00
parent 44079e8e4c
commit b6f1925053
7 changed files with 150 additions and 101 deletions

View File

@@ -72,6 +72,7 @@ type WorkerListener struct {
OnTap func(w *TapWorker) error
AddRoutes func(routes []*models.Route) error
DelRoutes func(routes []*models.Route) error
Forward func(prefix, nexthop string)
}
type PrefixRule struct {
@@ -404,6 +405,14 @@ func (w *Worker) SetUUID(v string) {
w.uuid = v
}
func (w *Worker) OnDNS(name string, addr net.IP) {
w.out.Info("Worker.OnDSN %s -> %s\n", name, addr.String())
func (w *Worker) OnDNS(domain string, addr net.IP) {
name := strings.TrimRight(domain, ".")
w.out.Debug("Worker.OnDNS %s -> %s\n", name, addr.String())
via := w.cfg.Backends.FindBackend(name)
if via != nil {
w.out.Debug("Worker.OnDNS %s via %s", name, via.Server)
if w.listener.Forward != nil {
w.listener.Forward(addr.String()+"/32", via.Server)
}
}
}