V2bX/node/node.go
Yuzuki999 695da4f4c5 update to v1.1.0
change to uniproxy api
refactor build inbound
refactor limiter and rule
add ss2022 support
add speedlimit support
and more...
2022-12-18 23:31:06 +08:00

44 lines
820 B
Go

package node
import (
"github.com/Yuzuki616/V2bX/api/panel"
"github.com/Yuzuki616/V2bX/conf"
"github.com/Yuzuki616/V2bX/core"
"github.com/Yuzuki616/V2bX/node/controller"
)
type Node struct {
controllers []*controller.Node
}
func New() *Node {
return &Node{}
}
func (n *Node) Start(nodes []*conf.NodeConfig, core *core.Core) error {
n.controllers = make([]*controller.Node, len(nodes))
for i, c := range nodes {
p, err := panel.New(c.ApiConfig)
if err != nil {
return err
}
// Register controller service
n.controllers[i] = controller.New(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
}