From 00ec5b2d4dc151985c2b8ac5f2cfb13363f6c8fd Mon Sep 17 00:00:00 2001 From: root Date: Fri, 29 Sep 2023 14:18:29 +0900 Subject: [PATCH] fix bug: func RouterFromContext return nil router --- core/sing/node.go | 4 ++-- core/sing/sing.go | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/core/sing/node.go b/core/sing/node.go index 6573503..5b9f73b 100644 --- a/core/sing/node.go +++ b/core/sing/node.go @@ -1,7 +1,6 @@ package sing import ( - "context" "crypto/rand" "encoding/base64" "fmt" @@ -215,8 +214,9 @@ func (b *Box) AddNode(tag string, info *panel.NodeInfo, config *conf.Options) er if err != nil { return err } + in, err := inbound.New( - context.Background(), + b.ctx, b.router, b.logFactory.NewLogger(F.ToString("inbound/", c.Type, "[", tag, "]")), c, diff --git a/core/sing/sing.go b/core/sing/sing.go index 4165684..ec76b7f 100644 --- a/core/sing/sing.go +++ b/core/sing/sing.go @@ -31,6 +31,7 @@ type DNSConfig struct { } type Box struct { + ctx context.Context createdAt time.Time router adapter.Router inbounds map[string]adapter.Inbound @@ -169,6 +170,7 @@ func New(c *conf.CoreConfig) (vCore.Core, error) { } router.SetClashServer(server) return &Box{ + ctx: ctx, router: router, inbounds: inMap, outbounds: outbounds,