fix(web): install the share-link provider before the panel serves (#6914)

The panel started answering requests before the share-link generator was
registered, so an "all links", client sub-links or Telegram link request that
arrived during start-up got "sub link provider not registered". NewServer now
takes the provider and installs it before anything listens, and the provider
registry is guarded by a lock, since start-up writes it while requests read it.
This commit is contained in:
25f2002654
2026-10-24 09:20:46 +05:30
committed by GitHub
parent ad470681ef
commit d2a0216e01
9 changed files with 125 additions and 20 deletions
+10 -5
View File
@@ -138,8 +138,12 @@ type Server struct {
cancel context.CancelFunc
}
// NewServer creates a new web server instance with a cancellable context.
func NewServer() *Server {
// NewServer installs the share-link provider before anything serves, so an early link request
// no longer gets "sub link provider not registered".
func NewServer(subLinkProvider service.SubLinkProvider) *Server {
if subLinkProvider != nil {
service.RegisterSubLinkProvider(subLinkProvider)
}
ctx, cancel := context.WithCancel(context.Background())
return &Server{
ctx: ctx,
@@ -550,11 +554,12 @@ func (s *Server) start(restartXray bool, startTgBot bool) (err error) {
// add/update/delete to either the local xray or a remote node panel.
// The closures bridge into XrayService (which owns the running xray
// process state) without forcing the runtime package to import service.
runtime.SetManager(runtime.NewManager(runtime.LocalDeps{
mgr := runtime.NewManager(runtime.LocalDeps{
APIPort: func() int { return s.xrayService.GetXrayAPIPort() },
SetNeedRestart: func() { s.xrayService.SetToNeedRestart() },
}))
runtime.GetManager().SetNodeEgressResolver(&s.settingService)
})
runtime.SetManager(mgr)
mgr.SetNodeEgressResolver(&s.settingService)
// Supply the master client certificate for nodes in mtls mode. Issued lazily
// from the node CA on first use; runtime stays free of a service import.
runtime.SetMasterClientCertProvider(func() (tls.Certificate, error) {