Change interval type
This commit is contained in:
@@ -420,8 +420,8 @@ func BuildConfig(opt ConfigOptions, input option.Options) (*option.Options, erro
|
|||||||
URLTestOptions: option.URLTestOutboundOptions{
|
URLTestOptions: option.URLTestOutboundOptions{
|
||||||
Outbounds: tags,
|
Outbounds: tags,
|
||||||
URL: opt.ConnectionTestUrl,
|
URL: opt.ConnectionTestUrl,
|
||||||
Interval: opt.URLTestInterval,
|
Interval: option.Duration(opt.URLTestInterval.Duration()),
|
||||||
IdleTimeout: opt.URLTestIdleTimeout,
|
IdleTimeout: option.Duration(opt.URLTestIdleTimeout.Duration()),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/sagernet/sing-box/option"
|
"github.com/sagernet/sing-box/option"
|
||||||
dns "github.com/sagernet/sing-dns"
|
dns "github.com/sagernet/sing-dns"
|
||||||
)
|
)
|
||||||
@@ -45,8 +43,8 @@ type InboundOptions struct {
|
|||||||
|
|
||||||
type URLTestOptions struct {
|
type URLTestOptions struct {
|
||||||
ConnectionTestUrl string `json:"connection-test-url"`
|
ConnectionTestUrl string `json:"connection-test-url"`
|
||||||
URLTestInterval option.Duration `json:"url-test-interval"`
|
URLTestInterval DurationInSeconds `json:"url-test-interval"`
|
||||||
URLTestIdleTimeout option.Duration `json:"url-test-idle-timeout"`
|
URLTestIdleTimeout DurationInSeconds `json:"url-test-idle-timeout"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type RouteOptions struct {
|
type RouteOptions struct {
|
||||||
@@ -94,8 +92,8 @@ func DefaultConfigOptions() *ConfigOptions {
|
|||||||
},
|
},
|
||||||
URLTestOptions: URLTestOptions{
|
URLTestOptions: URLTestOptions{
|
||||||
ConnectionTestUrl: "http://cp.cloudflare.com/",
|
ConnectionTestUrl: "http://cp.cloudflare.com/",
|
||||||
URLTestInterval: option.Duration(10 * time.Minute),
|
URLTestInterval: DurationInSeconds(600),
|
||||||
URLTestIdleTimeout: option.Duration(100 * time.Minute),
|
URLTestIdleTimeout: DurationInSeconds(6000),
|
||||||
},
|
},
|
||||||
RouteOptions: RouteOptions{
|
RouteOptions: RouteOptions{
|
||||||
ResolveDestination: false,
|
ResolveDestination: false,
|
||||||
|
|||||||
25
config/types.go
Normal file
25
config/types.go
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type DurationInSeconds int
|
||||||
|
|
||||||
|
func (d DurationInSeconds) MarshalJSON() ([]byte, error) {
|
||||||
|
return json.Marshal(int64(d))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *DurationInSeconds) UnmarshalJSON(bytes []byte) error {
|
||||||
|
var v int64
|
||||||
|
if err := json.Unmarshal(bytes, &v); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
*d = DurationInSeconds(v)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d DurationInSeconds) Duration() time.Duration {
|
||||||
|
return time.Duration(d) * time.Second
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user