2023-02-18 02:01:51 +07:00
|
|
|
/*
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
2023-02-18 17:27:28 +07:00
|
|
|
* Copyright (c) 2022-2023, v2rayA Organization <team@v2raya.org>
|
2023-02-18 02:01:51 +07:00
|
|
|
*/
|
|
|
|
|
|
|
|
package config
|
|
|
|
|
2023-02-20 17:06:54 +07:00
|
|
|
import (
|
|
|
|
"fmt"
|
2023-02-25 01:38:21 +07:00
|
|
|
"github.com/v2rayA/dae/common/consts"
|
2023-02-20 17:06:54 +07:00
|
|
|
)
|
2023-02-18 02:01:51 +07:00
|
|
|
|
2023-02-25 21:53:18 +07:00
|
|
|
type patch func(params *Config) error
|
2023-02-18 02:01:51 +07:00
|
|
|
|
|
|
|
var patches = []patch{
|
2023-02-25 01:38:21 +07:00
|
|
|
patchEmptyDns,
|
|
|
|
patchDeprecatedGlobalDnsUpstream,
|
2023-02-18 02:01:51 +07:00
|
|
|
}
|
|
|
|
|
2023-02-25 21:53:18 +07:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2023-02-25 21:53:18 +07:00
|
|
|
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")
|
|
|
|
}
|
2023-02-25 21:53:18 +07:00
|
|
|
params.Global.DnsUpstream = ""
|
2023-02-25 01:38:21 +07:00
|
|
|
return nil
|
|
|
|
}
|