add router component

This commit is contained in:
ginuerzh
2023-11-19 14:23:21 +08:00
parent 88cc6ff4d5
commit 74639e9c4e
25 changed files with 788 additions and 123 deletions

View File

@ -82,7 +82,7 @@ func (h *tunHandler) transportServer(ctx context.Context, tun io.ReadWriter, con
return nil
}
addr := h.findRouteFor(dst, config.Routes...)
addr := h.findRouteFor(ctx, dst, config.Router)
if addr == nil {
log.Debugf("no route for %s -> %s, packet discarded", src, dst)
return nil
@ -203,7 +203,7 @@ func (h *tunHandler) transportServer(ctx context.Context, tun io.ReadWriter, con
return nil
}
if addr := h.findRouteFor(dst, config.Routes...); addr != nil {
if addr := h.findRouteFor(ctx, dst, config.Router); addr != nil {
log.Debugf("find route: %s -> %s", dst, addr)
_, err := conn.WriteTo(b[:n], addr)