V2bX/core/hy/hy.go

50 lines
740 B
Go
Raw Normal View History

package hy
import (
"fmt"
2023-06-09 09:20:41 -04:00
"sync"
"github.com/Yuzuki616/V2bX/conf"
2023-06-09 00:36:49 -04:00
vCore "github.com/Yuzuki616/V2bX/core"
"github.com/hashicorp/go-multierror"
)
2023-06-09 00:36:49 -04:00
func init() {
vCore.RegisterCore("hy", NewHy)
}
type Hy struct {
servers sync.Map
}
2023-06-09 00:36:49 -04:00
func NewHy(_ *conf.CoreConfig) (vCore.Core, error) {
return &Hy{
servers: sync.Map{},
}, nil
}
func (h *Hy) Start() error {
return nil
}
func (h *Hy) Close() error {
var errs error
h.servers.Range(func(tag, s any) bool {
err := s.(*Server).Close()
if err != nil {
errs = multierror.Append(errs, fmt.Errorf("close %s error: %s", tag, err))
}
return true
})
if errs != nil {
return errs
}
return nil
}
2023-06-09 09:20:41 -04:00
func (h *Hy) Protocols() []string {
return []string{
"hysteria",
}
}