fix(router): skip system route setup for TUN @internal router
When a TUN listener with `route=::/0` (or any route) creates its fallback @internal router during parseMetadata/Init, the router immediately calls setSysRoutes before the TUN device exists. This causes an ENETUNREACH "no route to host" error logged by the kernel because the gateway is unreachable at that point. The system routes are correctly added later by the listener's own addRoutes() after device creation. The @internal router only needs in-memory routes for GetRoute lookups. Add NoSysRouteOption which disables netlink route management while keeping route data for in-memory queries. Use it in the TUN listener's @internal router. Fixes go-gost/x#48
This commit is contained in:
@@ -109,6 +109,7 @@ func (l *tunListener) parseMetadata(md mdata.Metadata) (err error) {
|
||||
if config.Router == nil && len(l.routes) > 0 {
|
||||
config.Router = xrouter.NewRouter(
|
||||
xrouter.RoutesOption(l.routes),
|
||||
xrouter.NoSysRouteOption(),
|
||||
xrouter.LoggerOption(logger.Default().WithFields(map[string]any{
|
||||
"kind": "router",
|
||||
"router": "@internal",
|
||||
|
||||
Reference in New Issue
Block a user