fix crash for tun

This commit is contained in:
ginuerzh
2023-11-19 14:39:24 +08:00
parent 74639e9c4e
commit c95edd6ed3
2 changed files with 10 additions and 2 deletions

View File

@ -61,6 +61,7 @@ func (h *tunnelHandler) parseMetadata(md mdata.Metadata) (err error) {
xingress.RulesOption(rules), xingress.RulesOption(rules),
xingress.LoggerOption(logger.Default().WithFields(map[string]any{ xingress.LoggerOption(logger.Default().WithFields(map[string]any{
"kind": "ingress", "kind": "ingress",
"ingress": "@internal",
})), })),
) )
} }

View File

@ -4,6 +4,7 @@ import (
"net" "net"
"strings" "strings"
"github.com/go-gost/core/logger"
mdata "github.com/go-gost/core/metadata" mdata "github.com/go-gost/core/metadata"
mdutil "github.com/go-gost/core/metadata/util" mdutil "github.com/go-gost/core/metadata/util"
"github.com/go-gost/core/router" "github.com/go-gost/core/router"
@ -99,7 +100,13 @@ func (l *tunListener) parseMetadata(md mdata.Metadata) (err error) {
} }
if config.Router == nil && len(l.routes) > 0 { if config.Router == nil && len(l.routes) > 0 {
config.Router = xrouter.NewRouter(xrouter.RoutesOption(l.routes)) config.Router = xrouter.NewRouter(
xrouter.RoutesOption(l.routes),
xrouter.LoggerOption(logger.Default().WithFields(map[string]any{
"kind": "router",
"router": "@internal",
})),
)
} }
l.md.config = config l.md.config = config