mirror of
https://github.com/wyx2685/V2bX.git
synced 2026-02-04 12:40:11 +00:00
update
initial support for hysteria update config update api change user email format ...
This commit is contained in:
34
core/hy/node.go
Normal file
34
core/hy/node.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package hy
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/Yuzuki616/V2bX/api/panel"
|
||||
"github.com/Yuzuki616/V2bX/conf"
|
||||
"github.com/apernet/hysteria/core/cs"
|
||||
)
|
||||
|
||||
func (h *Hy) AddNode(tag string, info *panel.NodeInfo, c *conf.ControllerConfig) error {
|
||||
if info.Type != "hysteria" {
|
||||
return errors.New("the core not support " + info.Type)
|
||||
}
|
||||
s := NewServer(tag)
|
||||
err := s.runServer(info, c)
|
||||
if err != nil {
|
||||
return fmt.Errorf("run hy server error: %s", err)
|
||||
}
|
||||
h.servers.Store(tag, s)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h *Hy) DelNode(tag string) error {
|
||||
if s, e := h.servers.Load(tag); e {
|
||||
err := s.(*cs.Server).Close()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
h.servers.Delete(tag)
|
||||
return nil
|
||||
}
|
||||
return errors.New("the node is not have")
|
||||
}
|
||||
Reference in New Issue
Block a user