version: 1
kind: platform-infra-host-proxy
metadata:
  owner: unidesk
  relatedIssues:
    - 1148
    - 1110
    - 1117
defaults:
  targetId: JD01
server:
  id: benchmark-validated-master-shadowsocks-server
  enabled: true
  benchmarkRef: "pikasTech/unidesk#1110"
  implementationRef: "pikasTech/unidesk#1117"
  sourceConfigRef: "config/platform-infra/egress-proxy-sources.yaml#sources.master-shadowsocks"
  composeFile: config/platform-infra/sub2api-master-egress-proxy.compose.yaml
  serviceName: sub2api-master-egress-proxy
  containerName: unidesk-sub2api-master-egress-proxy
  image: ghcr.io/shadowsocks/ssserver-rust:latest
  configPath: /root/.unidesk/.state/secrets/platform-infra/sub2api-master-egress-proxy.config.json
  listenHost: 0.0.0.0
  listenPort: 18792
  health:
    mode: tcp
    host: 127.0.0.1
    port: 18792
sources:
  pk01-nc01-vpn-server-hysteria:
    sourceType: vpn-server-hysteria-existing
    serverRef: /root/vpn-server
    benchmarkRef: local-vpn-server
    implementationRef: /root/vpn-server
    sourceConfigRef: /root/vpn-server/output/client.yaml
    expectedServer: 152-53-229-148.nip.io:443
    client:
      mode: external-existing-hysteria
      configPath: /etc/host-proxy/hysteria-client.yaml
      serviceName: host-proxy-hysteria.service
      httpListenHost: 127.0.0.1
      httpListenPort: 10809
      socks5ListenHost: 127.0.0.1
      socks5ListenPort: 10808
    proxyUrl: http://127.0.0.1:10809
    externalProbeUrl: https://www.gstatic.com/generate_204
  nc01-vpn-server-shadowsocks:
    extends: templates.sources.singBoxHostClient
    benchmarkRef: local-vpn-server
  jd01-real-deps-master-shadowsocks:
    extends: templates.sources.singBoxHostClient
    benchmarkRef: "pikasTech/unidesk#1110"
targets:
  PK01:
    extends: templates.targets.hostProxyClient
    route: PK01
    sourceRef: sources.pk01-nc01-vpn-server-hysteria
    env:
      httpProxy: http://127.0.0.1:10809
      httpsProxy: http://127.0.0.1:10809
      allProxy: http://127.0.0.1:10809
      noProxyRefs:
        common: noProxy.common
        extras: noProxy.nodeExtras.PK01
    trans:
      hostProxyEnv:
        enabled: false
    apply:
      reloadSystemd: false
      restartDocker: false
      restartK3s: false
  NC01:
    extends: templates.targets.hostProxyClient
    route: NC01
    sourceRef: sources.nc01-vpn-server-shadowsocks
    env:
      noProxyRefs:
        common: noProxy.common
        extras: noProxy.nodeExtras.NC01
  JD01:
    extends: templates.targets.hostProxyClient
    route: JD01
    sourceRef: sources.jd01-real-deps-master-shadowsocks
    env:
      noProxyRefs:
        common: noProxy.common
        extras: noProxy.nodeExtras.JD01
templates:
  sources:
    singBoxHostClient:
      sourceType: vpn-server-shadowsocks
      serverRef: /root/vpn-server
      implementationRef: /root/vpn-server
      sourceConfigRef: "config/platform-infra/egress-proxy-sources.yaml#sources.nc01-vpn-server-shadowsocks"
      client:
        mode: trans-static-binary
        upstreamUrl: https://github.com/SagerNet/sing-box/releases/download/v1.13.14/sing-box-1.13.14-linux-amd64.tar.gz
        version: v1.13.14
        archiveCachePath: /root/.unidesk/.state/artifacts/platform-infra/sing-box-1.13.14-linux-amd64.tar.gz
        archiveSha256: f48703461a15476951ac4967cdad339d986f4b8096b4eb3ff0829a500502d697
        archiveInstallPath: /var/cache/unidesk/host-egress-proxy/sing-box-1.13.14-linux-amd64.tar.gz
        binaryMember: sing-box-1.13.14-linux-amd64/sing-box
        binaryCachePath: /root/.unidesk/.state/artifacts/platform-infra/sing-box-1.13.14-linux-amd64
        binarySha256: 68aeab83cc4ab2659a5b92232261a20746ccdafc3b3d1e19b2d63247eec3bbf7
        installPath: /usr/local/bin/sing-box
        configPath: /etc/unidesk/host-egress-proxy/sing-box.json
        unitPath: /etc/systemd/system/unidesk-host-egress-proxy.service
        serviceName: unidesk-host-egress-proxy
        listenHost: 127.0.0.1
        listenPort: 10808
        podAccess:
          enabled: true
          listenHost: 10.42.0.1
          listenPort: 10808
          proxyUrl: http://10.42.0.1:10808
        clashApiListen: 127.0.0.1:19090
        healthUrl: http://127.0.0.1:19090/connections
      proxyUrl: http://127.0.0.1:10808
      externalProbeUrl: https://www.gstatic.com/generate_204
  targets:
    hostProxyClient:
      enabled: true
      env:
        httpProxy: http://127.0.0.1:10808
        httpsProxy: http://127.0.0.1:10808
        allProxy: http://127.0.0.1:10808
      files:
        envFile: /etc/unidesk/proxy.env
        profile: /etc/profile.d/unidesk-proxy.sh
        apt: /etc/apt/apt.conf.d/90unidesk-proxy
        dockerSystemdDropIn: /etc/systemd/system/docker.service.d/10-unidesk-proxy.conf
        k3sSystemdDropIn: /etc/systemd/system/k3s.service.d/10-unidesk-proxy.conf
      trans:
        hostProxyEnv:
          enabled: true
          envFileRef: files.envFile
          applyTo: host-posix-commands
      apply:
        reloadSystemd: true
        restartDocker: true
        restartK3s: true
noProxy:
  common:
    - localhost
    - 127.0.0.1
    - "::1"
    - host.docker.internal
    - 10.0.0.0/8
    - 10.42.0.0/16
    - 10.43.0.0/16
    - 172.16.0.0/12
    - 192.168.0.0/16
    - .svc
    - .svc.cluster.local
    - .cluster.local
    - kubernetes
    - kubernetes.default
    - kubernetes.default.svc
    - argocd-repo-server
    - argocd-repo-server.argocd
    - argocd-redis
    - argocd-redis.argocd
    - git-mirror-http
    - git-mirror-http.devops-infra
    - git-mirror-write
    - git-mirror-write.devops-infra
    - 127.0.0.1:5000
    - localhost:5000
    - hyueapi.com
    - .hyueapi.com
  nodeExtras:
    PK01:
      - 152.53.229.148
      - 152-53-229-148.nip.io
    NC01:
      - 152.53.229.148
    JD01:
      - 74.48.78.17
      - 82.156.23.220
