Merge pull request #107 from Yuzuki616/dev

Dev
This commit is contained in:
Yuzuki 2023-07-24 17:24:27 +08:00 committed by GitHub
commit 8167dad5ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 8 deletions

View File

@ -16,7 +16,7 @@ func NewCore(c *conf.CoreConfig) (Core, error) {
if types := strings.Split(c.Type, " "); len(types) > 1 {
var cs []Core
for _, t := range types {
f, ok := cores[strings.ToLower(c.Type)]
f, ok := cores[strings.ToLower(t)]
if !ok {
return nil, errors.New("unknown core type: " + t)
}

View File

@ -3,12 +3,11 @@ package hy
import (
"crypto/tls"
"errors"
"github.com/Yuzuki616/hysteria/core/utils"
rdns "github.com/folbricht/routedns"
"net"
"net/url"
"strings"
"github.com/Yuzuki616/hysteria/core/utils"
rdns "github.com/folbricht/routedns"
)
var errInvalidSyntax = errors.New("invalid syntax")

View File

@ -80,6 +80,9 @@ func buildInbound(config *conf.ControllerConfig, nodeInfo *panel.NodeInfo, tag s
if err != nil {
return nil, fmt.Errorf("marshal reality dest error: %s", err)
}
if len(config.CertConfig.RealityConfig.ShortIds) == 0 {
config.CertConfig.RealityConfig.ShortIds = []string{""}
}
in.StreamSetting.REALITYSettings = &coreConf.REALITYConfig{
Dest: d,
Xver: config.CertConfig.RealityConfig.Xver,
@ -99,6 +102,9 @@ func buildInbound(config *conf.ControllerConfig, nodeInfo *panel.NodeInfo, tag s
if err != nil {
return nil, fmt.Errorf("marshal reality dest error: %s", err)
}
if len(rc.ShortIds) == 0 {
rc.ShortIds = []string{""}
}
Xver, _ := strconv.ParseUint(rc.Xver, 10, 64)
MaxTimeDiff, _ := strconv.ParseUint(rc.Xver, 10, 64)
in.StreamSetting.REALITYSettings = &coreConf.REALITYConfig{

View File

@ -28,6 +28,7 @@ func (c *Controller) requestCert() error {
if c.CertConfig.CertFile == "" || c.CertConfig.KeyFile == "" {
return fmt.Errorf("cert file path or key file path not exist")
}
return nil
case "dns", "http":
if c.CertConfig.CertFile == "" || c.CertConfig.KeyFile == "" {
return fmt.Errorf("cert file path or key file path not exist")

View File

@ -41,9 +41,9 @@ func (c *Controller) startTasks(node *panel.NodeInfo) {
}
if c.LimitConfig.EnableDynamicSpeedLimit {
c.traffic = make(map[string]int64)
c.renewCertPeriodic = &task.Task{
Interval: time.Duration(c.LimitConfig.DynamicSpeedLimitConfig.Periodic) * time.Minute,
Execute: c.reportUserTrafficTask,
c.dynamicSpeedLimitPeriodic = &task.Task{
Interval: time.Duration(c.LimitConfig.DynamicSpeedLimitConfig.Periodic) * time.Second,
Execute: c.SpeedChecker,
}
}
}
@ -204,7 +204,7 @@ func (c *Controller) nodeInfoMonitor() (err error) {
return nil
}
func (c *Controller) SpeedChecker() {
func (c *Controller) SpeedChecker() error {
for u, t := range c.traffic {
if t >= c.LimitConfig.DynamicSpeedLimitConfig.Traffic {
err := c.limiter.UpdateDynamicSpeedLimit(c.tag, u,
@ -214,4 +214,5 @@ func (c *Controller) SpeedChecker() {
delete(c.traffic, u)
}
}
return nil
}