调用 inboundManager.Create(...) 时把第二个参数 router 传成了 nil。但 protocol/shadowsocks/inbound_multi.go 初始化时会无条件把这个 router 包进 uot.NewRouter(router, logger),所以 client 每次重连都会稳定触发一次空指针。
This commit is contained in:
@@ -72,6 +72,7 @@ type Service struct {
|
|||||||
reportTicker *time.Ticker
|
reportTicker *time.Ticker
|
||||||
aliveTicker *time.Ticker
|
aliveTicker *time.Ticker
|
||||||
access sync.Mutex
|
access sync.Mutex
|
||||||
|
router adapter.Router
|
||||||
inboundManager adapter.InboundManager
|
inboundManager adapter.InboundManager
|
||||||
ssCipher string // stored for user key derivation in syncUsers
|
ssCipher string // stored for user key derivation in syncUsers
|
||||||
ssServerKey string // stored for SS2022 per-user key extraction
|
ssServerKey string // stored for SS2022 per-user key extraction
|
||||||
@@ -258,6 +259,7 @@ func NewService(ctx context.Context, logger log.ContextLogger, tag string, optio
|
|||||||
syncTicker: time.NewTicker(time.Duration(options.SyncInterval)),
|
syncTicker: time.NewTicker(time.Duration(options.SyncInterval)),
|
||||||
reportTicker: time.NewTicker(time.Duration(options.ReportInterval)),
|
reportTicker: time.NewTicker(time.Duration(options.ReportInterval)),
|
||||||
aliveTicker: time.NewTicker(1 * time.Minute),
|
aliveTicker: time.NewTicker(1 * time.Minute),
|
||||||
|
router: service.FromContext[adapter.Router](ctx),
|
||||||
inboundManager: service.FromContext[adapter.InboundManager](ctx),
|
inboundManager: service.FromContext[adapter.InboundManager](ctx),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -759,7 +761,7 @@ func (s *Service) setupNode() error {
|
|||||||
s.inboundManager.Remove(inboundTag)
|
s.inboundManager.Remove(inboundTag)
|
||||||
|
|
||||||
// Create new inbound
|
// Create new inbound
|
||||||
err = s.inboundManager.Create(s.ctx, nil, s.logger, inboundTag, protocol, inboundOptions)
|
err = s.inboundManager.Create(s.ctx, s.router, s.logger, inboundTag, protocol, inboundOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,3 +51,18 @@ func TestResolveUserKeyForNonSS2022UsesResolvedKey(t *testing.T) {
|
|||||||
t.Fatalf("resolveUserKey() = %q, want %q", got, "passwd-value")
|
t.Fatalf("resolveUserKey() = %q, want %q", got, "passwd-value")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestXUserIdentifierFallsBackToEmailThenID(t *testing.T) {
|
||||||
|
userWithEmail := XUser{
|
||||||
|
ID: 8,
|
||||||
|
Email: "user@example.com",
|
||||||
|
}
|
||||||
|
if got := userWithEmail.Identifier(); got != "user@example.com" {
|
||||||
|
t.Fatalf("Identifier() = %q, want %q", got, "user@example.com")
|
||||||
|
}
|
||||||
|
|
||||||
|
userWithID := XUser{ID: 9}
|
||||||
|
if got := userWithID.Identifier(); got != "9" {
|
||||||
|
t.Fatalf("Identifier() = %q, want %q", got, "9")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user