juewuy / ShellCrash

Run sing-box/mihomo as client in shell
8.73k stars 1.46k forks source link

[Bug] Overly strict config validation #365

Closed LaplaceTor closed 1 year ago

LaplaceTor commented 1 year ago

Verify steps

Description

My config looks like

proxies:
    name: HKT
    server: hk
    port: 15
    type: vmess
    uuid: 31
    alterId: 0
    cipher: auto
    tls: false
    skip-cert-verify: true

Then it told me that alterId missing, fixed with rewrite uuid: 31 to uuid: '31'

Each extra line for reading would get a reply that it ask for an expect word , or }

Shellclash Version 1.7.4d

juewuy commented 1 year ago

ShellClash will not overly proxies: during starting or download configs

LaplaceTor commented 1 year ago

ShellClash will not overly proxies: during starting or download configs

I just uploaded my config which is converted locally via subconverter, but I cannot pass the configuration check you build in, the config work fine on desktop and mobile I got a lot strict config validation, looks like it cannot check where the value should end, fix after do something such as add " " each value, remove the space or blank line etc.

juewuy commented 1 year ago
    yaml_p=$(grep -n "^prox" $yaml | head -1 | cut -d ":" -f 1) #获取节点起始行号
    yaml_r=$(grep -n "^rules:" $yaml | head -1 | cut -d ":" -f 1) #获取规则起始行号
    if [ "$yaml_p" -lt "$yaml_r" ];then
        sed -n "${yaml_p},${yaml_r}p" $yaml > $tmpdir/proxy.yaml
        cat $yaml | sed -n "${yaml_r},\$p" | sed '1d' | sed 's/^ *-/ -/g' > $tmpdir/rule.yaml #切割rule并对齐
    else
        cat $yaml | sed -n "${yaml_r},${yaml_p}p" | sed '1d' | sed '$d' | sed 's/^ *-/ -/g' > $tmpdir/rule.yaml #切割rule并对齐
        sed -n "${yaml_p},\$p" $yaml > $tmpdir/proxy.yaml
        sed -n "${yaml_r}p" $yaml >> $tmpdir/proxy.yaml #将rule字段附在末尾
    fi

Everything before the first "^prox" or "^rules:" will be drop.