Skip to content

Optimize proxy chain handling for multiple nodes #7468

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

Merged
merged 3 commits into from
Jun 21, 2025

Conversation

DHR60
Copy link
Contributor

@DHR60 DHR60 commented Jun 20, 2025

添加 多配置文件-链式代理 支持

当多个配置文件使用同一个前置节点时,生成一个前置节点 outbound,多个配置文件的 sockopt 指向前置节点 outbound.tag

GenOutboundsList 负责 GenOutbound 和 GenMoreOutbounds 的功能

@DHR60
Copy link
Contributor Author

DHR60 commented Jun 20, 2025

xray outbound 输出示例:
[
  {
    "tag": "proxy-1",
    "protocol": "shadowsocks",
    "settings": {
      "servers": [
        {
          "address": "456",
          "method": "aes-128-gcm",
          "ota": false,
          "password": "456",
          "port": 456,
          "level": 1
        }
      ]
    },
    "streamSettings": {
      "network": "tcp",
      "sockopt": {
        "dialerProxy": "mid-proxy-1"
      }
    },
    "mux": {
      "enabled": false,
      "concurrency": -1
    }
  },
  {
    "tag": "mid-proxy-1",
    "protocol": "vless",
    "settings": {
      "vnext": [
        {
          "address": "0.0.0.0",
          "port": 443,
          "users": [
            {
              "id": "67b9b87f-c688-437d-a517-03e209fcb294",
              "email": "[email protected]",
              "security": "auto",
              "encryption": "none",
              "flow": "xtls-rprx-vision"
            }
          ]
        }
      ]
    },
    "streamSettings": {
      "network": "tcp",
      "security": "tls",
      "tlsSettings": {
        "allowInsecure": false,
        "serverName": "***",
        "fingerprint": "chrome"
      },
      "sockopt": {
        "dialerProxy": "proxy-prev-1"
      }
    },
    "mux": {
      "enabled": false,
      "concurrency": -1
    }
  },
  {
    "tag": "proxy-2",
    "protocol": "shadowsocks",
    "settings": {
      "servers": [
        {
          "address": "456",
          "method": "aes-128-gcm",
          "ota": false,
          "password": "456",
          "port": 456,
          "level": 1
        }
      ]
    },
    "streamSettings": {
      "network": "tcp",
      "sockopt": {
        "dialerProxy": "mid-proxy-2"
      }
    },
    "mux": {
      "enabled": false,
      "concurrency": -1
    }
  },
  {
    "tag": "mid-proxy-2",
    "protocol": "vless",
    "settings": {
      "vnext": [
        {
          "address": "0.0.0.0",
          "port": 443,
          "users": [
            {
              "id": "67b9b87f-c688-437d-a517-03e209fcb294",
              "email": "[email protected]",
              "security": "auto",
              "encryption": "none",
              "flow": "xtls-rprx-vision"
            }
          ]
        }
      ]
    },
    "streamSettings": {
      "network": "tcp",
      "security": "tls",
      "tlsSettings": {
        "allowInsecure": false,
        "serverName": "***",
        "fingerprint": "chrome"
      },
      "sockopt": {
        "dialerProxy": "proxy-prev-1"
      }
    },
    "mux": {
      "enabled": false,
      "concurrency": -1
    }
  },
  {
    "tag": "proxy-3",
    "protocol": "shadowsocks",
    "settings": {
      "servers": [
        {
          "address": "456",
          "method": "aes-128-gcm",
          "ota": false,
          "password": "456",
          "port": 456,
          "level": 1
        }
      ]
    },
    "streamSettings": {
      "network": "tcp",
      "sockopt": {
        "dialerProxy": "mid-proxy-3"
      }
    },
    "mux": {
      "enabled": false,
      "concurrency": -1
    }
  },
  {
    "tag": "mid-proxy-3",
    "protocol": "vless",
    "settings": {
      "vnext": [
        {
          "address": "0.0.0.0",
          "port": 443,
          "users": [
            {
              "id": "67b9b87f-c688-437d-a517-03e209fcb294",
              "email": "[email protected]",
              "security": "auto",
              "encryption": "none",
              "flow": "xtls-rprx-vision"
            }
          ]
        }
      ]
    },
    "streamSettings": {
      "network": "tcp",
      "security": "tls",
      "tlsSettings": {
        "allowInsecure": false,
        "serverName": "***",
        "fingerprint": "safari"
      },
      "sockopt": {
        "dialerProxy": "proxy-prev-1"
      }
    },
    "mux": {
      "enabled": false,
      "concurrency": -1
    }
  },
  {
    "tag": "proxy-prev-1",
    "protocol": "shadowsocks",
    "settings": {
      "servers": [
        {
          "address": "123",
          "method": "aes-128-gcm",
          "ota": false,
          "password": "123",
          "port": 123,
          "level": 1
        }
      ]
    },
    "streamSettings": {
      "network": "tcp"
    },
    "mux": {
      "enabled": false,
      "concurrency": -1
    }
  },
  {
    "tag": "direct",
    "protocol": "freedom"
  },
  {
    "tag": "block",
    "protocol": "blackhole"
  }
]
sing-box outbound 输出示例:
[
  {
    "type": "selector",
    "tag": "proxy",
    "outbounds": [
      "proxy-auto",
      "proxy-1",
      "proxy-2",
      "proxy-3"
    ],
    "interrupt_exist_connections": false
  },
  {
    "type": "urltest",
    "tag": "proxy-auto",
    "outbounds": [
      "proxy-1",
      "proxy-2",
      "proxy-3"
    ],
    "interrupt_exist_connections": false
  },
  {
    "type": "shadowsocks",
    "tag": "proxy-1",
    "server": "456",
    "server_port": 456,
    "detour": "mid-proxy-1",
    "method": "aes-128-gcm",
    "password": "456"
  },
  {
    "type": "vless",
    "tag": "mid-proxy-1",
    "server": "0.0.0.0",
    "server_port": 443,
    "uuid": "67b9b87f-c688-437d-a517-03e209fcb294",
    "flow": "xtls-rprx-vision",
    "detour": "proxy-prev-1",
    "packet_encoding": "xudp",
    "tls": {
      "enabled": true,
      "server_name": "***",
      "insecure": false,
      "utls": {
        "enabled": true,
        "fingerprint": "chrome"
      }
    }
  },
  {
    "type": "shadowsocks",
    "tag": "proxy-2",
    "server": "456",
    "server_port": 456,
    "detour": "mid-proxy-2",
    "method": "aes-128-gcm",
    "password": "456"
  },
  {
    "type": "vless",
    "tag": "mid-proxy-2",
    "server": "0.0.0.0",
    "server_port": 443,
    "uuid": "67b9b87f-c688-437d-a517-03e209fcb294",
    "flow": "xtls-rprx-vision",
    "detour": "proxy-prev-1",
    "packet_encoding": "xudp",
    "tls": {
      "enabled": true,
      "server_name": "***",
      "insecure": false,
      "utls": {
        "enabled": true,
        "fingerprint": "chrome"
      }
    }
  },
  {
    "type": "shadowsocks",
    "tag": "proxy-3",
    "server": "456",
    "server_port": 456,
    "detour": "mid-proxy-3",
    "method": "aes-128-gcm",
    "password": "456"
  },
  {
    "type": "vless",
    "tag": "mid-proxy-3",
    "server": "0.0.0.0",
    "server_port": 443,
    "uuid": "67b9b87f-c688-437d-a517-03e209fcb294",
    "flow": "xtls-rprx-vision",
    "detour": "proxy-prev-1",
    "packet_encoding": "xudp",
    "tls": {
      "enabled": true,
      "server_name": "***",
      "insecure": false,
      "utls": {
        "enabled": true,
        "fingerprint": "safari"
      }
    }
  },
  {
    "type": "shadowsocks",
    "tag": "proxy-prev-1",
    "server": "123",
    "server_port": 123,
    "method": "aes-128-gcm",
    "password": "123"
  },
  {
    "type": "direct",
    "tag": "direct"
  },
  {
    "type": "block",
    "tag": "block"
  },
  {
    "type": "dns",
    "tag": "dns_out"
  }
]

@2dust
Copy link
Owner

2dust commented Jun 21, 2025

是好功能,但是产生配置文件变得更复杂了。。。

@2dust 2dust closed this Jun 21, 2025
@2dust 2dust reopened this Jun 21, 2025
@2dust 2dust merged commit fefa7de into 2dust:master Jun 21, 2025
@DHR60 DHR60 deleted the proxy_chain_multi_node branch June 21, 2025 10:45
@DHR60
Copy link
Contributor Author

DHR60 commented Jun 21, 2025

确实,ai 优化后代码量多了一倍,不过整体代码可读性比我写的好

后面我试试优化代码,添加个辅助函数或与 GenMoreOutbounds 联动

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