1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-01-21 08:46:31 -05:00
v2fly/app/policy/config.go

27 lines
573 B
Go
Raw Normal View History

2017-11-27 16:09:30 -05:00
package policy
import (
"time"
"v2ray.com/core"
2017-11-27 16:09:30 -05:00
)
2017-12-14 09:02:36 -05:00
// Duration converts Second to time.Duration.
2017-11-27 16:09:30 -05:00
func (s *Second) Duration() time.Duration {
if s == nil {
return 0
}
2017-11-27 16:09:30 -05:00
return time.Second * time.Duration(s.Value)
}
func (p *Policy) ToCorePolicy() core.Policy {
var cp core.Policy
if p.Timeout != nil {
cp.Timeouts.ConnectionIdle = p.Timeout.ConnectionIdle.Duration()
cp.Timeouts.Handshake = p.Timeout.Handshake.Duration()
cp.Timeouts.DownlinkOnly = p.Timeout.DownlinkOnly.Duration()
cp.Timeouts.UplinkOnly = p.Timeout.UplinkOnly.Duration()
}
return cp
}