V2bX/node/node.go
yuzuki999 15c36a9580 update
refactor limiter
fix getLink bug
add connection limit
move limit config to ControllerConfig
del dynamic speed limit (next version will be re add)
del online ip sync (next version will be re add)
2023-05-16 09:15:29 +08:00

43 lines
764 B
Go

package node
import (
"github.com/Yuzuki616/V2bX/api/panel"
"github.com/Yuzuki616/V2bX/conf"
"github.com/Yuzuki616/V2bX/core"
)
type Node struct {
controllers []*Controller
}
func New() *Node {
return &Node{}
}
func (n *Node) Start(nodes []*conf.NodeConfig, core *core.Core) error {
n.controllers = make([]*Controller, len(nodes))
for i, c := range nodes {
p, err := panel.New(c.ApiConfig)
if err != nil {
return err
}
// Register controller service
n.controllers[i] = NewController(core, p, c.ControllerConfig)
err = n.controllers[i].Start()
if err != nil {
return err
}
}
return nil
}
func (n *Node) Close() {
for _, c := range n.controllers {
err := c.Close()
if err != nil {
panic(err)
}
}
n.controllers = nil
}