dae/config/patch.go

37 lines
914 B
Go
Raw Normal View History

/*
* SPDX-License-Identifier: AGPL-3.0-only
* Copyright (c) 2022-2023, v2rayA Organization <team@v2raya.org>
*/
package config
import (
"fmt"
2023-02-25 01:38:21 +07:00
"github.com/v2rayA/dae/common/consts"
)
type patch func(params *Config) error
var patches = []patch{
2023-02-25 01:38:21 +07:00
patchEmptyDns,
patchDeprecatedGlobalDnsUpstream,
}
func patchEmptyDns(params *Config) error {
2023-02-25 01:38:21 +07:00
if params.Dns.Routing.Request.Fallback == nil {
params.Dns.Routing.Request.Fallback = consts.DnsRequestOutboundIndex_AsIs.String()
}
if params.Dns.Routing.Response.Fallback == nil {
params.Dns.Routing.Response.Fallback = consts.DnsResponseOutboundIndex_Accept.String()
}
return nil
}
func patchDeprecatedGlobalDnsUpstream(params *Config) error {
2023-02-25 01:38:21 +07:00
if params.Global.DnsUpstream != "<empty>" {
return fmt.Errorf("'global.dns_upstream' was deprecated, please refer to the latest examples and docs for help")
}
params.Global.DnsUpstream = ""
2023-02-25 01:38:21 +07:00
return nil
}