diff --git a/service/xboard/service.go b/service/xboard/service.go index 13fab8f1..8d478d90 100644 --- a/service/xboard/service.go +++ b/service/xboard/service.go @@ -72,6 +72,7 @@ type Service struct { reportTicker *time.Ticker aliveTicker *time.Ticker access sync.Mutex + router adapter.Router inboundManager adapter.InboundManager ssCipher string // stored for user key derivation in syncUsers 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)), reportTicker: time.NewTicker(time.Duration(options.ReportInterval)), aliveTicker: time.NewTicker(1 * time.Minute), + router: service.FromContext[adapter.Router](ctx), inboundManager: service.FromContext[adapter.InboundManager](ctx), } @@ -759,7 +761,7 @@ func (s *Service) setupNode() error { s.inboundManager.Remove(inboundTag) // 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 { return err } diff --git a/service/xboard/service_test.go b/service/xboard/service_test.go index 16971a33..e7ac2e58 100644 --- a/service/xboard/service_test.go +++ b/service/xboard/service_test.go @@ -51,3 +51,18 @@ func TestResolveUserKeyForNonSS2022UsesResolvedKey(t *testing.T) { 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") + } +}