mirror of
https://github.com/XrayR-project/XrayR.git
synced 2025-06-08 13:29:54 +00:00
add timeout
This commit is contained in:
parent
c04330d0bf
commit
d1bc36782b
@ -56,9 +56,12 @@ func (l *Limiter) AddInboundLimiter(tag string, nodeSpeedLimit uint64, userList
|
|||||||
l.g.limit = globalDeviceLimit.Limit
|
l.g.limit = globalDeviceLimit.Limit
|
||||||
l.g.timeout = globalDeviceLimit.Timeout
|
l.g.timeout = globalDeviceLimit.Timeout
|
||||||
l.g.expiry = globalDeviceLimit.Expiry
|
l.g.expiry = globalDeviceLimit.Expiry
|
||||||
_, err := l.r.Ping(context.Background()).Result()
|
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), time.Second*time.Duration(l.g.timeout))
|
||||||
|
defer cancel()
|
||||||
|
_, err := l.r.Ping(ctx).Result()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("redis connect failed: %v", err)
|
return fmt.Errorf("Redis connect failed: %v", err)
|
||||||
} else {
|
} else {
|
||||||
log.Printf("[%s] Redis connect success", tag)
|
log.Printf("[%s] Redis connect success", tag)
|
||||||
log.Printf("[%s] GlobalDeviceLimit : %d", tag, globalDeviceLimit.Limit)
|
log.Printf("[%s] GlobalDeviceLimit : %d", tag, globalDeviceLimit.Limit)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user