diff --git a/core/hy/resolver.go b/core/hy/resolver.go index cc5edd9..8da3ea8 100644 --- a/core/hy/resolver.go +++ b/core/hy/resolver.go @@ -1,20 +1,9 @@ package hy -import ( - "crypto/tls" - "errors" - "net" - "net/url" - "strings" - - "github.com/Yuzuki616/hysteria/core/utils" - rdns "github.com/folbricht/routedns" -) - -var errInvalidSyntax = errors.New("invalid syntax") +//var errInvalidSyntax = errors.New("invalid syntax") func setResolver(dns string) error { - if net.ParseIP(dns) != nil { + /*if net.ParseIP(dns) != nil { // Just an IP address, treat as UDP 53 dns = "udp://" + net.JoinHostPort(dns, "53") } @@ -118,6 +107,6 @@ func setResolver(dns string) error { return errInvalidSyntax } cache := rdns.NewCache("cache", r, rdns.CacheOptions{}) - net.DefaultResolver = rdns.NewNetResolver(cache) + net.DefaultResolver = rdns.NewNetResolver(cache)*/ return nil } diff --git a/node/task.go b/node/task.go index 8940dd1..d9ce94c 100644 --- a/node/task.go +++ b/node/task.go @@ -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 }