tindy2013 / subconverter

Utility to convert between various subscription format
GNU General Public License v3.0
13.43k stars 2.87k forks source link

[BUG] 通过Subconverter无法更新 Error code: 400 #644

Closed SplitGemini closed 1 year ago

SplitGemini commented 1 year ago

确认版本最新

检索issue

subconverter版本

0.8.0

转换过程

clash转换clash

转换设置

common:
  api_mode: false
  api_access_token: password
  default_url: []
  enable_insert: true
  insert_url: []
  prepend_insert_url: true
  exclude_remarks: ["(到期|剩余流量|时间|官网|产品|平台)"]
  include_remarks: []
  enable_filter: false
  filter_script: ""
  default_external_config: "" # config/example_external_config.yml
  base_path: base
  clash_rule_base: base/all_base.tpl
  surge_rule_base: base/all_base.tpl
  surfboard_rule_base: base/all_base.tpl
  mellow_rule_base: base/all_base.tpl
  quan_rule_base: base/all_base.tpl
  quanx_rule_base: base/all_base.tpl
  loon_rule_base: base/all_base.tpl
  sssub_rule_base: base/all_base.tpl
  # socks5://127.0.0.1:2222
  proxy_config: http://127.0.0.1:2222
  proxy_ruleset: http://127.0.0.1:2222
  proxy_subscription: http://127.0.0.1:2222
  append_proxy_type: false

userinfo:
  stream_rule: 
  - {match: "^剩余流量:(.*?)\\|总流量:(.*)$", replace: "total=$2&left=$1"}
  - {match: "^剩余流量:(.*?) (.*)$", replace: "total=$1&left=$2"}
  - {match: "^Bandwidth: (.*?)/(.*)$", replace: "used=$1&total=$2"}
  - {match: "^.*剩余(.*?)(?:\\s*?)@(?:.*)$", replace: "total=$1"}
  - {match: "^.*?流量:(.*?) 剩:(?:.*)$", replace: "total=$1"}
  time_rule:
  - {match: "^过期时间:(\\d+)-(\\d+)-(\\d+) (\\d+):(\\d+):(\\d+)$", replace: "$1:$2:$3:$4:$5:$6"}
  - {match: "^到期时间(:|:)(\\d+)-(\\d+)-(\\d+)$", replace: "$1:$2:$3:0:0:0"}
  - {match: "^Smart Access expire: (\\d+)/(\\d+)/(\\d+)$", replace: "$1:$2:$3:0:0:0"}
  - {match: "^.*?流量:(?:.*?) 剩:(.*?)天$", replace: "left=$1d"}

node_pref:
#  udp_flag: false
#  tcp_fast_open_flag: false
#  skip_cert_verify_flag: false
#  tls13_flag: false
  sort_flag: false
  sort_script: ""
  filter_deprecated_nodes: false
  append_sub_userinfo: true
  clash_use_new_field_name: true
  clash_proxies_style: flow
  rename_node:
#  - {match: "\\(?((x|X)?(\\d+)(\\.?\\d+)?)((\\s?倍率?)|(x|X))\\)?", replace: "$1x"}
#  - {script: "function rename(node){}"}
#  - {script: "path:/path/to/script.js"}
  - {import: snippets/rename_node.txt}

managed_config:
  write_managed_config: true
  managed_config_prefix: "http://127.0.0.1:25500"
  config_update_interval: 86400
  config_update_strict: false
  quanx_device_id: ""

surge_external_proxy:
  surge_ssr_path: "" # /usr/bin/ssr-local
  resolve_hostname: true

emojis:
  add_emoji: true
  remove_old_emoji: true
  rules:
#  - {match: "(流量|时间|应急)", emoji: "🏳️‍🌈"}
#  - {script: "function getEmoji(node){}"}
#  - {script: "path:/path/to/script.js"}
  - {import: snippets/emoji.txt}

rulesets:
  enabled: true
  overwrite_original_rules: false
  update_ruleset_on_request: false
  rulesets:
#  - {rule: "GEOIP,CN", group: "DIRECT"}
#  - {ruleset: "rules/LocalAreaNetwork.list", group: "DIRECT"}
#  - {ruleset: "surge:rules/LocalAreaNetwork.list", group: "DIRECT"}
#  - {ruleset: "quanx:https://raw.githubusercontent.com/ConnersHua/Profiles/master/Quantumult/X/Filter/Advertising.list", group: "Advertising", interval: 86400}
#  - {ruleset: "clash-domain:https://ruleset.dev/clash_domestic_services_domains", group: "Domestic Services", interval: 86400}
#  - {ruleset: "clash-ipcidr:https://ruleset.dev/clash_domestic_services_ips", group: "Domestic Services", interval: 86400}
#  - {ruleset: "clash-classic:https://raw.githubusercontent.com/DivineEngine/Profiles/master/Clash/RuleSet/China.yaml", group: "DIRECT", interval: 86400}
  - {import: snippets/rulesets.txt}

proxy_groups:
  custom_proxy_group:
#  - {name: UrlTest, type: url-test, rule: [".*"], url: http://www.gstatic.com/generate_204, interval: 300, tolerance: 100, timeout: 5}
#  - {name: Proxy, type: select, rule: [".*"]}
#  - {name: group1, type: select, rule: ["!!GROUPID=0"]}
#  - {name: v2ray, type: select, rule: ["!!GROUP=V2RayProvider"]}
#  - {import: snippets/groups_forcerule.txt}
#  - {name: ssid group, type: ssid, rule: ["default_group", "celluar=group0,ssid1=group1,ssid2=group2"]}
  - {import: snippets/groups.txt}

template:
  template_path: "templates"
  globals:
  - {key: clash.http_port, value: 7890}
  - {key: clash.socks_port, value: 7891}
  - {key: clash.allow_lan, value: true}
  - {key: clash.log_level, value: info}

aliases:
  - {uri: /v, target: /version}
  - {uri: /clash, target: "/sub?target=clash"}
  - {uri: /clashr, target: "/sub?target=clashr"}
  - {uri: /surge, target: "/sub?target=surge"}
  - {uri: /quan, target: "/sub?target=quan"}
  - {uri: /quanx, target: "/sub?target=quanx"}
  - {uri: /mellow, target: "/sub?target=mellow"}
  - {uri: /surfboard, target: "/sub?target=surfboard"}
  - {uri: /loon, target: "/sub?target=loon"}
  - {uri: /ss, target: "/sub?target=ss"}
  - {uri: /ssd, target: "/sub?target=ssd"}
  - {uri: /sssub, target: "/sub?target=sssub"}
  - {uri: /ssr, target: "/sub?target=ssr"}
  - {uri: /v2ray, target: "/sub?target=v2ray"}
  - {uri: /trojan, target: "/sub?target=trojan"}

tasks:
#  - name: tick
#    cronexp: "0/10 * * * * ?"
#    path: tick.js
#    timeout: 3

server:
  listen: 0.0.0.0
  port: 25500
  serve_file_root: ""

advanced:
  log_level: info
  print_debug_info: false
  max_pending_connections: 10240
  max_concurrent_threads: 2
  max_allowed_rulesets: 0
  max_allowed_rules: 0
  max_allowed_download_size: 0
  enable_cache: false
  cache_subscription: 60
  cache_config: 300
  cache_ruleset: 21600
  script_clean_context: true
  async_fetch_ruleset: false
  skip_failed_links: false

复现步骤

clash for windows使用http:;//127.0.0.1:25500连接subconverter进行转换

期望结果

可以转发

实际结果

image

直连是可以获取到配置的

错误信息

2023/10/11 Wed 19:50:16.196213 [19652 2][INFO] Fetching node data from url 'xxx'.
2023/10/11 Wed 19:50:16.196350 [19652 2][VERB] Received Link.
2023/10/11 Wed 19:50:16.196497 [19652 2][VERB] Downloading subscription data...
2023/10/11 Wed 19:50:16.196888 [19652 2][VERB] CACHE NOT EXIST: 'xxx', creating new cache.
*   Trying 127.0.0.1:2222...
* Connected to 127.0.0.1 (127.0.0.1) port 2222 (#0)
* allocate connect buffer
* Establish HTTP proxy tunnel to update.glados-config.com:443
> CONNECT update.glados-config.com:443 HTTP/1.1

Host: update.glados-config.com:443

User-Agent: subconverter/v0.8.0 cURL/7.88.1-DEV

Proxy-Connection: Keep-Alive

< HTTP/1.1 200 Connection established

< 

* CONNECT phase completed
* CONNECT tunnel established, response 200
* schannel: disabled automatic use of client certificate
* schannel: next InitializeSecurityContext failed: SEC_E_ILLEGAL_MESSAGE (0x80090326) - This error usually occurs when a fatal SSL/TLS alert is received (e.g. handshake failed). More detail may be available in the Windows System event log.
* Closing connection 0
* schannel: shutting down SSL/TLS connection with update.glados-config.com port 443
2023/10/11 Wed 19:50:16.797258 [19652 2][VERB] Fetch failed. No local cache available.
2023/10/11 Wed 19:50:16.797818 [19652 2][VERB] Cannot download subscription data.

不走代理也是一样

2023/10/11 Wed 20:06:14.766236 [16008 3][VERB] Received Link.
2023/10/11 Wed 20:06:14.794756 [16008 3][VERB] Downloading subscription data...
2023/10/11 Wed 20:06:14.833197 [16008 3][VERB] CACHE NOT EXIST: 'xxx', creating new cache.
*   Trying 35.78.253.2:443...
* Connected to update.glados-config.com (35.78.253.2) port 443 (#0)
* schannel: disabled automatic use of client certificate
* schannel: next InitializeSecurityContext failed: SEC_E_ILLEGAL_MESSAGE (0x80090326) - This error usually occurs when a fatal SSL/TLS alert is received (e.g. handshake failed). More detail may be available in the Windows System event log.
* Closing connection 0
* schannel: shutting down SSL/TLS connection with update.glados-config.com port 443
2023/10/11 Wed 20:06:15.317783 [16008 3][VERB] Fetch failed. No local cache available.
2023/10/11 Wed 20:06:15.319596 [16008 3][VERB] Cannot download subscription data.

No response

Mythologyli commented 1 year ago

glados 的特有问题,可以将 url 中的 config 换成 www 临时解决

初步判断和 libcurl 有关,我本机 ubuntu 20.04,使用系统默认版本的 libcurl-dev 编译出的 subconverter 没这个问题,而用 Github CI 编译的就有问题

Mythologyli commented 1 year ago

问题已定位

https://github.com/tindy2013/subconverter/blob/e7380d8a9c5fd977c6f0d2a91c2dc8943059d741/scripts/build.alpine.release.sh#L9

subconverter 构建时,采用了 curl+mbedTLS,在访问 GLaDOS 订阅更新站点时出错。如果使用 curl+OpenSSL 则不会出错

我稍后会放出一个使用 curl+OpenSSL 的 fork

Mythologyli commented 1 year ago

https://github.com/Mythologyli/subconverter-curl-openssl

构建可在 https://github.com/Mythologyli/subconverter-curl-openssl/actions/runs/6493905299 下载

SplitGemini commented 1 year ago

glados 的特有问题,可以将 url 中的 config 换成 www 临时解决

初步判断和 libcurl 有关,我本机 ubuntu 20.04,使用系统默认版本的 libcurl-dev 编译出的 subconverter 没这个问题,而用 Github CI 编译的就有问题

改url works

SplitGemini commented 1 year ago

Mythologyli/subconverter-curl-openssl

构建可在 Mythologyli/subconverter-curl-openssl/actions/runs/6493905299 下载

但是这个不work

Mythologyli commented 1 year ago

你是 linux 系统吗

SplitGemini commented 1 year ago

你是 linux 系统吗

不是,Windows

Mythologyli commented 1 year ago

我这个 fork 是针对 linux 版本更改的

Mythologyli commented 1 year ago

Windows 也改了: https://github.com/Mythologyli/subconverter-curl-openssl/actions/runs/6498803908

SplitGemini commented 1 year ago

Windows 也改了: Mythologyli/subconverter-curl-openssl/actions/runs/6498803908

有效,感谢大佬,👍👍👍

Marukon commented 9 months ago

Windows 也改了: https://github.com/Mythologyli/subconverter-curl-openssl/actions/runs/6498803908

大佬,actions的文件过期了,能重新编译一下吗

Mythologyli commented 9 months ago

Windows 也改了: https://github.com/Mythologyli/subconverter-curl-openssl/actions/runs/6498803908

大佬,actions的文件过期了,能重新编译一下吗

你自己 fork 一下然后编译不就好了