compassd / dcompass

A high-performance programmable DNS component aiming at robustness, speed, and flexibility
GNU General Public License v3.0
283 stars 23 forks source link

[BUG] 切换版本后配置文件不可用 #73

Closed Janet-Baker closed 2 years ago

Janet-Baker commented 2 years ago

Describe the bug 发生了什么 从2021年6月4日版本迁移到2021年10月23日版本后,启动失败。

# /usr/local/bin/dcompass -c /usr/local/etc/dcompass/config.json
Using the config file specified: /usr/local/etc/dcompass/config.json
Error: Failed to parse the configuration file

Caused by:
    table: data did not match any variant of untagged enum RuleBuilders at line 4 column 14

To Reproduce 如何重现 配置文件:config.json

{
    "verbosity": "off",
    "address": "0.0.0.0:53",
    "table": {
        "start": {
            "if": {
                "qtype": ["A"]
            },
            "then": [
                "query": {
                    "tag": "ipv4",
                    "cache_policy": "persistent"
                },
                "end"
            ],
            "else": [
                "query": {
                    "tag": "ipv6",
                    "cache_policy": "persistent"
                },
                "end"
            ]
        }
    },
    "upstreams": {
        "dlut4": {
            "udp": {
                "timeout": 1,
                "addr": "202.118.66.6:53"
            }
        },
        "dlut6": {
            "udp": {
                "timeout": 2,
                "addr": "[2001:da8:a800:3::6]:53"
            }
        },
        "qq4": {
            "https": {
                "timeout": 1,
                "no_sni": false,
                "addr": "1.12.34.56:443",
                "name": "doh-qjflggzs-dcompass.doh.pub"
            }
        },
        "ipv4": {
            "hybrid": [
                "dlut4",
                "qq4"
            ]
        },
        "ipv6": {
            "hybrid": [
                "dlut6",
                "qq4"
            ]
        }
    }
}

Version & Platform (please complete the following information) 版本信息

Additional context 附加信息 配置文件是从 Windows 版 dcompass 迁移的。在2021年6月4日版的Windows 版 dcompass 上可以使用。

LEXUGE commented 2 years ago

我猜测是因为 expression engine 导致的 可以参考一下这里 if 的写法:https://github.com/compassd/dcompass/blob/main/configs/success_rule.json

LEXUGE commented 2 years ago
{
    "verbosity": "off",
    "address": "0.0.0.0:53",
    "table": {
        "start": {
            "if": "qtype([A])",
            "then": [
                "query": {
                    "tag": "ipv4",
                    "cache_policy": "persistent"
                },
                "end"
            ],
            "else": [
                "query": {
                    "tag": "ipv6",
                    "cache_policy": "persistent"
                },
                "end"
            ]
        }
    },
    "upstreams": {
        "dlut4": {
            "udp": {
                "timeout": 1,
                "addr": "202.118.66.6:53"
            }
        },
        "dlut6": {
            "udp": {
                "timeout": 2,
                "addr": "[2001:da8:a800:3::6]:53"
            }
        },
        "qq4": {
            "https": {
                "timeout": 1,
                "no_sni": false,
                "addr": "1.12.34.56",
                "uri": "https://doh-qjflggzs-dcompass.doh.pub/dns-query"
            }
        },
        "ipv4": {
            "hybrid": [
                "dlut4",
                "qq4"
            ]
        },
        "ipv6": {
            "hybrid": [
                "dlut6",
                "qq4"
            ]
        }
    }
}

写成这样或许就可以了

EDIT: 我更新了其他的一些地方,测试可在最新版本上通过

Janet-Baker commented 2 years ago

OK 这样就可以了。 谢谢!

另,配置文件结构改了不少,比如name改成了uri,https的addr把端口去掉了,no_sni改成了sni 改结构一时爽,迁移火葬场——

LEXUGE commented 2 years ago

是的,因为到现在还在开发,所以配置没有稳定