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

feat: add proxy name replacement functionality for override #1481

Merged
merged 2 commits into from
Sep 18, 2024

Conversation

pmnmq
Copy link

@pmnmq pmnmq commented Aug 31, 2024

add proxy name field replacement functionality. When there are multiple proxy providers, the information in proxy-name can be replaced, making it easier to group them. Replacement content supports using regular expressions.

proxy-providers:
  provider1:
    type: http
    url: "url"
    path: ./provider1.yaml
    override:
      proxy-name:
        - pattern: "test"
          target: "TEST"
        - pattern: "IPLC-(.*?)倍"
          target: "iplc x $1"

override增加了proxy-name替换功能。当存在多个proxy-provider的时候将可以将proxy-name中的信息进行替换,方便进行代理分组,替换内容支持使用正则表达式

@wwqgtxx wwqgtxx force-pushed the Alpha branch 2 times, most recently from 15365f5 to 6306c6b Compare August 31, 2024 14:42
@wwqgtxx wwqgtxx force-pushed the Alpha branch 4 times, most recently from a2273e2 to 417d709 Compare September 10, 2024 13:47
@@ -41,6 +48,8 @@ type OverrideSchema struct {
IPVersion *string `provider:"ip-version,omitempty"`
AdditionalPrefix *string `provider:"additional-prefix,omitempty"`
AdditionalSuffix *string `provider:"additional-suffix,omitempty"`

ProxyName []*OverrideProxyNameSchema `provider:"proxy-name,omitempty"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里可以直接使用[]OverrideProxyNameSchema

@@ -27,6 +27,13 @@ type healthCheckSchema struct {
ExpectedStatus string `provider:"expected-status,omitempty"`
}

type OverrideProxyNameSchema struct {
// matching expression for regex replacement
Pattern string `provider:"pattern,omitempty"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个schema内部不该允许omitempty

// matching expression for regex replacement
Pattern string `provider:"pattern,omitempty"`
// the new content after regex matching
Target string `provider:"target,omitempty"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上

case "proxy-name":
exprList, ok := field.Interface().([]*OverrideProxyNameSchema)
if !ok {
return nil, errors.New("file must have a `proxy-name` field")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的报错提示不对

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感谢你的反馈,你提到的问题我会尽快处理

@wwqgtxx wwqgtxx merged commit 3676d1b into MetaCubeX:Alpha Sep 18, 2024
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

Successfully merging this pull request may close these issues.

2 participants