| 64 | } |
| 65 | |
| 66 | func New(store nodes.Store) *API { |
| 67 | return &API{ |
| 68 | store: store, |
| 69 | clientFactory: func(node nodes.Node) *nodes.Client { |
| 70 | // 默认 factory:未注入 hub 时返回一个 hub == nil 的 Client; |
| 71 | // 所有方法会返回 nodes.ErrHubNotConfigured。生产环境会立即被 |
| 72 | // SetNodeHub 替换,仅在单测或冷启动早期短暂出现。 |
| 73 | return nodes.NewClientWithHub(node.ID, nil) |
| 74 | }, |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | func NewWithUsers(nodesStore nodes.Store, usersStore users.Store, inboundStore inbounds.InboundStore, outboundStore outbounds.Store, applyOpts jobs.ApplyOptions, settings UpdateSettingsStore) *API { |
| 79 | api := New(nodesStore) |