Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getNodeNames 可以筛选出指定 provider 下的节点 #51

Closed
lifesign opened this issue Dec 30, 2019 · 2 comments
Closed

getNodeNames 可以筛选出指定 provider 下的节点 #51

lifesign opened this issue Dec 30, 2019 · 2 comments

Comments

@lifesign
Copy link

lifesign commented Dec 30, 2019

场景是这样的,有一些小机场的场景想单独测试,而默认的 filter 机制,大部分是基于地域、国别或者应用,无法直接筛出指定 provider 的

目前自己使用了重命名节点+自定义 filter 的方式来跑通实现

provider 配置重命名节点

provider/self-build.js 中
renameNode: name => {
    return "SELF|" + name; // SELF 是自建的节点
 }

surgio.conf.js 中增加自定义过滤

customFilters: {
    selfFilter: utils.useKeywords(['SELF']),
},

模板中使用
🚀 Proxy = select, {{ getNodeNames(nodeList, customFilters.selfFilter) }}

虽然能实现,但是不够优雅,因为每新接入一个订阅会都需要这样配置一下,是否 surgio 原生可以支持

可以考虑如下方式

  1. getNodeNames(nodeList, filter?, separator?) 接口增加 provider ,实现指定在某个 provider 下

新接口签名 getNodeNames(nodeList, filter?, separator?, provider?)

  1. 增加默认的过滤器 providerFilter,支持传入多个 provider,这样 getNodeNames 无需改动
    providerFilter(['demo', 'self-build'])

  2. 增加一个 util 的内置方法 useProviders,支持传入多个 provider
    utils.useProviders(['demo', 'self-build'])

@geekdada
Copy link
Member

geekdada commented Jan 2, 2020

提议不错,我比较倾向使用过滤器。方式 2 和 3 都不错,不过方式 3 比较符合目前的使用习惯。

@lifesign
Copy link
Author

lifesign commented Jan 2, 2020

好的~ 期待能支持

geekdada added a commit that referenced this issue Jan 2, 2020
@geekdada geekdada closed this as completed Jan 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants