mirror of
https://github.com/wyx2685/V2bX.git
synced 2025-01-22 09:58:14 -05:00
fix dynamic speed limit
This commit is contained in:
parent
15118de367
commit
1c68cd80c8
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user